mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Can get older messages
This commit is contained in:
@ -264,6 +264,25 @@ export class ConversationsController {
|
||||
h.success("Conversation message was sent!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the older messages of a conversation
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async GetOlderMessages(h: RequestHandler) {
|
||||
const convID = await this.GetPostConversationId("conversationID", h);
|
||||
const maxID = h.postInt("oldest_message_id") - 1;
|
||||
|
||||
let limit = h.postInt("limit");
|
||||
if(limit < 1) limit = 1;
|
||||
else if(limit > 30) limit = 30;
|
||||
|
||||
// Get the list of messages
|
||||
const messages = await ConversationsHelper.GetOlderMessage(convID, maxID, limit);
|
||||
|
||||
h.send(messages.map(e => this.ConversationMessageToAPI(e)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and return safely a conversation ID specified in a $_POST Request
|
||||
*
|
||||
|
@ -64,6 +64,8 @@ export const Routes : Route[] = [
|
||||
{path: "/conversations/refresh_single", cb: (h) => ConversationsController.RefreshSingleConversation(h)},
|
||||
|
||||
{path: "/conversations/sendMessage", cb: (h) => ConversationsController.SendMessage(h)},
|
||||
|
||||
{path: "/conversations/get_older_messages", cb: (h) => ConversationsController.GetOlderMessages(h)},
|
||||
|
||||
|
||||
// Search controller
|
||||
|
Reference in New Issue
Block a user