mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 21:39:22 +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);
|
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
|
* Get and return safely a conversation ID specified in a $_POST Request
|
||||||
*
|
*
|
||||||
|
@ -59,6 +59,8 @@ export const Routes : Route[] = [
|
|||||||
|
|
||||||
{path: "/conversations/refresh", cb: (h) => ConversationsController.RefreshList(h)},
|
{path: "/conversations/refresh", cb: (h) => ConversationsController.RefreshList(h)},
|
||||||
|
|
||||||
|
{path: "/conversations/refresh_single", cb: (h) => ConversationsController.RefreshSingleConversation(h)},
|
||||||
|
|
||||||
|
|
||||||
// Search controller
|
// Search controller
|
||||||
{path: "/search/user", cb: (h) => SearchController.SearchUser(h)},
|
{path: "/search/user", cb: (h) => SearchController.SearchUser(h)},
|
||||||
|
Loading…
Reference in New Issue
Block a user