2024-06-04 13:12:38 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { HttpService } from 'src/app/services/http.service';
|
2024-07-11 10:28:21 +01:00
|
|
|
import { DataSourceReturn } from 'src/app/services/Repositorys/type';
|
2024-08-27 11:00:32 +01:00
|
|
|
import { SignalRService } from 'src/app/infra/socket/signalR/signal-r.service';
|
2024-08-27 15:42:11 +01:00
|
|
|
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
2024-08-27 20:29:57 +01:00
|
|
|
import { IMessageGetAllByRoomIdOutPut } from 'src/app/core/chat/usecase/message/message-get-all-by-room-Id';
|
|
|
|
|
import { IMessageRemoteRepository } from 'src/app/core/chat/repository/message/message-remote-repository';
|
2024-06-04 13:12:38 +01:00
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
2024-08-27 20:29:57 +01:00
|
|
|
export class MessageRemoteDataSourceService implements IMessageRemoteRepository {
|
2024-06-04 13:12:38 +01:00
|
|
|
|
|
|
|
|
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
|
|
|
|
|
|
2024-08-18 15:40:43 +01:00
|
|
|
constructor(
|
|
|
|
|
private httpService: HttpService,
|
|
|
|
|
private socket: SignalRService,
|
2024-08-27 15:42:11 +01:00
|
|
|
private http: HttpAdapter
|
2024-08-18 15:40:43 +01:00
|
|
|
) {}
|
2024-06-04 13:12:38 +01:00
|
|
|
|
2024-08-08 15:53:00 +01:00
|
|
|
|
2024-08-15 10:26:20 +01:00
|
|
|
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
2024-08-27 20:29:57 +01:00
|
|
|
async getMessagesFromRoom(id: string): DataSourceReturn<IMessageGetAllByRoomIdOutPut> {
|
2024-08-27 15:42:11 +01:00
|
|
|
|
2024-08-27 20:29:57 +01:00
|
|
|
var a = await this.http.get<IMessageGetAllByRoomIdOutPut>(`${this.baseUrl}/Room/${id}/Messages`)
|
2024-08-27 15:42:11 +01:00
|
|
|
|
|
|
|
|
return a.map((e) => {
|
|
|
|
|
return e.data
|
|
|
|
|
})
|
2024-08-13 10:52:35 +01:00
|
|
|
|
2024-08-27 20:29:57 +01:00
|
|
|
// return await this.httpService.get(`${this.baseUrl}/Room/${id}/Messages`);
|
2024-08-13 10:52:35 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-04 13:12:38 +01:00
|
|
|
}
|