Files
doneit-web/src/app/module/chat/domain/use-case/socket/socket-message-delete-use-case.service.ts
T

48 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-08-02 16:20:26 +01:00
import { Injectable } from '@angular/core';
2024-08-19 16:01:58 +01:00
import { MessageLocalDataSourceService } from '../../../data/repository/message/message-local-data-source.service';
2024-08-27 20:29:57 +01:00
import { MessageEntitySchema } from 'src/app/core/chat/entity/message';
import { z } from 'zod';
const SocketMessageDeleteOutputSchema = MessageEntitySchema.pick({
id: true,
attachments: true,
canEdit: true,
editedAt: true,
info: true,
isDeleted: true,
message: true,
messageType: true,
oneShot: true,
reactions: true,
receiverId: true,
requireUnlock: true,
roomId: true,
sender: true,
sending: true,
sentAt: true,
})
export type ISocketMessageDeleteOutput = z.infer<typeof SocketMessageDeleteOutputSchema>
2024-08-02 16:20:26 +01:00
@Injectable({
providedIn: 'root'
})
export class SocketMessageDeleteUseCaseService {
constructor(
private messageLocalDataSourceService: MessageLocalDataSourceService
) { }
2024-08-27 20:29:57 +01:00
async execute(input: ISocketMessageDeleteOutput) {
2024-08-26 14:47:03 +01:00
const result = await this.messageLocalDataSourceService.update(input.id, { isDeleted: true})
2024-08-02 16:20:26 +01:00
if(result.isOk()) {
} else {
console.log(result.error)
}
}
}