mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-12-28 14:38:52 +00:00
Can get the messages of a single conversation.
This commit is contained in:
parent
2d29db4900
commit
cdf59e29b8
@ -179,6 +179,29 @@ export class ConversationsController {
|
||||
h.send(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the messages of a single conversation
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async RefreshSingleConversation(h: RequestHandler) {
|
||||
const convID = await this.GetPostConversationId("conversationID", h);
|
||||
const lastMessageID = h.postInt("last_message_id");
|
||||
|
||||
const messages = lastMessageID == 0 ?
|
||||
|
||||
// Get lastest messages (the user has no message yet)
|
||||
await ConversationsHelper.GetLastMessages(convID, 10) :
|
||||
|
||||
// Get new messages
|
||||
await ConversationsHelper.GetNewMessages(convID, lastMessageID);
|
||||
|
||||
// Specify the user has seen the last message
|
||||
await ConversationsHelper.MarkUserSeen(convID, h.getUserId());
|
||||
|
||||
h.send(h.send(messages.map(e => this.ConversationMessageToAPI(e)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and return safely a conversation ID specified in a $_POST Request
|
||||
*
|
||||
|
@ -58,6 +58,8 @@ export const Routes : Route[] = [
|
||||
{path: "/conversations/updateSettings", cb: (h) => ConversationsController.UpdateSettings(h)},
|
||||
|
||||
{path: "/conversations/refresh", cb: (h) => ConversationsController.RefreshList(h)},
|
||||
|
||||
{path: "/conversations/refresh_single", cb: (h) => ConversationsController.RefreshSingleConversation(h)},
|
||||
|
||||
|
||||
// Search controller
|
||||
|
Loading…
Reference in New Issue
Block a user