From 50767c39a001c36940ee34e01d45f689ba395490 Mon Sep 17 00:00:00 2001 From: Aryan-Verma-999 Date: Sun, 1 Mar 2026 22:20:55 +0530 Subject: [PATCH] fix(api): replace deprecated method.call endpoints with REST equivalents --- packages/api/src/EmbeddedChatApi.ts | 56 +------------------ packages/react/src/hooks/useFetchChatData.js | 4 +- .../react/src/views/ChatHeader/ChatHeader.js | 3 +- 3 files changed, 6 insertions(+), 57 deletions(-) diff --git a/packages/api/src/EmbeddedChatApi.ts b/packages/api/src/EmbeddedChatApi.ts index 72e25a0466..9267c8c843 100644 --- a/packages/api/src/EmbeddedChatApi.ts +++ b/packages/api/src/EmbeddedChatApi.ts @@ -495,32 +495,17 @@ export default class EmbeddedChatApi { try { const { userId, authToken } = (await this.auth.getCurrentUser()) || {}; const response = await fetch( - `${this.host}/api/v1/method.call/rooms%3Aget`, + `${this.host}/api/v1/rooms.info?roomId=${this.rid}`, { - body: JSON.stringify({ - message: JSON.stringify({ - msg: "method", - id: null, - method: "rooms/get", - params: [], - }), - }), headers: { "Content-Type": "application/json", "X-Auth-Token": authToken, "X-User-Id": userId, }, - method: "POST", + method: "GET", } ); - - const result = await response.json(); - - if (result.success && result.message) { - const parsedMessage = JSON.parse(result.message); - return parsedMessage; - } - return null; + return await response.json(); } catch (err) { console.error(err); } @@ -695,41 +680,6 @@ export default class EmbeddedChatApi { } } - async getUserRoles() { - try { - const { userId, authToken } = (await this.auth.getCurrentUser()) || {}; - const response = await fetch( - `${this.host}/api/v1/method.call/getUserRoles`, - { - body: JSON.stringify({ - message: JSON.stringify({ - msg: "method", - id: null, - method: "getUserRoles", - params: [], - }), - }), - headers: { - "Content-Type": "application/json", - "X-Auth-Token": authToken, - "X-User-Id": userId, - }, - method: "POST", - } - ); - - const result = await response.json(); - - if (result.success && result.message) { - const parsedMessage = JSON.parse(result.message); - return parsedMessage; - } - return null; - } catch (err) { - console.error(err); - } - } - async sendTypingStatus(username: string, typing: boolean) { try { this.rcClient.methodCall( diff --git a/packages/react/src/hooks/useFetchChatData.js b/packages/react/src/hooks/useFetchChatData.js index 2078fdf05d..3f52d126ae 100644 --- a/packages/react/src/hooks/useFetchChatData.js +++ b/packages/react/src/hooks/useFetchChatData.js @@ -148,8 +148,8 @@ const useFetchChatData = (showRoles) => { if (showRoles) { const { roles } = await RCInstance.getChannelRoles(isChannelPrivate); - const fetchedRoles = await RCInstance.getUserRoles(); - const fetchedAdmins = fetchedRoles?.result; + const fetchedRoles = await RCInstance.getUsersInRole('admin'); + const fetchedAdmins = fetchedRoles?.users; const adminUsernames = fetchedAdmins?.map((user) => user.username); setAdmins(adminUsernames); diff --git a/packages/react/src/views/ChatHeader/ChatHeader.js b/packages/react/src/views/ChatHeader/ChatHeader.js index 0986104ae5..a27cb38796 100644 --- a/packages/react/src/views/ChatHeader/ChatHeader.js +++ b/packages/react/src/views/ChatHeader/ChatHeader.js @@ -198,8 +198,7 @@ const ChatHeader = ({ ) { setIsChannelArchived(true); const roomInfo = await RCInstance.getRoomInfo(); - const roomData = roomInfo.result[roomInfo.result.length - 1]; - setChannelInfo(roomData); + setChannelInfo(roomInfo?.room); } else if ('errorType' in res && res.errorType === 'Not Allowed') { dispatchToastMessage({ type: 'error',