mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { HttpService } from 'src/app/services/http.service';
|
|
import { MessageInputDTO, MessageInputDTOSchema } from '../../dto/message/messageInputDtO';
|
|
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
|
import { APIReturn } from 'src/app/services/decorators/api-validate-schema.decorator';
|
|
import { MessageOutPutDataDTOSchema, MessageOutPutDTO, MessageOutPutDTOSchema } from '../../dto/message/messageOutputDTO';
|
|
import { DataSourceReturn } from 'src/app/services/Repositorys/type';
|
|
import { SignalRService } from '../../../infra/socket/signal-r.service';
|
|
import { MessageUpdateInput } from '../../../domain/use-case/message-update-by-id-use-case.service';
|
|
import { SessionStore } from 'src/app/store/session.service';
|
|
import { MessageDeleteInputDTO } from '../../dto/message/messageDeleteInputDTO';
|
|
import { InstanceId } from '../../../domain/chat-service.service';
|
|
import { v4 as uuidv4 } from 'uuid'
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class MessageRemoteDataSourceService {
|
|
|
|
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
|
|
|
|
constructor(
|
|
private httpService: HttpService,
|
|
private socket: SignalRService,
|
|
) {}
|
|
|
|
@APIReturn(MessageOutPutDTOSchema, 'post/Messages')
|
|
@ValidateSchema(MessageInputDTOSchema)
|
|
async sendMessage(data: MessageInputDTO) {
|
|
return await this.httpService.post<MessageOutPutDTO>(`${this.baseUrl}/Messages`, data);
|
|
}
|
|
|
|
async reactToMessage(id: string, reaction: any) {
|
|
return await this.httpService.post<any>(`${this.baseUrl}/Messages/${id}/React`, reaction);
|
|
}
|
|
|
|
|
|
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
|
async getMessagesFromRoom(id: string): DataSourceReturn<MessageOutPutDTO> {
|
|
return await this.httpService.get(`${this.baseUrl}/Room/${id}/Messages`);
|
|
}
|
|
|
|
|
|
@APIReturn(MessageOutPutDTOSchema, 'get/Messages/attachment')
|
|
async getAttachment(id: string): DataSourceReturn<MessageOutPutDTO> {
|
|
return await this.httpService.get(`${this.baseUrl}/attachment/${id}`);
|
|
}
|
|
|
|
|
|
}
|