1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-26 07:19:23 +00:00

Can mark conversation messages as seen

This commit is contained in:
Pierre HUBERT 2019-11-30 15:22:10 +01:00
parent 46f6e15b02
commit c9f25a46ae
2 changed files with 21 additions and 1 deletions

View File

@ -139,7 +139,8 @@ export class ConversationsController {
list["conversation-" + convID] = (await ConversationsHelper.GetLastMessages(convID, 10)) list["conversation-" + convID] = (await ConversationsHelper.GetLastMessages(convID, 10))
.map(e => this.ConversationMessageToAPI(e)); .map(e => this.ConversationMessageToAPI(e));
// TODO : mark the user has seen the messages // Mark the user has seen the messages
await ConversationsHelper.MarkUserSeen(convID, h.getUserId());
} }
} }

View File

@ -258,6 +258,25 @@ export class ConversationsHelper {
})).map(m => this.DBToConversationMessage(convID, m)); })).map(m => this.DBToConversationMessage(convID, m));
} }
/**
* Mark the user has seen the last messages of the conversation
*
* @param convID Target conversation ID
* @param userID Target user ID
*/
public static async MarkUserSeen(convID: number, userID: number) {
await DatabaseHelper.UpdateRows({
table: USERS_TABLE,
where: {
conv_id: convID,
user_id: userID
},
set: {
saw_last_message: 1
}
});
}
/** /**
* Get the list of members of a conversation * Get the list of members of a conversation
* *