From 9a22c995e6b4c8ae5481a5327add6f6ca975b087 Mon Sep 17 00:00:00 2001 From: Maiko Tan Date: Fri, 22 Dec 2023 22:48:43 +0800 Subject: [PATCH 1/2] feat(lark): add more api, correct function name This commit add APIs for "forwarding messages" and "merging and forwarding messages", also changing the original `getUserInfo` function to the consist one `getContactUser` Fix #207 --- adapters/lark/src/bot.ts | 2 +- adapters/lark/src/types/message/index.ts | 17 +++++++++++++++++ adapters/lark/src/types/user.ts | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/adapters/lark/src/bot.ts b/adapters/lark/src/bot.ts index d80579ac..e9431ae7 100644 --- a/adapters/lark/src/bot.ts +++ b/adapters/lark/src/bot.ts @@ -87,7 +87,7 @@ export class LarkBot extends Bot } async getUser(userId: string, guildId?: string) { - const data = await this.internal.getUserInfo(userId) + const data = await this.internal.getContactUser(userId) return Utils.decodeUser(data.data) } diff --git a/adapters/lark/src/types/message/index.ts b/adapters/lark/src/types/message/index.ts index 08c8a23e..c6848893 100644 --- a/adapters/lark/src/types/message/index.ts +++ b/adapters/lark/src/types/message/index.ts @@ -205,6 +205,17 @@ declare module '../internal' { getMessage(message_id: string): Promise /** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/delete */ deleteMessage(message_id: string): Promise + /** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/forward */ + forwardMessage( + message_id: string, + receive_id_type: Lark.ReceiveIdType, + data: { receive_id: string }, + ): Promise + /** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/merge_forward */ + mergeForwardMessage( + receive_id_type: Lark.ReceiveIdType, + data: { receive_id: string, message_id_list: string[] }, + ): Promise /** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/read_users */ getMessageReadUsers(message_id: string, params: Pagination<{ user_id_type: Lark.UserIdType }>): Promise }> /** @see https://open.larksuite.com/document/server-docs/im-v1/message/list */ @@ -230,4 +241,10 @@ Internal.define({ '/im/v1/messages/{message_id}/read_users': { GET: 'getMessageReadUsers', }, + '/im/v1/messages/{message_id}/forward?receive_id_type={receive_id_type}': { + POST: 'forwardMessage', + }, + '/im/v1/messages/merge_forward?receive_id_type={receive_id_type}': { + POST: 'mergeForwardMessage', + }, }) diff --git a/adapters/lark/src/types/user.ts b/adapters/lark/src/types/user.ts index f6a46e3f..915c1c93 100644 --- a/adapters/lark/src/types/user.ts +++ b/adapters/lark/src/types/user.ts @@ -80,12 +80,12 @@ export interface GuildMember { declare module './internal' { export interface Internal { /** @see https://open.larksuite.com/document/server-docs/contact-v3/user/get */ - getUserInfo(user_id: string, user_id_type?: Lark.UserIdType, department_id_type?: Lark.DepartmentIdType): Promise + getContactUser(user_id: string, user_id_type?: Lark.UserIdType, department_id_type?: Lark.DepartmentIdType): Promise } } Internal.define({ 'contact/v3/users/{user_id}': { - GET: 'getUserInfo', + GET: 'getContactUser', }, }) From 413b031af79752f1d51c33f34481dc48a20c8b5f Mon Sep 17 00:00:00 2001 From: Maiko Sinkyaet Tan Date: Sat, 23 Dec 2023 08:55:51 +0800 Subject: [PATCH 2/2] Apply suggestions from code review --- adapters/lark/src/types/message/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapters/lark/src/types/message/index.ts b/adapters/lark/src/types/message/index.ts index c6848893..47d841fe 100644 --- a/adapters/lark/src/types/message/index.ts +++ b/adapters/lark/src/types/message/index.ts @@ -214,8 +214,8 @@ declare module '../internal' { /** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/merge_forward */ mergeForwardMessage( receive_id_type: Lark.ReceiveIdType, - data: { receive_id: string, message_id_list: string[] }, - ): Promise + data: { receive_id: string; message_id_list: string[] }, + ): Promise /** @see https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/read_users */ getMessageReadUsers(message_id: string, params: Pagination<{ user_id_type: Lark.UserIdType }>): Promise }> /** @see https://open.larksuite.com/document/server-docs/im-v1/message/list */