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

Can update conversation message content

This commit is contained in:
2019-12-07 18:39:59 +01:00
parent fad098114a
commit 327cbe434d
3 changed files with 57 additions and 0 deletions

View File

@ -243,6 +243,22 @@ export class ConversationsHelper {
}) == 1;
}
/**
* Check out whether a user is the owner of a message or not
*
* @param userID Target user ID
* @param messageID Target message ID
*/
public static async IsUserMessageOwner(userID: number, messageID: number) : Promise<boolean> {
return (await DatabaseHelper.Count({
table: MESSAGES_TABLE,
where: {
id: messageID,
user_id: userID
}
})) > 0;
}
/**
* Get the last messages of a conversation
*
@ -382,6 +398,24 @@ export class ConversationsHelper {
}
/**
* Update message content
*
* @param messageID Target message ID
* @param newContent New message content
*/
public static async UpdateMessageContent(messageID: number, newContent: string) {
await DatabaseHelper.UpdateRows({
table: MESSAGES_TABLE,
where: {
id: messageID
},
set: {
message: newContent
}
});
}
/**
* Search for private conversations between two users
*