mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
fix chat send attchment
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ import { environment } from 'src/environments/environment';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AttachmentRemoteDataSourceService implements IAttachmentRemoteRepository {
|
||||
private baseUrl = `${environment.apiURLStage.slice(0, -1)}`; // Your base URL
|
||||
private baseUrl = `${environment.apiURLStage}chat`; // Your base URL
|
||||
|
||||
constructor(
|
||||
private httpService: HttpService,
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ export class MessageSocketRepositoryService implements IMessageSocketRepository
|
||||
data['requestId'] = uuidv4();
|
||||
}
|
||||
|
||||
const result = await this.socket.sendData<MessageCreateOutPutDataDTO>({
|
||||
const result = await this.socket.sendData<MessageOutPutDataDTO>({
|
||||
method: 'sendMessage',
|
||||
data: data,
|
||||
})
|
||||
|
||||
@@ -9,11 +9,12 @@ import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Result } from 'neverthrow';
|
||||
import { HttpResult } from 'src/app/infra/http/type';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { MessageAttachmentInput } from 'src/app/core/chat/usecase/message/message-attachment-upload-use-case.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MessageRemoteDataSourceService implements IMessageRemoteRepository {
|
||||
export class MessageRemoteDataSourceService {
|
||||
|
||||
private baseUrl = `${environment.apiURLStage}Chat`; // Your base URL
|
||||
|
||||
@@ -23,6 +24,13 @@ export class MessageRemoteDataSourceService implements IMessageRemoteRepository
|
||||
private http: HttpAdapter
|
||||
) {}
|
||||
|
||||
async messageAttachmentUpload(input: MessageAttachmentInput) {
|
||||
var a = await this.http.post<IMessageGetAllByRoomIdOutPut>(`${this.baseUrl}/attachment`, input)
|
||||
return a.map((e) => {
|
||||
return e.data.data["attachmentId"] as String
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||
async getMessagesFromRoom(input: IGetMessagesFromRoomParams): DataSourceReturn<IMessageGetAllByRoomIdOutPut> {
|
||||
|
||||
@@ -2,17 +2,20 @@ import { Injectable } from '@angular/core';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { IProfilePictureInputDTO } from '../dto/profilePictureInputDTO';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
||||
import { TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
||||
import { IUserRepositoryLoginParams, UserRefreshTokenInputDTO } from 'src/app/core/user/repository/user-remote-repository';
|
||||
import { IUserRemoteRepository, IUserRepositoryLoginParams, UserLoginOutputResponse, UserRefreshTokenInputDTO } from 'src/app/core/user/repository/user-remote-repository';
|
||||
import { UserLoginOutput } from 'src/app/core/user/use-case/user-login-use-case.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { UserGetByIdOutput } from 'src/app/core/user/use-case/user-get-by-id.service';
|
||||
import { Result } from 'neverthrow';
|
||||
import { UserPhotoUploadInput } from 'src/app/core/user/use-case/user-photo-upload.service';
|
||||
import { HttpResult } from 'src/app/infra/http/type';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserRemoteRepositoryService {
|
||||
export class UserRemoteRepositoryService implements IUserRemoteRepository{
|
||||
|
||||
private baseUrl = `${environment.apiURLStage.slice(0, -1)}`; // Your base URL
|
||||
|
||||
@@ -21,12 +24,14 @@ export class UserRemoteRepositoryService {
|
||||
private http: HttpAdapter,
|
||||
) { }
|
||||
|
||||
async uploadPhoto(input: UserPhotoUploadInput): Promise<Result<HttpResult<any>, HttpErrorResponse>> {
|
||||
return await this.http.post<UserGetByIdOutput>(`${this.baseUrl}/Users/${SessionStore.user.UserId}/photo`, input)
|
||||
}
|
||||
|
||||
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||
async login(input: IUserRepositoryLoginParams) {
|
||||
|
||||
return await this.http.post<UserLoginOutput>(`${this.baseUrl}/Users/login`, input)
|
||||
}
|
||||
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||
async login(input: IUserRepositoryLoginParams) {
|
||||
return await this.http.post<UserLoginOutputResponse>(`${this.baseUrl}/Users/login`, input)
|
||||
}
|
||||
|
||||
// @APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||
async logout() {
|
||||
@@ -43,17 +48,4 @@ export class UserRemoteRepositoryService {
|
||||
return await this.http.get<UserGetByIdOutput>(`${this.baseUrl}/Users/${SessionStore.user.UserId}`, {})
|
||||
}
|
||||
|
||||
addUserProfilePhoto(data: IProfilePictureInputDTO) {
|
||||
const geturl = environment.apiURL + 'UserAuthentication/AddPhoto';
|
||||
|
||||
let http = new HttpHeaders();
|
||||
|
||||
http = http.set('content-type', "application/json");
|
||||
http = http.set('accept', "application/json");
|
||||
let options = {
|
||||
headers: http
|
||||
};
|
||||
|
||||
return this.httpService.post<string>(`${geturl}`, data, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,20 +27,6 @@ export class UserRepositoryService {
|
||||
return result
|
||||
}
|
||||
|
||||
async addUserProfilePhoto(data: IProfilePictureInputDTO, tracing?: TracingType) {
|
||||
const result = await this.remote.addUserProfilePhoto(data)
|
||||
|
||||
|
||||
if(result.isOk()) {
|
||||
this.local.addProfilePicture({base64: 'data:image/jpeg;base64,' + data.ImageBase64})
|
||||
} else {
|
||||
tracing?.setAttribute("picture.upload", "false")
|
||||
tracing?.hasError("cant upload picture")
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
getProfilePictureLive() {
|
||||
return this.local.getLiveProfilePicture()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user