2024-06-04 13:12:38 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { HttpService } from 'src/app/services/http.service';
|
|
|
|
|
import { MessageListInputDTO } from '../../dto/message/messageListInputDTO';
|
2024-06-04 16:21:11 +01:00
|
|
|
import { DataSourceReturn } from '../../../type';
|
2024-06-05 10:28:38 +01:00
|
|
|
import { MessageInputDTO, MessageInputDTOSchema } from '../../dto/message/messageInputDtO';
|
|
|
|
|
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
|
|
|
|
import { MessageOutPutDTO } from '../../dto/message/messageOutputDTO';
|
2024-06-05 15:35:38 +01:00
|
|
|
import { MessageListOutput } from '../../dto/message/messageListOutputDTO';
|
2024-06-04 13:12:38 +01:00
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class MessageRemoteDataSourceService {
|
|
|
|
|
|
|
|
|
|
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
|
|
|
|
|
|
|
|
|
|
constructor(private httpService: HttpService) {}
|
|
|
|
|
|
2024-06-05 10:28:38 +01:00
|
|
|
@ValidateSchema(MessageInputDTOSchema)
|
|
|
|
|
async sendMessage(data: MessageInputDTO) {
|
|
|
|
|
return await this.httpService.post<MessageOutPutDTO>(`${this.baseUrl}/Messages`, data);
|
2024-06-04 13:12:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async reactToMessage(id: string, reaction: any) {
|
|
|
|
|
return await this.httpService.post<any>(`${this.baseUrl}/Messages/${id}/React`, reaction);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-05 15:35:38 +01:00
|
|
|
async getMessagesFromRoom(id: string): DataSourceReturn<MessageListOutput> {
|
2024-06-04 16:21:11 +01:00
|
|
|
return await this.httpService.get(`${this.baseUrl}/Room/${id}/Messages`);
|
2024-06-04 13:12:38 +01:00
|
|
|
}
|
2024-06-05 14:31:26 +01:00
|
|
|
|
2024-06-04 13:12:38 +01:00
|
|
|
}
|