1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 08:35:17 +00:00

Can get older messages

This commit is contained in:
2019-12-07 17:08:53 +01:00
parent 4ade176434
commit ae88b7a979
3 changed files with 43 additions and 0 deletions

View File

@ -276,6 +276,28 @@ export class ConversationsHelper {
})).map(m => this.DBToConversationMessage(convID, m));
}
/**
* Get older messages of a conversation
*
* @param convID ID of the target conversation
* @param startID ID from which the research should start
* @param limit Maximum number of messages to get
* @return The list of messages
*/
public static async GetOlderMessage(convID: number, startID: number, limit: number) : Promise<Array<ConversationMessage>> {
return (await DatabaseHelper.Query({
table: MESSAGES_TABLE,
where: {
conv_id: convID,
},
customWhere: "ID <= ?",
customWhereArgs: [startID.toString()],
order: "id DESC",
limit: limit
}))
.map(m => this.DBToConversationMessage(convID, m)).reverse();
}
/**
* Mark the user has seen the last messages of the conversation
*