add readAt and delete message

This commit is contained in:
Peter Maquiran
2024-07-31 17:23:44 +01:00
parent 128d92fe5e
commit 82e4acbe87
14 changed files with 287 additions and 67 deletions
@@ -88,6 +88,19 @@ export class MessageLocalDataSourceService {
}
}
async deleteByMessageId(messageId: string): Promise<Result<undefined|TableMessage, any>> {
try {
console.log(messageId)
const lastMessage = await messageDataSource.message
.where('messageId')
.equals(messageId).delete()
return ok(lastMessage[0]); // Get the last message
} catch (error) {
return err(error);
}
}
async sendMessage(data: MessageInputDTO) {
@@ -121,6 +134,25 @@ export class MessageLocalDataSourceService {
}
async messageExist({messageId}) {
try {
const existingMessage = await messageDataSource.message
.where('messageId')
.equals(messageId)
.first();
if (existingMessage) {
return ok(true)
} else {
return err(false)
}
} catch (error) {
return err(false);
}
}
async update(data: TableMessage ) {
try {