From 1de91d21ab999e6cb4619148d08e8ca83599ff7d Mon Sep 17 00:00:00 2001 From: NickWang Date: Fri, 29 Jul 2022 12:20:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20batch=20roomDel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/puppet-service.ts | 13 ++++++++++--- src/server/puppet-implementation.ts | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/client/puppet-service.ts b/src/client/puppet-service.ts index 8d2bcce9..1afaa37d 100644 --- a/src/client/puppet-service.ts +++ b/src/client/puppet-service.ts @@ -1333,13 +1333,20 @@ class PuppetService extends PUPPET.Puppet { override async roomDel ( roomId : string, - contactId : string, + contactIds : string | string[], ): Promise { - log.verbose('PuppetService', 'roomDel(%s, %s)', roomId, contactId) + log.verbose('PuppetService', 'roomDel(%s, %s)', roomId, contactIds) const request = new grpcPuppet.RoomDelRequest() request.setId(roomId) - request.setContactId(contactId) + if (Array.isArray(contactIds)) { + request.setContactIdsList(contactIds) + if (contactIds.length === 1) { + request.setContactId(contactIds[0] as string) + } + } else { + request.setId(contactIds) + } await util.promisify( this.grpcManager.client.roomDel diff --git a/src/server/puppet-implementation.ts b/src/server/puppet-implementation.ts index 02f7312a..772070c3 100644 --- a/src/server/puppet-implementation.ts +++ b/src/server/puppet-implementation.ts @@ -1108,8 +1108,13 @@ function puppetImplementation ( try { const roomId = call.request.getId() const contactId = call.request.getContactId() + const contactIds = call.request.getContactIdsList() - await puppet.roomDel(roomId, contactId) + if (contactIds && contactIds.length > 1) { + await puppet.roomDel(roomId, contactId) + } else { + await puppet.roomDel(roomId, contactId || (contactIds && contactIds[0]) || '') + } return callback(null, new grpcPuppet.RoomDelResponse()) From 8c78262c42e12ef38c5b70eea2c91bee65a6ee6f Mon Sep 17 00:00:00 2001 From: NickWang Date: Wed, 26 Apr 2023 16:56:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20batch=20roomAdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/puppet-service.ts | 13 ++++++++++--- src/server/puppet-implementation.ts | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/client/puppet-service.ts b/src/client/puppet-service.ts index 1afaa37d..54caa7e6 100644 --- a/src/client/puppet-service.ts +++ b/src/client/puppet-service.ts @@ -1371,14 +1371,21 @@ class PuppetService extends PUPPET.Puppet { override async roomAdd ( roomId : string, - contactId : string, + contactIds : string | string[], inviteOnly : boolean, ): Promise { - log.verbose('PuppetService', 'roomAdd(%s, %s)', roomId, contactId) + log.verbose('PuppetService', 'roomAdd(%s, %s)', roomId, contactIds) const request = new grpcPuppet.RoomAddRequest() request.setId(roomId) - request.setContactId(contactId) + if (Array.isArray(contactIds)) { + request.setContactIds(contactIds) + if (contactIds.length === 1) { + request.setContactId(contactIds[0] as string) + } + } else { + request.setContactId(contactId) + } request.setInviteOnly(inviteOnly) await util.promisify( diff --git a/src/server/puppet-implementation.ts b/src/server/puppet-implementation.ts index 772070c3..4fb58bad 100644 --- a/src/server/puppet-implementation.ts +++ b/src/server/puppet-implementation.ts @@ -1024,9 +1024,14 @@ function puppetImplementation ( try { const roomId = call.request.getId() const contactId = call.request.getContactId() + const contactIds = call.request.getContactIdsList() const inviteOnly = call.request.getInviteOnly() - await puppet.roomAdd(roomId, contactId, inviteOnly) + if (contactIds && contactIds.length > 1) { + await puppet.roomAdd(roomId, contactId, inviteOnly) + } else { + await puppet.roomAdd(roomId, contactId || (contactIds && contactIds[0]) || '', inviteOnly) + } return callback(null, new grpcPuppet.RoomAddResponse())