From b16b84289bc840d1a6a210726fe8350f0291ccf0 Mon Sep 17 00:00:00 2001 From: Mohammed S Date: Wed, 13 Mar 2024 12:45:47 +0530 Subject: [PATCH] fix: chat.info changes (#1163) --- packages/restapi/src/lib/chat/getChatInfo.ts | 18 ++++++++++++------ packages/restapi/src/lib/pushapi/chat.ts | 6 +++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/restapi/src/lib/chat/getChatInfo.ts b/packages/restapi/src/lib/chat/getChatInfo.ts index 3401891e5..092135610 100644 --- a/packages/restapi/src/lib/chat/getChatInfo.ts +++ b/packages/restapi/src/lib/chat/getChatInfo.ts @@ -2,6 +2,7 @@ import { getAPIBaseUrls } from '../helpers'; import Constants, { ENV } from '../constants'; import { axiosGet } from '../utils/axiosUtil'; import { handleError } from '../errors/ValidationError'; +import { getUserDID } from './helpers'; /** * Represents the response type for the chat status. @@ -11,14 +12,16 @@ export interface ChatInfoResponse { group: boolean; }; list: string; + participants: string[]; + chatId: string } /** * Represents the input type for fetching chat status. */ export interface GetChatInfoType { - chatId: string; - address: string; // Ethereum address or similar + receipient: string; + sender: string; // Ethereum address or similar env?: ENV; } @@ -28,15 +31,18 @@ export interface GetChatInfoType { export const getChatInfo = async ( options: GetChatInfoType ): Promise => { - const { chatId, address, env = Constants.ENV.PROD } = options; + const { receipient, sender, env = Constants.ENV.PROD } = options; try { - if (!chatId || !address) { - throw new Error('chatId and address cannot be null or empty'); + if (!receipient || !sender) { + throw new Error('receipient and sender cannot be null or empty'); } const API_BASE_URL = getAPIBaseUrls(env); - const requestUrl = `${API_BASE_URL}/v1/chat/${chatId}/address/${address}`; + const requestUrl = `${API_BASE_URL}/v1/chat/${await getUserDID( + receipient, + env + )}/address/${await getUserDID(sender, env)}`; const response = await axiosGet(requestUrl); return response.data; } catch (err) { diff --git a/packages/restapi/src/lib/pushapi/chat.ts b/packages/restapi/src/lib/pushapi/chat.ts index e43e191f4..074bc6dfb 100644 --- a/packages/restapi/src/lib/pushapi/chat.ts +++ b/packages/restapi/src/lib/pushapi/chat.ts @@ -283,10 +283,10 @@ export class Chat { }); } - async info(chatId: string, address: string): Promise { + async info(receipient: string): Promise { const options: PUSH_CHAT.GetChatInfoType = { - chatId: chatId, - address: address, + receipient: receipient, + sender: this.account, env: this.env, };