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

Can delete a single conversation message

This commit is contained in:
2019-12-07 18:52:20 +01:00
parent 327cbe434d
commit 8737607b53
3 changed files with 50 additions and 0 deletions

View File

@ -310,6 +310,26 @@ export class ConversationsHelper {
})).map(m => this.DBToConversationMessage(convID, m));
}
/**
* Get information about a single conversation message
*
* @param messageID The ID of the message to get
* @throws If the message was not found
*/
private static async GetSingleMessage(messageID: number) : Promise<ConversationMessage> {
const row = await DatabaseHelper.QueryRow({
table: MESSAGES_TABLE,
where: {
id: messageID
}
});
if(row == null)
throw Error("The message was not found!");
return this.DBToConversationMessage(row.conv_id, row);
}
/**
* Get older messages of a conversation
*
@ -565,6 +585,18 @@ export class ConversationsHelper {
await this.RemoveMember(convID, memberID);
}
/**
* Delete a conversation message identified by its ID
*
* @param id The ID of the message to delete
*/
public static async DeleteMessageById(id: number) {
// Get information about the message
const message = await this.GetSingleMessage(id);
await this.DeleteMessage(message);
}
/**
* Delete a conversation message from the database
*