diff --git a/server/plugins/com.msgbyte.welcome/services/welcome.service.ts b/server/plugins/com.msgbyte.welcome/services/welcome.service.ts index 1426d39b..9efc22fb 100644 --- a/server/plugins/com.msgbyte.welcome/services/welcome.service.ts +++ b/server/plugins/com.msgbyte.welcome/services/welcome.service.ts @@ -12,7 +12,7 @@ class WelcomeService extends TcService { } onInit() { - this.registryAfterActionHook('group.joinGroup', 'joinGroupCallback'); // not work + this.registryAfterActionHook('group.joinGroup', 'joinGroupCallback'); this.registerAction('joinGroupCallback', this.joinGroupCallback, { params: { diff --git a/server/services/core/group/group.service.ts b/server/services/core/group/group.service.ts index b2f91d1e..3c4bc07f 100644 --- a/server/services/core/group/group.service.ts +++ b/server/services/core/group/group.service.ts @@ -84,6 +84,13 @@ class GroupService extends TcService { groupId: 'string', }, }); + this.registerAction('addMember', this.addMember, { + params: { + groupId: 'string', + userId: 'string', + }, + visibility: 'public', + }); this.registerAction('joinGroup', this.joinGroup, { params: { groupId: 'string', @@ -493,15 +500,15 @@ class GroupService extends TcService { } /** - * 加入群组 + * 群组添加成员 */ - async joinGroup( + async addMember( ctx: TcContext<{ groupId: string; + userId: string; }> ) { - const groupId = ctx.params.groupId; - const userId = ctx.meta.userId; + const { groupId, userId } = ctx.params; if (!isValidStr(userId)) { throw new EntityError('用户id为空'); @@ -550,6 +557,24 @@ class GroupService extends TcService { return group; } + /** + * 加入群组 + * @deprecated 请尽量使用 addMember + */ + async joinGroup( + ctx: TcContext<{ + groupId: string; + }> + ) { + const groupId = ctx.params.groupId; + const userId = ctx.meta.userId; + + return this.localCall('addMember', { + groupId, + userId, + }); + } + /** * 退出群组 */