mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
34 lines
820 B
TypeScript
34 lines
820 B
TypeScript
|
|
import { Injectable } from '@angular/core';
|
||
|
|
import { MessageEntity } from '../entity/message';
|
||
|
|
import { SessionStore } from 'src/app/store/session.service';
|
||
|
|
import { MessageRepositoryService } from "src/app/module/chat/data/repository/message-respository.service"
|
||
|
|
import { z } from 'zod';
|
||
|
|
|
||
|
|
const MessageInputUseCaseSchema = z.object({
|
||
|
|
memberId: z.number(),
|
||
|
|
roomId: z.string(),
|
||
|
|
message: z.string()
|
||
|
|
})
|
||
|
|
|
||
|
|
export type MessageInputUseCase = z.infer< typeof MessageInputUseCaseSchema>
|
||
|
|
|
||
|
|
@Injectable({
|
||
|
|
providedIn: 'root'
|
||
|
|
})
|
||
|
|
export class MessageCreateUseCaseService {
|
||
|
|
|
||
|
|
constructor(
|
||
|
|
private MessageRepositoryService: MessageRepositoryService
|
||
|
|
) { }
|
||
|
|
|
||
|
|
|
||
|
|
async execute(input: MessageEntity) {
|
||
|
|
|
||
|
|
input.sendAttemp++;
|
||
|
|
|
||
|
|
const result = await this.MessageRepositoryService.sendMessage(input)
|
||
|
|
|
||
|
|
return result
|
||
|
|
}
|
||
|
|
}
|