From 71b184d38ab686645093f8e54e577837ca2dc4e9 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 2 Mar 2022 13:06:30 -0400 Subject: [PATCH 1/2] Chore: Migrate REST API - markAsUnread to TS (#3801) * Migrate `subscriptions.unread` to typescript --- app/definitions/rest/v1/index.ts | 4 +++- app/definitions/rest/v1/subscriptions.ts | 5 +++++ app/lib/rocketchat/services/restApi.ts | 4 +--- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 app/definitions/rest/v1/subscriptions.ts diff --git a/app/definitions/rest/v1/index.ts b/app/definitions/rest/v1/index.ts index 83bb410d0..e292cb99b 100644 --- a/app/definitions/rest/v1/index.ts +++ b/app/definitions/rest/v1/index.ts @@ -15,6 +15,7 @@ import { UserEndpoints } from './user'; import { UsersEndpoints } from './users'; import { TeamsEndpoints } from './teams'; import { E2eEndpoints } from './e2e'; +import { SubscriptionsEndpoints } from './subscriptions'; export type Endpoints = ChannelsEndpoints & ChatEndpoints & @@ -32,4 +33,5 @@ export type Endpoints = ChannelsEndpoints & UserEndpoints & UsersEndpoints & TeamsEndpoints & - E2eEndpoints; + E2eEndpoints & + SubscriptionsEndpoints; diff --git a/app/definitions/rest/v1/subscriptions.ts b/app/definitions/rest/v1/subscriptions.ts new file mode 100644 index 000000000..c05e25cf2 --- /dev/null +++ b/app/definitions/rest/v1/subscriptions.ts @@ -0,0 +1,5 @@ +export type SubscriptionsEndpoints = { + 'subscriptions.unread': { + POST: (params: { firstUnreadMessage: { _id: string } }) => {}; + }; +}; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 2f1bf4a5c..83c061150 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -264,10 +264,8 @@ export const deleteMessage = (messageId: string, rid: string): any => // @ts-ignore sdk.post('chat.delete', { msgId: messageId, roomId: rid }); -export const markAsUnread = ({ messageId }: { messageId: string }): any => +export const markAsUnread = ({ messageId }: { messageId: string }) => // RC 0.65.0 - // TODO: missing definitions from server - // @ts-ignore sdk.post('subscriptions.unread', { firstUnreadMessage: { _id: messageId } }); export const toggleStarMessage = (messageId: string, starred: boolean): any => { From c5023eaeea284b07b61abd418e0d198f6a0c055e Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 2 Mar 2022 13:44:42 -0400 Subject: [PATCH 2/2] Chore: Migrate REST API - convertChannelToTeam to TS (#3792) * migrate channels.convertToTeam and groups.convertToTeam to ts Co-authored-by: Gleidson Daniel Silva --- app/definitions/rest/v1/channels.ts | 4 ++++ app/definitions/rest/v1/groups.ts | 4 ++++ app/lib/rocketchat/services/restApi.ts | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/definitions/rest/v1/channels.ts b/app/definitions/rest/v1/channels.ts index e507d970e..d5270e0bc 100644 --- a/app/definitions/rest/v1/channels.ts +++ b/app/definitions/rest/v1/channels.ts @@ -1,3 +1,4 @@ +import { ITeam } from '../../ITeam'; import type { IMessage, IMessageFromServer } from '../../IMessage'; import type { IRoom } from '../../IRoom'; import type { IUser } from '../../IUser'; @@ -28,4 +29,7 @@ export type ChannelsEndpoints = { messages: IMessageFromServer[]; }; }; + 'channels.convertToTeam': { + POST: (params: { channelId: string; channelName: string }) => { team: ITeam }; + }; }; diff --git a/app/definitions/rest/v1/groups.ts b/app/definitions/rest/v1/groups.ts index 8518fcd05..d858d79d5 100644 --- a/app/definitions/rest/v1/groups.ts +++ b/app/definitions/rest/v1/groups.ts @@ -1,3 +1,4 @@ +import { ITeam } from '../../ITeam'; import type { IMessage, IMessageFromServer } from '../../IMessage'; import type { IRoom } from '../../IRoom'; import type { IUser } from '../../IUser'; @@ -22,4 +23,7 @@ export type GroupsEndpoints = { messages: IMessageFromServer[]; }; }; + 'groups.convertToTeam': { + POST: (params: { roomId: string; roomName: string }) => { team: ITeam }; + }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 83c061150..fa2fb91b8 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -220,7 +220,7 @@ export const teamListRoomsOfUser = ({ teamId, userId }: { teamId: string; userId // @ts-ignore sdk.get('teams.listRoomsOfUser', { teamId, userId }); -export const convertChannelToTeam = ({ rid, name, type }: { rid: string; name: string; type: 'c' | 'p' }): any => { +export const convertChannelToTeam = ({ rid, name, type }: { rid: string; name: string; type: 'c' | 'p' }) => { const params = { ...(type === 'c' ? { @@ -232,8 +232,6 @@ export const convertChannelToTeam = ({ rid, name, type }: { rid: string; name: s roomName: name }) }; - // TODO: missing definitions from server - // @ts-ignore return sdk.post(type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam', params); };