@juzi/wechaty-puppet-service 1.0.123 → 1.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/client/grpc-manager.d.ts +1 -0
- package/dist/cjs/src/client/grpc-manager.d.ts.map +1 -1
- package/dist/cjs/src/client/grpc-manager.js +49 -47
- package/dist/cjs/src/client/grpc-manager.js.map +1 -1
- package/dist/cjs/src/client/payload-store.d.ts +3 -0
- package/dist/cjs/src/client/payload-store.d.ts.map +1 -1
- package/dist/cjs/src/client/payload-store.js +8 -6
- package/dist/cjs/src/client/payload-store.js.map +1 -1
- package/dist/cjs/src/client/puppet-service.d.ts.map +1 -1
- package/dist/cjs/src/client/puppet-service.js +221 -216
- package/dist/cjs/src/client/puppet-service.js.map +1 -1
- package/dist/cjs/src/package-json.d.ts.map +1 -1
- package/dist/cjs/src/package-json.js +4 -3
- package/dist/cjs/src/package-json.js.map +1 -1
- package/dist/esm/src/client/grpc-manager.d.ts +1 -0
- package/dist/esm/src/client/grpc-manager.d.ts.map +1 -1
- package/dist/esm/src/client/grpc-manager.js +50 -48
- package/dist/esm/src/client/grpc-manager.js.map +1 -1
- package/dist/esm/src/client/payload-store.d.ts +3 -0
- package/dist/esm/src/client/payload-store.d.ts.map +1 -1
- package/dist/esm/src/client/payload-store.js +8 -6
- package/dist/esm/src/client/payload-store.js.map +1 -1
- package/dist/esm/src/client/puppet-service.d.ts.map +1 -1
- package/dist/esm/src/client/puppet-service.js +221 -216
- package/dist/esm/src/client/puppet-service.js.map +1 -1
- package/dist/esm/src/package-json.d.ts.map +1 -1
- package/dist/esm/src/package-json.js +4 -3
- package/dist/esm/src/package-json.js.map +1 -1
- package/package.json +4 -3
- package/src/client/grpc-manager.ts +54 -48
- package/src/client/payload-store.ts +13 -7
- package/src/client/puppet-service.ts +222 -217
- package/src/package-json.ts +4 -3
|
@@ -110,6 +110,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
110
110
|
this.options = options;
|
|
111
111
|
this._payloadStore = new payload_store_js_1.PayloadStore({
|
|
112
112
|
token: config_js_1.envVars.WECHATY_PUPPET_SERVICE_TOKEN(this.options.token),
|
|
113
|
+
logger: this.options.logger,
|
|
113
114
|
});
|
|
114
115
|
this.hookPayloadStore();
|
|
115
116
|
this.FileBoxUuid = (0, mod_js_1.uuidifyFileBoxGrpc)(() => this.grpcManager.client);
|
|
@@ -139,77 +140,77 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
139
140
|
return package_json_js_1.packageJson.version || '0.0.0';
|
|
140
141
|
}
|
|
141
142
|
async onStart() {
|
|
142
|
-
|
|
143
|
+
this.log.verbose('PuppetService', 'onStart()');
|
|
143
144
|
this.waitingForLogin = false;
|
|
144
145
|
this.waitingForReady = false;
|
|
145
146
|
if (this._grpcManager) {
|
|
146
|
-
|
|
147
|
+
this.log.warn('PuppetService', 'onStart() found this.grpc is already existed. dropped.');
|
|
147
148
|
this._grpcManager = undefined;
|
|
148
149
|
}
|
|
149
|
-
|
|
150
|
+
this.log.info('PuppetService', 'start() instanciating GrpcManager ...');
|
|
150
151
|
const grpcManager = new grpc_manager_js_1.GrpcManager(this.options);
|
|
151
|
-
|
|
152
|
+
this.log.info('PuppetService', 'start() instanciating GrpcManager ... done');
|
|
152
153
|
/**
|
|
153
154
|
* Huan(202108): when we started the event stream,
|
|
154
155
|
* the `this.grpc` need to be available for all listeners.
|
|
155
156
|
*/
|
|
156
157
|
this._grpcManager = grpcManager;
|
|
157
|
-
|
|
158
|
+
this.log.info('PuppetService', 'start() setting up bridge grpc event stream ...');
|
|
158
159
|
this.bridgeGrpcEventStream(grpcManager);
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
this.log.info('PuppetService', 'start() setting up bridge grpc event stream ... done');
|
|
161
|
+
this.log.info('PuppetService', 'start() starting grpc manager...');
|
|
161
162
|
const { lastEventSeq, accountId } = await this.getMiscellaneousStoreData();
|
|
162
163
|
await grpcManager.start(lastEventSeq, accountId);
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
this.log.info('PuppetService', 'start() starting grpc manager... done');
|
|
165
|
+
this.log.info('PuppetService', 'start healthCheck');
|
|
165
166
|
this.startHealthCheck();
|
|
166
|
-
|
|
167
|
+
this.log.info('PuppetService', 'onStart() ... done');
|
|
167
168
|
}
|
|
168
169
|
async onStop() {
|
|
169
|
-
|
|
170
|
+
this.log.info('PuppetService', 'onStop()');
|
|
170
171
|
if (this._grpcManager) {
|
|
171
|
-
|
|
172
|
+
this.log.info('PuppetService', 'onStop() stopping grpc manager ...');
|
|
172
173
|
const grpcManager = this._grpcManager;
|
|
173
174
|
this._grpcManager = undefined;
|
|
174
175
|
await grpcManager.stop();
|
|
175
|
-
|
|
176
|
+
this.log.info('PuppetService', 'onStop() stopping grpc manager ... done');
|
|
176
177
|
}
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
this.log.info('PuppetService', 'onStop() ... done');
|
|
179
|
+
this.log.info('PuppetService', 'stop healthCheck');
|
|
179
180
|
this.stopHealthCheck();
|
|
180
181
|
}
|
|
181
182
|
hookPayloadStore() {
|
|
182
|
-
|
|
183
|
+
this.log.verbose('PuppetService', 'hookPayloadStore()');
|
|
183
184
|
this.on('login', async ({ contactId }) => {
|
|
184
185
|
try {
|
|
185
|
-
|
|
186
|
+
this.log.verbose('PuppetService', 'hookPayloadStore() this.on(login) contactId: "%s"', contactId);
|
|
186
187
|
await this._payloadStore.start(contactId);
|
|
187
188
|
}
|
|
188
189
|
catch (e) {
|
|
189
|
-
|
|
190
|
+
this.log.verbose('PuppetService', 'hookPayloadStore() this.on(login) rejection "%s"', e.message);
|
|
190
191
|
}
|
|
191
192
|
});
|
|
192
193
|
this.on('logout', async ({ contactId }) => {
|
|
193
|
-
|
|
194
|
+
this.log.verbose('PuppetService', 'hookPayloadStore() this.on(logout) contactId: "%s"', contactId);
|
|
194
195
|
try {
|
|
195
196
|
await this._payloadStore.stop();
|
|
196
197
|
}
|
|
197
198
|
catch (e) {
|
|
198
|
-
|
|
199
|
+
this.log.verbose('PuppetService', 'hookPayloadStore() this.on(logout) rejection "%s"', e.message);
|
|
199
200
|
}
|
|
200
201
|
});
|
|
201
202
|
}
|
|
202
203
|
bridgeGrpcEventStream(client) {
|
|
203
|
-
|
|
204
|
+
this.log.verbose('PuppetService', 'bridgeGrpcEventStream(client)');
|
|
204
205
|
client
|
|
205
206
|
.on('data', this.onGrpcStreamEvent.bind(this))
|
|
206
207
|
.on('end', () => {
|
|
207
|
-
|
|
208
|
+
this.log.verbose('PuppetService', 'bridgeGrpcEventStream() eventStream.on(end)');
|
|
208
209
|
})
|
|
209
210
|
.on('error', (e) => {
|
|
210
211
|
this.emit('error', e);
|
|
211
212
|
// https://github.com/wechaty/wechaty-puppet-service/issues/16
|
|
212
|
-
// log.verbose('PuppetService', 'bridgeGrpcEventStream() eventStream.on(error) %s', e)
|
|
213
|
+
// this.log.verbose('PuppetService', 'bridgeGrpcEventStream() eventStream.on(error) %s', e)
|
|
213
214
|
// const reason = 'bridgeGrpcEventStream() eventStream.on(error) ' + e
|
|
214
215
|
/**
|
|
215
216
|
* Huan(202110): simple reset puppet when grpc client has error? (or not?)
|
|
@@ -224,7 +225,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
224
225
|
// }
|
|
225
226
|
})
|
|
226
227
|
.on('cancel', (...args) => {
|
|
227
|
-
|
|
228
|
+
this.log.verbose('PuppetService', 'bridgeGrpcEventStream() eventStream.on(cancel), %s', JSON.stringify(args));
|
|
228
229
|
});
|
|
229
230
|
}
|
|
230
231
|
async onGrpcStreamEvent(event) {
|
|
@@ -233,9 +234,9 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
233
234
|
const seq = event.getSeq();
|
|
234
235
|
const timestamp = String(Date.now());
|
|
235
236
|
if (!config_js_1.NO_LOG_EVENTS.includes(type)) {
|
|
236
|
-
|
|
237
|
+
this.log.info('PuppetService', `received grpc event ${event_type_rev_js_1.EventTypeRev[type]} on ${new Date().toString()}, content: ${JSON.stringify(payload)}, seq: ${seq}, timestamp: ${timestamp}`);
|
|
237
238
|
}
|
|
238
|
-
|
|
239
|
+
this.log.silly('PuppetService', 'onGrpcStreamEvent({type:%s(%s), payload:"%s"})', event_type_rev_js_1.EventTypeRev[type], type, payload);
|
|
239
240
|
if (type !== wechaty_grpc_1.puppet.EventType.EVENT_TYPE_HEARTBEAT) {
|
|
240
241
|
this.emit('heartbeat', {
|
|
241
242
|
data: `onGrpcStreamEvent(${event_type_rev_js_1.EventTypeRev[type]})`,
|
|
@@ -266,7 +267,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
266
267
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_LOGIN:
|
|
267
268
|
{
|
|
268
269
|
if (this.waitingForLogin && this.isLoggedIn) {
|
|
269
|
-
|
|
270
|
+
this.log.warn('PuppetService', 'this login event is ignored because the it is expected by event stream reconnect and this puppet is already logged in');
|
|
270
271
|
return;
|
|
271
272
|
}
|
|
272
273
|
const loginPayload = JSON.parse(payload);
|
|
@@ -279,7 +280,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
}
|
|
282
|
-
(async () => this.login(loginPayload.contactId))().catch(e =>
|
|
283
|
+
(async () => this.login(loginPayload.contactId))().catch(e => this.log.error('PuppetService', 'onGrpcStreamEvent() this.login() rejection %s', e.message));
|
|
283
284
|
}
|
|
284
285
|
break;
|
|
285
286
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_LOGOUT:
|
|
@@ -289,7 +290,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
289
290
|
await this.resetMiscellaneousStoreData();
|
|
290
291
|
}
|
|
291
292
|
;
|
|
292
|
-
(async () => this.logout(logoutPayload.data))().catch(e =>
|
|
293
|
+
(async () => this.logout(logoutPayload.data))().catch(e => this.log.error('PuppetService', 'onGrpcStreamEvent() this.logout() rejection %s', e.message));
|
|
293
294
|
}
|
|
294
295
|
break;
|
|
295
296
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_DIRTY: {
|
|
@@ -312,7 +313,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
312
313
|
break;
|
|
313
314
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_READY:
|
|
314
315
|
if (this.waitingForReady && this.readyIndicator.value()) {
|
|
315
|
-
|
|
316
|
+
this.log.warn('PuppetService', 'this ready event is ignored because the it is expected by event stream reconnect and this puppet is already ready');
|
|
316
317
|
return;
|
|
317
318
|
}
|
|
318
319
|
this.emit('ready', JSON.parse(payload));
|
|
@@ -342,14 +343,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
342
343
|
this.emit('tag-group', JSON.parse(payload));
|
|
343
344
|
break;
|
|
344
345
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_RESET:
|
|
345
|
-
|
|
346
|
+
this.log.warn('PuppetService', 'onGrpcStreamEvent() got an EventType.EVENT_TYPE_RESET ?');
|
|
346
347
|
// the `reset` event should be dealed not send out
|
|
347
348
|
break;
|
|
348
349
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_VERIFY_CODE:
|
|
349
350
|
this.emit('verify-code', JSON.parse(payload));
|
|
350
351
|
break;
|
|
351
352
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_UNSPECIFIED:
|
|
352
|
-
|
|
353
|
+
this.log.error('PuppetService', 'onGrpcStreamEvent() got an EventType.EVENT_TYPE_UNSPECIFIED ?');
|
|
353
354
|
break;
|
|
354
355
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_VERIFY_SLIDE:
|
|
355
356
|
this.emit('verify-slide', JSON.parse(payload));
|
|
@@ -359,27 +360,27 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
359
360
|
break;
|
|
360
361
|
default:
|
|
361
362
|
// Huan(202003): in default, the `type` type should be `never`, please check.
|
|
362
|
-
|
|
363
|
+
this.log.error(`eventType ${type} unsupported! data: ${payload}`);
|
|
363
364
|
}
|
|
364
365
|
}
|
|
365
366
|
async logout(reason) {
|
|
366
|
-
|
|
367
|
+
this.log.verbose('PuppetService', 'logout(%s)', reason ? `"${reason}"` : '');
|
|
367
368
|
await super.logout(reason);
|
|
368
369
|
try {
|
|
369
370
|
await util_1.default.promisify(this.grpcManager.client.logout
|
|
370
371
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.LogoutRequest());
|
|
371
372
|
}
|
|
372
373
|
catch (e) {
|
|
373
|
-
|
|
374
|
+
this.log.silly('PuppetService', 'logout() no grpc client');
|
|
374
375
|
}
|
|
375
376
|
}
|
|
376
377
|
ding(data) {
|
|
377
|
-
|
|
378
|
+
this.log.silly('PuppetService', 'ding(%s)', data);
|
|
378
379
|
const request = new wechaty_grpc_1.puppet.DingRequest();
|
|
379
380
|
request.setData(data || '');
|
|
380
381
|
this.grpcManager.client.ding(request, (error, _response) => {
|
|
381
382
|
if (error) {
|
|
382
|
-
|
|
383
|
+
this.log.error('PuppetService', 'ding() rejection: %s', error);
|
|
383
384
|
}
|
|
384
385
|
});
|
|
385
386
|
}
|
|
@@ -392,7 +393,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
392
393
|
*
|
|
393
394
|
*/
|
|
394
395
|
async dirtyPayload(type, id) {
|
|
395
|
-
|
|
396
|
+
this.log.verbose('PuppetService', 'dirtyPayload(%s, %s)', type, id);
|
|
396
397
|
const request = new wechaty_grpc_1.puppet.DirtyPayloadRequest();
|
|
397
398
|
request.setId(id);
|
|
398
399
|
request.setType(type);
|
|
@@ -401,7 +402,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
401
402
|
.bind(this.grpcManager.client))(request);
|
|
402
403
|
}
|
|
403
404
|
catch (e) {
|
|
404
|
-
|
|
405
|
+
this.log.error('PuppetService', 'dirtyPayload() rejection: %s', e && e.message);
|
|
405
406
|
throw e;
|
|
406
407
|
}
|
|
407
408
|
}
|
|
@@ -483,7 +484,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
483
484
|
[PUPPET.types.Dirty.Call]: async (_) => { },
|
|
484
485
|
[PUPPET.types.Dirty.Unspecified]: async (id) => {
|
|
485
486
|
const msg = `fastDirty() received Unspecified dirty type (id=${id}); upstream puppet is leaking protobuf default — this is a server-side contract bug`;
|
|
486
|
-
|
|
487
|
+
this.log.error('PuppetService', msg);
|
|
487
488
|
this.emit('error', new Error(msg));
|
|
488
489
|
},
|
|
489
490
|
};
|
|
@@ -493,14 +494,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
493
494
|
* the event listener will be registered in `start()` from the `PuppetAbstract` class
|
|
494
495
|
*/
|
|
495
496
|
async fastDirty({ payloadType, payloadId, }) {
|
|
496
|
-
|
|
497
|
+
this.log.verbose('PuppetService', 'fastDirty(%s<%s>, %s)', PUPPET.types.Dirty[payloadType], payloadType, payloadId);
|
|
497
498
|
// payloadType is typed as the enum, but at runtime the server may emit a
|
|
498
499
|
// value outside our enum (forward-compat). Look it up via a
|
|
499
500
|
// possibly-undefined view so the runtime guard stays meaningful.
|
|
500
501
|
const lookup = this._dirtyHandlerMap;
|
|
501
502
|
const handler = lookup[payloadType];
|
|
502
503
|
if (!handler) {
|
|
503
|
-
|
|
504
|
+
this.log.warn('PuppetService', 'fastDirty() no handler for payloadType=%s', payloadType);
|
|
504
505
|
return;
|
|
505
506
|
}
|
|
506
507
|
try {
|
|
@@ -511,7 +512,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
511
512
|
}
|
|
512
513
|
}
|
|
513
514
|
async enterVerifyCode(id, code) {
|
|
514
|
-
|
|
515
|
+
this.log.verbose('PuppetService', 'enterVerifyCode(%s, %s)', id, code);
|
|
515
516
|
const request = new wechaty_grpc_1.puppet.EnterVerifyCodeRequest();
|
|
516
517
|
request.setId(id);
|
|
517
518
|
request.setCode(code);
|
|
@@ -519,20 +520,20 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
519
520
|
.bind(this.grpcManager.client))(request);
|
|
520
521
|
}
|
|
521
522
|
async cancelVerifyCode(id) {
|
|
522
|
-
|
|
523
|
+
this.log.verbose('PuppetService', 'cancelVerifyCode(%s)', id);
|
|
523
524
|
const request = new wechaty_grpc_1.puppet.CancelVerifyCodeRequest();
|
|
524
525
|
request.setId(id);
|
|
525
526
|
await util_1.default.promisify(this.grpcManager.client.cancelVerifyCode
|
|
526
527
|
.bind(this.grpcManager.client))(request);
|
|
527
528
|
}
|
|
528
529
|
async refreshQRCode() {
|
|
529
|
-
|
|
530
|
+
this.log.verbose('PuppetService', 'refreshQRCode(%s)');
|
|
530
531
|
const request = new wechaty_grpc_1.puppet.RefreshQRCodeRequest();
|
|
531
532
|
await util_1.default.promisify(this.grpcManager.client.refreshQRCode
|
|
532
533
|
.bind(this.grpcManager.client))(request);
|
|
533
534
|
}
|
|
534
535
|
async contactAlias(contactId, alias) {
|
|
535
|
-
|
|
536
|
+
this.log.verbose('PuppetService', 'contactAlias(%s, %s)', contactId, alias);
|
|
536
537
|
/**
|
|
537
538
|
* Get alias
|
|
538
539
|
*/
|
|
@@ -570,7 +571,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
570
571
|
.bind(this.grpcManager.client))(request);
|
|
571
572
|
}
|
|
572
573
|
async contactPhone(contactId, phoneList) {
|
|
573
|
-
|
|
574
|
+
this.log.verbose('PuppetService', 'contactPhone(%s, %s)', contactId, phoneList);
|
|
574
575
|
const request = new wechaty_grpc_1.puppet.ContactPhoneRequest();
|
|
575
576
|
request.setContactId(contactId);
|
|
576
577
|
request.setPhonesList(phoneList);
|
|
@@ -578,7 +579,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
578
579
|
.bind(this.grpcManager.client))(request);
|
|
579
580
|
}
|
|
580
581
|
async contactCorporationRemark(contactId, corporationRemark) {
|
|
581
|
-
|
|
582
|
+
this.log.verbose('PuppetService', 'contactCorporationRemark(%s, %s)', contactId, corporationRemark);
|
|
582
583
|
const request = new wechaty_grpc_1.puppet.ContactCorporationRemarkRequest();
|
|
583
584
|
request.setContactId(contactId);
|
|
584
585
|
if (corporationRemark) {
|
|
@@ -596,7 +597,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
596
597
|
.bind(this.grpcManager.client))(request);
|
|
597
598
|
}
|
|
598
599
|
async contactDescription(contactId, description) {
|
|
599
|
-
|
|
600
|
+
this.log.verbose('PuppetService', 'contactDescription(%s, %s)', contactId, description);
|
|
600
601
|
const request = new wechaty_grpc_1.puppet.ContactDescriptionRequest();
|
|
601
602
|
request.setContactId(contactId);
|
|
602
603
|
if (description) {
|
|
@@ -614,13 +615,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
614
615
|
.bind(this.grpcManager.client))(request);
|
|
615
616
|
}
|
|
616
617
|
async contactList() {
|
|
617
|
-
|
|
618
|
+
this.log.verbose('PuppetService', 'contactList()');
|
|
618
619
|
const response = await util_1.default.promisify(this.grpcManager.client.contactList
|
|
619
620
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.ContactListRequest());
|
|
620
621
|
return response.getIdsList();
|
|
621
622
|
}
|
|
622
623
|
async contactAvatar(contactId, fileBox) {
|
|
623
|
-
|
|
624
|
+
this.log.verbose('PuppetService', 'contactAvatar(%s)', contactId);
|
|
624
625
|
/**
|
|
625
626
|
* 1. set
|
|
626
627
|
*/
|
|
@@ -657,10 +658,10 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
657
658
|
return this.FileBoxUuid.fromJSON(jsonText);
|
|
658
659
|
}
|
|
659
660
|
async contactRawPayload(id) {
|
|
660
|
-
|
|
661
|
+
this.log.verbose('PuppetService', 'contactRawPayload(%s)', id);
|
|
661
662
|
const cachedPayload = await this._payloadStore.contact?.get(id);
|
|
662
663
|
if (cachedPayload) {
|
|
663
|
-
|
|
664
|
+
this.log.silly('PuppetService', 'contactRawPayload(%s) cache HIT', id);
|
|
664
665
|
return cachedPayload;
|
|
665
666
|
}
|
|
666
667
|
const request = new wechaty_grpc_1.puppet.ContactPayloadRequest();
|
|
@@ -701,16 +702,16 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
701
702
|
aka: response.getAka(),
|
|
702
703
|
};
|
|
703
704
|
await this._payloadStore.contact?.set(id, payload);
|
|
704
|
-
|
|
705
|
+
this.log.silly('PuppetService', 'contactRawPayload(%s) cache SET', id);
|
|
705
706
|
return payload;
|
|
706
707
|
}
|
|
707
708
|
async contactRawPayloadParser(payload) {
|
|
708
|
-
// log.silly('PuppetService', 'contactRawPayloadParser({id:%s})', payload.id)
|
|
709
|
+
// this.log.silly('PuppetService', 'contactRawPayloadParser({id:%s})', payload.id)
|
|
709
710
|
// passthrough
|
|
710
711
|
return payload;
|
|
711
712
|
}
|
|
712
713
|
async batchContactRawPayload(contactIdList) {
|
|
713
|
-
|
|
714
|
+
this.log.verbose('PuppetService', 'batchContactRawPayload(%s)', contactIdList);
|
|
714
715
|
const result = new Map();
|
|
715
716
|
const contactIdSet = new Set(contactIdList);
|
|
716
717
|
const needGetSet = new Set();
|
|
@@ -738,7 +739,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
738
739
|
}
|
|
739
740
|
}
|
|
740
741
|
catch (e) {
|
|
741
|
-
|
|
742
|
+
this.log.error('PuppetService', 'batchContactRawPayload(%s, %s) error: %s, use one by one method', contactIdList, needGetSet, e);
|
|
742
743
|
for (const contactId of needGetSet) {
|
|
743
744
|
const payload = await this.contactRawPayload(contactId);
|
|
744
745
|
result.set(contactId, payload);
|
|
@@ -748,7 +749,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
748
749
|
return result;
|
|
749
750
|
}
|
|
750
751
|
async contactPayloadModify(contactId, payload) {
|
|
751
|
-
|
|
752
|
+
this.log.verbose('PuppetService', 'contactPayloadModify(%s, %s)', contactId, JSON.stringify(payload));
|
|
752
753
|
const request = new wechaty_grpc_1.puppet.ContactPayloadModifyRequest();
|
|
753
754
|
request.setId(contactId);
|
|
754
755
|
if (payload.id) {
|
|
@@ -818,41 +819,41 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
818
819
|
.bind(this.grpcManager.client))(request);
|
|
819
820
|
}
|
|
820
821
|
async contactSelfName(name) {
|
|
821
|
-
|
|
822
|
+
this.log.verbose('PuppetService', 'contactSelfName(%s)', name);
|
|
822
823
|
const request = new wechaty_grpc_1.puppet.ContactSelfNameRequest();
|
|
823
824
|
request.setName(name);
|
|
824
825
|
await util_1.default.promisify(this.grpcManager.client.contactSelfName
|
|
825
826
|
.bind(this.grpcManager.client))(request);
|
|
826
827
|
}
|
|
827
828
|
async contactSelfRealName(realName) {
|
|
828
|
-
|
|
829
|
+
this.log.verbose('PuppetService', 'contactSelfRealName(%s)', realName);
|
|
829
830
|
const request = new wechaty_grpc_1.puppet.ContactSelfRealNameRequest();
|
|
830
831
|
request.setRealName(realName);
|
|
831
832
|
await util_1.default.promisify(this.grpcManager.client.contactSelfRealName
|
|
832
833
|
.bind(this.grpcManager.client))(request);
|
|
833
834
|
}
|
|
834
835
|
async contactSelfAka(aka) {
|
|
835
|
-
|
|
836
|
+
this.log.verbose('PuppetService', 'contactSelfAka(%s)', aka);
|
|
836
837
|
const request = new wechaty_grpc_1.puppet.ContactSelfAkaRequest();
|
|
837
838
|
request.setAka(aka);
|
|
838
839
|
await util_1.default.promisify(this.grpcManager.client.contactSelfAka
|
|
839
840
|
.bind(this.grpcManager.client))(request);
|
|
840
841
|
}
|
|
841
842
|
async contactSelfQRCode() {
|
|
842
|
-
|
|
843
|
+
this.log.verbose('PuppetService', 'contactSelfQRCode()');
|
|
843
844
|
const response = await util_1.default.promisify(this.grpcManager.client.contactSelfQRCode
|
|
844
845
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.ContactSelfQRCodeRequest());
|
|
845
846
|
return response.getQrcode();
|
|
846
847
|
}
|
|
847
848
|
async contactSelfSignature(signature) {
|
|
848
|
-
|
|
849
|
+
this.log.verbose('PuppetService', 'contactSelfSignature(%s)', signature);
|
|
849
850
|
const request = new wechaty_grpc_1.puppet.ContactSelfSignatureRequest();
|
|
850
851
|
request.setSignature(signature);
|
|
851
852
|
await util_1.default.promisify(this.grpcManager.client.contactSelfSignature
|
|
852
853
|
.bind(this.grpcManager.client))(request);
|
|
853
854
|
}
|
|
854
855
|
async contactSelfRoomAlias(roomId, alias) {
|
|
855
|
-
|
|
856
|
+
this.log.verbose('PuppetService', 'contactSelfRoomAlias(%s, %s)', roomId, alias);
|
|
856
857
|
const request = new wechaty_grpc_1.puppet.ContactSelfRoomAliasRequest();
|
|
857
858
|
request.setRoomId(roomId);
|
|
858
859
|
request.setAlias(alias);
|
|
@@ -860,7 +861,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
860
861
|
.bind(this.grpcManager.client))(request);
|
|
861
862
|
}
|
|
862
863
|
async contactDelete(contactId) {
|
|
863
|
-
|
|
864
|
+
this.log.verbose('PuppetService', 'contactDelete(%s)', contactId);
|
|
864
865
|
const request = new wechaty_grpc_1.puppet.ContactDeleteRequest();
|
|
865
866
|
request.setContactId(contactId);
|
|
866
867
|
await util_1.default.promisify(this.grpcManager.client.contactDelete
|
|
@@ -872,7 +873,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
872
873
|
*
|
|
873
874
|
*/
|
|
874
875
|
async conversationReadMark(conversationId, hasRead = true) {
|
|
875
|
-
|
|
876
|
+
this.log.verbose('PuppetService', 'conversationMarkRead(%s, %s)', conversationId, hasRead);
|
|
876
877
|
const request = new wechaty_grpc_1.puppet.ConversationReadRequest();
|
|
877
878
|
request.setConversationId(conversationId);
|
|
878
879
|
request.setHasRead(hasRead);
|
|
@@ -885,7 +886,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
885
886
|
*
|
|
886
887
|
*/
|
|
887
888
|
async messageMiniProgram(messageId) {
|
|
888
|
-
|
|
889
|
+
this.log.verbose('PuppetService', 'messageMiniProgram(%s)', messageId);
|
|
889
890
|
const request = new wechaty_grpc_1.puppet.MessageMiniProgramRequest();
|
|
890
891
|
request.setId(messageId);
|
|
891
892
|
const response = await util_1.default.promisify(this.grpcManager.client.messageMiniProgram
|
|
@@ -904,7 +905,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
904
905
|
return payload;
|
|
905
906
|
}
|
|
906
907
|
async messageLocation(messageId) {
|
|
907
|
-
|
|
908
|
+
this.log.verbose('PuppetService', 'messageLocation(%s)', messageId);
|
|
908
909
|
const request = new wechaty_grpc_1.puppet.MessageLocationRequest();
|
|
909
910
|
request.setId(messageId);
|
|
910
911
|
const response = await util_1.default.promisify(this.grpcManager.client.messageLocation
|
|
@@ -920,7 +921,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
920
921
|
return payload;
|
|
921
922
|
}
|
|
922
923
|
async messageImage(messageId, imageType) {
|
|
923
|
-
|
|
924
|
+
this.log.verbose('PuppetService', 'messageImage(%s, %s[%s])', messageId, imageType, PUPPET.types.Image[imageType]);
|
|
924
925
|
const request = new wechaty_grpc_1.puppet.MessageImageRequest();
|
|
925
926
|
request.setId(messageId);
|
|
926
927
|
request.setType(imageType);
|
|
@@ -933,7 +934,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
933
934
|
throw new Error(`failed to get image filebox for message ${messageId}`);
|
|
934
935
|
}
|
|
935
936
|
async messageContact(messageId) {
|
|
936
|
-
|
|
937
|
+
this.log.verbose('PuppetService', 'messageContact(%s)', messageId);
|
|
937
938
|
const request = new wechaty_grpc_1.puppet.MessageContactRequest();
|
|
938
939
|
request.setId(messageId);
|
|
939
940
|
const response = await util_1.default.promisify(this.grpcManager.client.messageContact
|
|
@@ -942,7 +943,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
942
943
|
return contactId;
|
|
943
944
|
}
|
|
944
945
|
async messageChannel(messageId) {
|
|
945
|
-
|
|
946
|
+
this.log.verbose('PuppetService', 'messageChannel(%s)', messageId);
|
|
946
947
|
const request = new wechaty_grpc_1.puppet.MessageChannelRequest();
|
|
947
948
|
request.setId(messageId);
|
|
948
949
|
const response = await util_1.default.promisify(this.grpcManager.client.messageChannel
|
|
@@ -951,7 +952,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
951
952
|
return payload;
|
|
952
953
|
}
|
|
953
954
|
async messageChannelCard(messageId) {
|
|
954
|
-
|
|
955
|
+
this.log.verbose('PuppetService', 'messageChannelCard(%s)', messageId);
|
|
955
956
|
const request = new wechaty_grpc_1.puppet.MessageChannelCardRequest();
|
|
956
957
|
request.setId(messageId);
|
|
957
958
|
const response = await util_1.default.promisify(this.grpcManager.client.messageChannelCard
|
|
@@ -960,7 +961,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
960
961
|
return payload;
|
|
961
962
|
}
|
|
962
963
|
async messageCallRecord(messageId) {
|
|
963
|
-
|
|
964
|
+
this.log.verbose('PuppetService', 'messageCallRecord(%s)', messageId);
|
|
964
965
|
const request = new wechaty_grpc_1.puppet.MessageCallRecordRequest();
|
|
965
966
|
request.setId(messageId);
|
|
966
967
|
const response = await util_1.default.promisify(this.grpcManager.client.messageCallRecord
|
|
@@ -969,7 +970,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
969
970
|
return payload;
|
|
970
971
|
}
|
|
971
972
|
async callInvite(contactIds, media) {
|
|
972
|
-
|
|
973
|
+
this.log.verbose('PuppetService', 'callInvite(%s, %s)', contactIds, media);
|
|
973
974
|
const request = new wechaty_grpc_1.puppet.CallInviteRequest();
|
|
974
975
|
request.setContactIdsList(contactIds);
|
|
975
976
|
request.setMedia((0, call_media_mapping_js_1.puppetCallMediaTypeToGrpc)(media));
|
|
@@ -982,20 +983,20 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
982
983
|
return callId;
|
|
983
984
|
}
|
|
984
985
|
async callAdd(callId, contactIds) {
|
|
985
|
-
|
|
986
|
+
this.log.verbose('PuppetService', 'callAdd(%s, %s)', callId, contactIds);
|
|
986
987
|
const request = new wechaty_grpc_1.puppet.CallAddRequest();
|
|
987
988
|
request.setCallId(callId);
|
|
988
989
|
request.setContactIdsList(contactIds);
|
|
989
990
|
await this.grpcUnary(this.grpcManager.client.callAdd, request);
|
|
990
991
|
}
|
|
991
992
|
async callAccept(callId) {
|
|
992
|
-
|
|
993
|
+
this.log.verbose('PuppetService', 'callAccept(%s)', callId);
|
|
993
994
|
const request = new wechaty_grpc_1.puppet.CallAcceptRequest();
|
|
994
995
|
request.setCallId(callId);
|
|
995
996
|
await this.grpcUnary(this.grpcManager.client.callAccept, request);
|
|
996
997
|
}
|
|
997
998
|
async callReject(callId, reason) {
|
|
998
|
-
|
|
999
|
+
this.log.verbose('PuppetService', 'callReject(%s, %s)', callId, reason);
|
|
999
1000
|
const request = new wechaty_grpc_1.puppet.CallRejectRequest();
|
|
1000
1001
|
request.setCallId(callId);
|
|
1001
1002
|
if (reason !== undefined && reason !== '') {
|
|
@@ -1004,13 +1005,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1004
1005
|
await this.grpcUnary(this.grpcManager.client.callReject, request);
|
|
1005
1006
|
}
|
|
1006
1007
|
async callCancel(callId) {
|
|
1007
|
-
|
|
1008
|
+
this.log.verbose('PuppetService', 'callCancel(%s)', callId);
|
|
1008
1009
|
const request = new wechaty_grpc_1.puppet.CallCancelRequest();
|
|
1009
1010
|
request.setCallId(callId);
|
|
1010
1011
|
await this.grpcUnary(this.grpcManager.client.callCancel, request);
|
|
1011
1012
|
}
|
|
1012
1013
|
async callHangup(callId, reason) {
|
|
1013
|
-
|
|
1014
|
+
this.log.verbose('PuppetService', 'callHangup(%s, %s)', callId, reason);
|
|
1014
1015
|
const request = new wechaty_grpc_1.puppet.CallHangupRequest();
|
|
1015
1016
|
request.setCallId(callId);
|
|
1016
1017
|
if (reason !== undefined && reason !== '') {
|
|
@@ -1019,7 +1020,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1019
1020
|
await this.grpcUnary(this.grpcManager.client.callHangup, request);
|
|
1020
1021
|
}
|
|
1021
1022
|
async callMediaEndpoint(callId) {
|
|
1022
|
-
|
|
1023
|
+
this.log.verbose('PuppetService', 'callMediaEndpoint(%s)', callId);
|
|
1023
1024
|
const request = new wechaty_grpc_1.puppet.CallMediaEndpointRequest();
|
|
1024
1025
|
request.setCallId(callId);
|
|
1025
1026
|
const response = await util_1.default.promisify(this.grpcManager.client.callMediaEndpoint
|
|
@@ -1043,7 +1044,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1043
1044
|
return payload;
|
|
1044
1045
|
}
|
|
1045
1046
|
async callRawPayload(callId) {
|
|
1046
|
-
|
|
1047
|
+
this.log.verbose('PuppetService', 'callRawPayload(%s)', callId);
|
|
1047
1048
|
const request = new wechaty_grpc_1.puppet.CallPayloadRequest();
|
|
1048
1049
|
request.setId(callId);
|
|
1049
1050
|
const response = await util_1.default.promisify(this.grpcManager.client.callPayload
|
|
@@ -1051,6 +1052,10 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1051
1052
|
return response.toObject();
|
|
1052
1053
|
}
|
|
1053
1054
|
async callRawPayloadParser(rawPayload) {
|
|
1055
|
+
// Intentionally uses the module-level `log` instead of `this.log`: the
|
|
1056
|
+
// matching unit spec invokes this parser via `prototype.call({}, raw)` and
|
|
1057
|
+
// never binds a real PuppetService instance. Keep this `this`-free so that
|
|
1058
|
+
// contract survives the pluggable-logger migration.
|
|
1054
1059
|
config_js_1.log.verbose('PuppetService', 'callRawPayloadParser({id:%s})', rawPayload.id);
|
|
1055
1060
|
const media = (0, call_media_mapping_js_1.grpcCallTypeToPuppetMedia)(rawPayload.media);
|
|
1056
1061
|
if (media === undefined) {
|
|
@@ -1074,7 +1079,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1074
1079
|
return payload;
|
|
1075
1080
|
}
|
|
1076
1081
|
async messageChatHistory(messageId) {
|
|
1077
|
-
|
|
1082
|
+
this.log.verbose('PuppetService', 'messageChatHistory(%s)', messageId);
|
|
1078
1083
|
const request = new wechaty_grpc_1.puppet.MessageChatHistoryRequest();
|
|
1079
1084
|
request.setId(messageId);
|
|
1080
1085
|
const response = await util_1.default.promisify(this.grpcManager.client.messageChatHistory
|
|
@@ -1083,7 +1088,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1083
1088
|
return payload;
|
|
1084
1089
|
}
|
|
1085
1090
|
async messageSendMiniProgram(conversationId, miniProgramPayload) {
|
|
1086
|
-
|
|
1091
|
+
this.log.verbose('PuppetService', 'messageSendMiniProgram(%s, "%s")', conversationId, JSON.stringify(miniProgramPayload));
|
|
1087
1092
|
const request = new wechaty_grpc_1.puppet.MessageSendMiniProgramRequest();
|
|
1088
1093
|
request.setConversationId(conversationId);
|
|
1089
1094
|
const pbMiniProgramPayload = new wechaty_grpc_1.puppet.MiniProgramPayload();
|
|
@@ -1119,11 +1124,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1119
1124
|
* Deprecated: will be removed after Dec 31, 2022
|
|
1120
1125
|
*/
|
|
1121
1126
|
request.setMiniProgramDeprecated(JSON.stringify(miniProgramPayload));
|
|
1122
|
-
|
|
1127
|
+
this.log.info('PuppetService', `messageSendMiniProgram(${conversationId}, ${miniProgramPayload.description}) about to call grpc`);
|
|
1123
1128
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendMiniProgram
|
|
1124
1129
|
.bind(this.grpcManager.client))(request);
|
|
1125
1130
|
const messageId = response.getId();
|
|
1126
|
-
|
|
1131
|
+
this.log.info('PuppetService', `messageSendMiniProgram(${conversationId}, ${miniProgramPayload.description}) grpc called, messageId: ${messageId}`);
|
|
1127
1132
|
if (messageId) {
|
|
1128
1133
|
return messageId;
|
|
1129
1134
|
}
|
|
@@ -1138,7 +1143,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1138
1143
|
}
|
|
1139
1144
|
}
|
|
1140
1145
|
async messageSendLocation(conversationId, locationPayload) {
|
|
1141
|
-
|
|
1146
|
+
this.log.verbose('PuppetService', 'messageSendLocation(%s)', conversationId, JSON.stringify(locationPayload));
|
|
1142
1147
|
const request = new wechaty_grpc_1.puppet.MessageSendLocationRequest();
|
|
1143
1148
|
request.setConversationId(conversationId);
|
|
1144
1149
|
const pbLocationPayload = new wechaty_grpc_1.puppet.LocationPayload();
|
|
@@ -1148,47 +1153,47 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1148
1153
|
pbLocationPayload.setLongitude(locationPayload.longitude);
|
|
1149
1154
|
pbLocationPayload.setName(locationPayload.name);
|
|
1150
1155
|
request.setLocation(pbLocationPayload);
|
|
1151
|
-
|
|
1156
|
+
this.log.info('PuppetService', `messageSendLocation(${conversationId}, ${locationPayload.name}) about to call grpc`);
|
|
1152
1157
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendLocation
|
|
1153
1158
|
.bind(this.grpcManager.client))(request);
|
|
1154
1159
|
const id = response.getId();
|
|
1155
|
-
|
|
1160
|
+
this.log.info('PuppetService', `messageSendMiniProgram(${conversationId}, ${locationPayload.name}) grpc called, messageId: ${id}`);
|
|
1156
1161
|
if (id) {
|
|
1157
1162
|
return id;
|
|
1158
1163
|
}
|
|
1159
1164
|
}
|
|
1160
1165
|
async messageSendChannel(conversationId, channelPayload) {
|
|
1161
|
-
|
|
1166
|
+
this.log.verbose('PuppetService', 'messageSendChannel(%s, "%s")', conversationId, JSON.stringify(channelPayload));
|
|
1162
1167
|
const request = new wechaty_grpc_1.puppet.MessageSendChannelRequest();
|
|
1163
1168
|
request.setConversationId(conversationId);
|
|
1164
1169
|
const pbChannelPayload = (0, pb_payload_helper_js_1.channelPayloadToPb)(wechaty_grpc_1.puppet, channelPayload);
|
|
1165
1170
|
request.setChannel(pbChannelPayload);
|
|
1166
|
-
|
|
1171
|
+
this.log.info('PuppetService', `messageSendChannel(${conversationId}, ${channelPayload.desc}) about to call grpc`);
|
|
1167
1172
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendChannel
|
|
1168
1173
|
.bind(this.grpcManager.client))(request);
|
|
1169
1174
|
const messageId = response.getId();
|
|
1170
|
-
|
|
1175
|
+
this.log.info('PuppetService', `messageSendChannel(${conversationId}, ${channelPayload.desc}) grpc called, messageId: ${messageId}`);
|
|
1171
1176
|
if (messageId) {
|
|
1172
1177
|
return messageId;
|
|
1173
1178
|
}
|
|
1174
1179
|
}
|
|
1175
1180
|
async messageSendChannelCard(conversationId, channelCardPayload) {
|
|
1176
|
-
|
|
1181
|
+
this.log.verbose('PuppetService', 'messageSendChannelCard(%s, "%s")', conversationId, JSON.stringify(channelCardPayload));
|
|
1177
1182
|
const request = new wechaty_grpc_1.puppet.MessageSendChannelCardRequest();
|
|
1178
1183
|
request.setConversationId(conversationId);
|
|
1179
1184
|
const pbChannelCardPayload = (0, pb_payload_helper_js_1.channelCardPayloadToPb)(wechaty_grpc_1.puppet, channelCardPayload);
|
|
1180
1185
|
request.setChannelCard(pbChannelCardPayload);
|
|
1181
|
-
|
|
1186
|
+
this.log.info('PuppetService', `messageSendChannelCard(${conversationId}, ${channelCardPayload.nickname}) about to call grpc`);
|
|
1182
1187
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendChannelCard
|
|
1183
1188
|
.bind(this.grpcManager.client))(request);
|
|
1184
1189
|
const messageId = response.getId();
|
|
1185
|
-
|
|
1190
|
+
this.log.info('PuppetService', `messageSendChannelCard(${conversationId}, ${channelCardPayload.nickname}) grpc called, messageId: ${messageId}`);
|
|
1186
1191
|
if (messageId) {
|
|
1187
1192
|
return messageId;
|
|
1188
1193
|
}
|
|
1189
1194
|
}
|
|
1190
1195
|
async messageRecall(messageId) {
|
|
1191
|
-
|
|
1196
|
+
this.log.verbose('PuppetService', 'messageRecall(%s)', messageId);
|
|
1192
1197
|
const request = new wechaty_grpc_1.puppet.MessageRecallRequest();
|
|
1193
1198
|
request.setId(messageId);
|
|
1194
1199
|
const response = await util_1.default.promisify(this.grpcManager.client.messageRecall
|
|
@@ -1196,7 +1201,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1196
1201
|
return response.getSuccess();
|
|
1197
1202
|
}
|
|
1198
1203
|
async messageFile(id) {
|
|
1199
|
-
|
|
1204
|
+
this.log.verbose('PuppetService', 'messageFile(%s)', id);
|
|
1200
1205
|
const request = new wechaty_grpc_1.puppet.MessageFileRequest();
|
|
1201
1206
|
request.setId(id);
|
|
1202
1207
|
const response = await util_1.default.promisify(this.grpcManager.client.messageFile
|
|
@@ -1208,7 +1213,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1208
1213
|
throw new Error(`failed to get filebox for message ${id}`);
|
|
1209
1214
|
}
|
|
1210
1215
|
async messageVoice(id) {
|
|
1211
|
-
|
|
1216
|
+
this.log.verbose('PuppetService', 'messageVoice(%s)', id);
|
|
1212
1217
|
const request = new wechaty_grpc_1.puppet.MessageVoiceRequest();
|
|
1213
1218
|
request.setId(id);
|
|
1214
1219
|
const response = await util_1.default.promisify(this.grpcManager.client.messageVoice
|
|
@@ -1220,7 +1225,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1220
1225
|
throw new Error(`failed to get voice filebox for message ${id}`);
|
|
1221
1226
|
}
|
|
1222
1227
|
async messageVoiceText(id) {
|
|
1223
|
-
|
|
1228
|
+
this.log.verbose('PuppetService', 'messageVoiceText(%s)', id);
|
|
1224
1229
|
const request = new wechaty_grpc_1.puppet.MessageVoiceTextRequest();
|
|
1225
1230
|
request.setId(id);
|
|
1226
1231
|
const response = await util_1.default.promisify(this.grpcManager.client.messageVoiceText
|
|
@@ -1231,7 +1236,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1231
1236
|
};
|
|
1232
1237
|
}
|
|
1233
1238
|
async messagePreview(id) {
|
|
1234
|
-
|
|
1239
|
+
this.log.verbose('PuppetService', 'messagePreview(%s)', id);
|
|
1235
1240
|
const request = new wechaty_grpc_1.puppet.MessagePreviewRequest();
|
|
1236
1241
|
request.setId(id);
|
|
1237
1242
|
const response = await util_1.default.promisify(this.grpcManager.client.messagePreview
|
|
@@ -1243,7 +1248,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1243
1248
|
return undefined;
|
|
1244
1249
|
}
|
|
1245
1250
|
async messageForward(conversationId, messageIds) {
|
|
1246
|
-
|
|
1251
|
+
this.log.verbose('PuppetService', 'messageForward(%s, %s)', conversationId, messageIds);
|
|
1247
1252
|
const request = new wechaty_grpc_1.puppet.MessageForwardRequest();
|
|
1248
1253
|
request.setConversationId(conversationId);
|
|
1249
1254
|
if (Array.isArray(messageIds)) {
|
|
@@ -1255,11 +1260,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1255
1260
|
else {
|
|
1256
1261
|
request.setMessageId(messageIds);
|
|
1257
1262
|
}
|
|
1258
|
-
|
|
1263
|
+
this.log.info('PuppetService', `messageForward(${conversationId}, ${messageIds}) about to call grpc`);
|
|
1259
1264
|
const response = await util_1.default.promisify(this.grpcManager.client.messageForward
|
|
1260
1265
|
.bind(this.grpcManager.client))(request);
|
|
1261
1266
|
const forwardedMessageId = response.getId();
|
|
1262
|
-
|
|
1267
|
+
this.log.info('PuppetService', `messageForward(${conversationId}, ${messageIds}) grpc called, messageId: ${forwardedMessageId}`);
|
|
1263
1268
|
if (forwardedMessageId) {
|
|
1264
1269
|
return forwardedMessageId;
|
|
1265
1270
|
}
|
|
@@ -1274,10 +1279,10 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1274
1279
|
}
|
|
1275
1280
|
}
|
|
1276
1281
|
async messageRawPayload(id) {
|
|
1277
|
-
|
|
1282
|
+
this.log.verbose('PuppetService', 'messageRawPayload(%s)', id);
|
|
1278
1283
|
// const cachedPayload = await this.payloadStore.message?.get(id)
|
|
1279
1284
|
// if (cachedPayload) {
|
|
1280
|
-
// log.silly('PuppetService', 'messageRawPayload(%s) cache HIT', id)
|
|
1285
|
+
// this.log.silly('PuppetService', 'messageRawPayload(%s) cache HIT', id)
|
|
1281
1286
|
// return cachedPayload
|
|
1282
1287
|
// }
|
|
1283
1288
|
const request = new wechaty_grpc_1.puppet.MessagePayloadRequest();
|
|
@@ -1326,21 +1331,21 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1326
1331
|
break;
|
|
1327
1332
|
}
|
|
1328
1333
|
default:
|
|
1329
|
-
|
|
1334
|
+
this.log.warn('PuppetService', `unknown text content type ${type}`);
|
|
1330
1335
|
}
|
|
1331
1336
|
payload.textContent?.push(contentData);
|
|
1332
1337
|
}
|
|
1333
|
-
// log.silly('PuppetService', 'messageRawPayload(%s) cache SET', id)
|
|
1338
|
+
// this.log.silly('PuppetService', 'messageRawPayload(%s) cache SET', id)
|
|
1334
1339
|
// await this.payloadStore.message?.set(id, payload)
|
|
1335
1340
|
return payload;
|
|
1336
1341
|
}
|
|
1337
1342
|
async messageRawPayloadParser(payload) {
|
|
1338
|
-
// log.silly('PuppetService', 'messagePayload({id:%s})', payload.id)
|
|
1343
|
+
// this.log.silly('PuppetService', 'messagePayload({id:%s})', payload.id)
|
|
1339
1344
|
// passthrough
|
|
1340
1345
|
return payload;
|
|
1341
1346
|
}
|
|
1342
1347
|
async messageSendText(conversationId, text, options) {
|
|
1343
|
-
|
|
1348
|
+
this.log.verbose('PuppetService', 'messageSend(%s, %s)', conversationId, text);
|
|
1344
1349
|
let mentionIdList;
|
|
1345
1350
|
let quoteId;
|
|
1346
1351
|
if (Array.isArray(options)) {
|
|
@@ -1359,11 +1364,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1359
1364
|
if (typeof quoteId !== 'undefined') {
|
|
1360
1365
|
request.setQuoteId(quoteId);
|
|
1361
1366
|
}
|
|
1362
|
-
|
|
1367
|
+
this.log.info('PuppetService', `messageSend(${conversationId}, ${text}) about to call grpc`);
|
|
1363
1368
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendText
|
|
1364
1369
|
.bind(this.grpcManager.client))(request);
|
|
1365
1370
|
const messageId = response.getId();
|
|
1366
|
-
|
|
1371
|
+
this.log.info('PuppetService', `messageSend(${conversationId}, ${text}) grpc called, messageId: ${messageId}`);
|
|
1367
1372
|
if (messageId) {
|
|
1368
1373
|
return messageId;
|
|
1369
1374
|
}
|
|
@@ -1378,7 +1383,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1378
1383
|
}
|
|
1379
1384
|
}
|
|
1380
1385
|
async messageBatchSendText(conversationIds, text, batchTaskId) {
|
|
1381
|
-
|
|
1386
|
+
this.log.verbose('PuppetService', 'messageBatchSendText(%s)', conversationIds.join(','));
|
|
1382
1387
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendTextRequest();
|
|
1383
1388
|
request.setConversationIdsList(conversationIds);
|
|
1384
1389
|
request.setText(text);
|
|
@@ -1389,7 +1394,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1389
1394
|
return grpcBatchResultsToPayload(response);
|
|
1390
1395
|
}
|
|
1391
1396
|
async messageBatchSendFile(conversationIds, fileBox, batchTaskId) {
|
|
1392
|
-
|
|
1397
|
+
this.log.verbose('PuppetService', 'messageBatchSendFile(%s)', conversationIds.join(','));
|
|
1393
1398
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendFileRequest();
|
|
1394
1399
|
request.setConversationIdsList(conversationIds);
|
|
1395
1400
|
request.setFileBox(await this.serializeFileBox(fileBox));
|
|
@@ -1400,7 +1405,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1400
1405
|
return grpcBatchResultsToPayload(response);
|
|
1401
1406
|
}
|
|
1402
1407
|
async messageBatchForward(conversationIds, messageIds, batchTaskId) {
|
|
1403
|
-
|
|
1408
|
+
this.log.verbose('PuppetService', 'messageBatchForward(%s, %s)', conversationIds.join(','), messageIds);
|
|
1404
1409
|
const request = new wechaty_grpc_1.puppet.MessageBatchForwardRequest();
|
|
1405
1410
|
request.setConversationIdsList(conversationIds);
|
|
1406
1411
|
if (Array.isArray(messageIds)) {
|
|
@@ -1419,7 +1424,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1419
1424
|
return grpcBatchResultsToPayload(response);
|
|
1420
1425
|
}
|
|
1421
1426
|
async messageBatchSendContact(conversationIds, contactId, batchTaskId) {
|
|
1422
|
-
|
|
1427
|
+
this.log.verbose('PuppetService', 'messageBatchSendContact(%s, %s)', conversationIds.join(','), contactId);
|
|
1423
1428
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendContactRequest();
|
|
1424
1429
|
request.setConversationIdsList(conversationIds);
|
|
1425
1430
|
request.setContactId(contactId);
|
|
@@ -1430,7 +1435,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1430
1435
|
return grpcBatchResultsToPayload(response);
|
|
1431
1436
|
}
|
|
1432
1437
|
async messageBatchSendUrl(conversationIds, urlLinkPayload, batchTaskId) {
|
|
1433
|
-
|
|
1438
|
+
this.log.verbose('PuppetService', 'messageBatchSendUrl(%s)', conversationIds.join(','));
|
|
1434
1439
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendUrlRequest();
|
|
1435
1440
|
request.setConversationIdsList(conversationIds);
|
|
1436
1441
|
request.setUrlLink((0, pb_payload_helper_js_1.urlLinkPayloadToPb)(wechaty_grpc_1.puppet, urlLinkPayload));
|
|
@@ -1441,7 +1446,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1441
1446
|
return grpcBatchResultsToPayload(response);
|
|
1442
1447
|
}
|
|
1443
1448
|
async messageBatchSendMiniProgram(conversationIds, miniProgramPayload, batchTaskId) {
|
|
1444
|
-
|
|
1449
|
+
this.log.verbose('PuppetService', 'messageBatchSendMiniProgram(%s)', conversationIds.join(','));
|
|
1445
1450
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendMiniProgramRequest();
|
|
1446
1451
|
request.setConversationIdsList(conversationIds);
|
|
1447
1452
|
request.setMiniProgram((0, pb_payload_helper_js_1.miniProgramPayloadToPb)(wechaty_grpc_1.puppet, miniProgramPayload));
|
|
@@ -1452,7 +1457,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1452
1457
|
return grpcBatchResultsToPayload(response);
|
|
1453
1458
|
}
|
|
1454
1459
|
async messageBatchSendLocation(conversationIds, locationPayload, batchTaskId) {
|
|
1455
|
-
|
|
1460
|
+
this.log.verbose('PuppetService', 'messageBatchSendLocation(%s)', conversationIds.join(','));
|
|
1456
1461
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendLocationRequest();
|
|
1457
1462
|
request.setConversationIdsList(conversationIds);
|
|
1458
1463
|
request.setLocation((0, pb_payload_helper_js_1.locationPayloadToPb)(wechaty_grpc_1.puppet, locationPayload));
|
|
@@ -1463,7 +1468,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1463
1468
|
return grpcBatchResultsToPayload(response);
|
|
1464
1469
|
}
|
|
1465
1470
|
async messageBatchSendChannel(conversationIds, channelPayload, batchTaskId) {
|
|
1466
|
-
|
|
1471
|
+
this.log.verbose('PuppetService', 'messageBatchSendChannel(%s)', conversationIds.join(','));
|
|
1467
1472
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendChannelRequest();
|
|
1468
1473
|
request.setConversationIdsList(conversationIds);
|
|
1469
1474
|
request.setChannel((0, pb_payload_helper_js_1.channelPayloadToPb)(wechaty_grpc_1.puppet, channelPayload));
|
|
@@ -1474,7 +1479,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1474
1479
|
return grpcBatchResultsToPayload(response);
|
|
1475
1480
|
}
|
|
1476
1481
|
async messageBatchSendChannelCard(conversationIds, channelCardPayload, batchTaskId) {
|
|
1477
|
-
|
|
1482
|
+
this.log.verbose('PuppetService', 'messageBatchSendChannelCard(%s)', conversationIds.join(','));
|
|
1478
1483
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendChannelCardRequest();
|
|
1479
1484
|
request.setConversationIdsList(conversationIds);
|
|
1480
1485
|
request.setChannelCard((0, pb_payload_helper_js_1.channelCardPayloadToPb)(wechaty_grpc_1.puppet, channelCardPayload));
|
|
@@ -1485,16 +1490,16 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1485
1490
|
return grpcBatchResultsToPayload(response);
|
|
1486
1491
|
}
|
|
1487
1492
|
async messageSendFile(conversationId, fileBox) {
|
|
1488
|
-
|
|
1493
|
+
this.log.verbose('PuppetService', 'messageSendFile(%s, %s)', conversationId, fileBox);
|
|
1489
1494
|
const request = new wechaty_grpc_1.puppet.MessageSendFileRequest();
|
|
1490
1495
|
request.setConversationId(conversationId);
|
|
1491
1496
|
const serializedFileBox = await this.serializeFileBox(fileBox);
|
|
1492
1497
|
request.setFileBox(serializedFileBox);
|
|
1493
|
-
|
|
1498
|
+
this.log.info('PuppetService', `messageSendFile(${conversationId}, ${fileBox}) about to call grpc`);
|
|
1494
1499
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendFile
|
|
1495
1500
|
.bind(this.grpcManager.client))(request);
|
|
1496
1501
|
const messageId = response.getId();
|
|
1497
|
-
|
|
1502
|
+
this.log.info('PuppetService', `messageSendFile(${conversationId}, ${fileBox}) grpc called, messageId: ${messageId}`);
|
|
1498
1503
|
if (messageId) {
|
|
1499
1504
|
return messageId;
|
|
1500
1505
|
}
|
|
@@ -1509,15 +1514,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1509
1514
|
}
|
|
1510
1515
|
}
|
|
1511
1516
|
async messageSendContact(conversationId, contactId) {
|
|
1512
|
-
|
|
1517
|
+
this.log.verbose('PuppetService', 'messageSend("%s", %s)', conversationId, contactId);
|
|
1513
1518
|
const request = new wechaty_grpc_1.puppet.MessageSendContactRequest();
|
|
1514
1519
|
request.setConversationId(conversationId);
|
|
1515
1520
|
request.setContactId(contactId);
|
|
1516
|
-
|
|
1521
|
+
this.log.info('PuppetService', `messageSendContact(${conversationId}, ${contactId}) about to call grpc`);
|
|
1517
1522
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendContact
|
|
1518
1523
|
.bind(this.grpcManager.client))(request);
|
|
1519
1524
|
const messageId = response.getId();
|
|
1520
|
-
|
|
1525
|
+
this.log.info('PuppetService', `messageSendContact(${conversationId}, ${contactId}) grpc called, messageId: ${messageId}`);
|
|
1521
1526
|
if (messageId) {
|
|
1522
1527
|
return messageId;
|
|
1523
1528
|
}
|
|
@@ -1532,7 +1537,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1532
1537
|
}
|
|
1533
1538
|
}
|
|
1534
1539
|
async messageSendUrl(conversationId, urlLinkPayload) {
|
|
1535
|
-
|
|
1540
|
+
this.log.verbose('PuppetService', 'messageSendUrl("%s", %s)', conversationId, JSON.stringify(urlLinkPayload));
|
|
1536
1541
|
const request = new wechaty_grpc_1.puppet.MessageSendUrlRequest();
|
|
1537
1542
|
request.setConversationId(conversationId);
|
|
1538
1543
|
const pbUrlLinkPayload = new wechaty_grpc_1.puppet.UrlLinkPayload();
|
|
@@ -1547,11 +1552,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1547
1552
|
request.setUrlLink(pbUrlLinkPayload);
|
|
1548
1553
|
// Deprecated: will be removed after Dec 31, 2022
|
|
1549
1554
|
request.setUrlLinkDeprecated(JSON.stringify(urlLinkPayload));
|
|
1550
|
-
|
|
1555
|
+
this.log.info('PuppetService', `messageSendUrl(${conversationId}, ${urlLinkPayload}) about to call grpc`);
|
|
1551
1556
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendUrl
|
|
1552
1557
|
.bind(this.grpcManager.client))(request);
|
|
1553
1558
|
const messageId = response.getId();
|
|
1554
|
-
|
|
1559
|
+
this.log.info('PuppetService', `messageSendUrl(${conversationId}, ${urlLinkPayload}) grpc called, messageId: ${messageId}`);
|
|
1555
1560
|
if (messageId) {
|
|
1556
1561
|
return messageId;
|
|
1557
1562
|
}
|
|
@@ -1566,22 +1571,22 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1566
1571
|
}
|
|
1567
1572
|
}
|
|
1568
1573
|
async messageSendPost(conversationId, postPayload) {
|
|
1569
|
-
|
|
1574
|
+
this.log.verbose('PuppetService', 'messageSendPost("%s", %s)', conversationId, JSON.stringify(postPayload));
|
|
1570
1575
|
const request = new wechaty_grpc_1.puppet.MessageSendPostRequest();
|
|
1571
1576
|
const post = await (0, pb_payload_helper_js_1.postPayloadToPb)(wechaty_grpc_1.puppet, postPayload, this.serializeFileBox.bind(this));
|
|
1572
1577
|
request.setContent(post);
|
|
1573
1578
|
request.setConversationId(conversationId);
|
|
1574
|
-
|
|
1579
|
+
this.log.info('PuppetService', `messageSendPost(${conversationId}, ${postPayload}) about to call grpc`);
|
|
1575
1580
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendPost
|
|
1576
1581
|
.bind(this.grpcManager.client))(request);
|
|
1577
1582
|
const messageId = response.getId();
|
|
1578
|
-
|
|
1583
|
+
this.log.info('PuppetService', `messageSendPost(${conversationId}, ${postPayload}) grpc called, messageId: ${messageId}`);
|
|
1579
1584
|
if (messageId) {
|
|
1580
1585
|
return messageId;
|
|
1581
1586
|
}
|
|
1582
1587
|
}
|
|
1583
1588
|
async messageUrl(messageId) {
|
|
1584
|
-
|
|
1589
|
+
this.log.verbose('PuppetService', 'messageUrl(%s)', messageId);
|
|
1585
1590
|
const request = new wechaty_grpc_1.puppet.MessageUrlRequest();
|
|
1586
1591
|
request.setId(messageId);
|
|
1587
1592
|
const response = await util_1.default.promisify(this.grpcManager.client.messageUrl
|
|
@@ -1600,7 +1605,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1600
1605
|
return payload;
|
|
1601
1606
|
}
|
|
1602
1607
|
async getMessageBroadcastTarget() {
|
|
1603
|
-
|
|
1608
|
+
this.log.verbose('PuppetService', 'getMessageBroadcastTarget()');
|
|
1604
1609
|
const request = new wechaty_grpc_1.puppet.GetMessageBroadcastTargetRequest();
|
|
1605
1610
|
const response = await util_1.default.promisify(this.grpcManager.client.getMessageBroadcastTarget.bind(this.grpcManager.client))(request);
|
|
1606
1611
|
return {
|
|
@@ -1609,7 +1614,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1609
1614
|
};
|
|
1610
1615
|
}
|
|
1611
1616
|
async createMessageBroadcast(targets, content) {
|
|
1612
|
-
|
|
1617
|
+
this.log.verbose('PuppetService', 'createMessageBroadcast()');
|
|
1613
1618
|
if (!PUPPET.payloads.isPostClient(content)) {
|
|
1614
1619
|
throw new Error('can only create broadcast with client post');
|
|
1615
1620
|
}
|
|
@@ -1621,7 +1626,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1621
1626
|
return response.getId();
|
|
1622
1627
|
}
|
|
1623
1628
|
async getMessageBroadcastStatus(id) {
|
|
1624
|
-
|
|
1629
|
+
this.log.verbose('PuppetService', 'getMessageBroadcastStatus()');
|
|
1625
1630
|
const request = new wechaty_grpc_1.puppet.GetMessageBroadcastStatusRequest();
|
|
1626
1631
|
request.setId(id);
|
|
1627
1632
|
const response = await util_1.default.promisify(this.grpcManager.client.getMessageBroadcastStatus.bind(this.grpcManager.client))(request);
|
|
@@ -1645,10 +1650,10 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1645
1650
|
*
|
|
1646
1651
|
*/
|
|
1647
1652
|
async roomRawPayload(id) {
|
|
1648
|
-
|
|
1653
|
+
this.log.verbose('PuppetService', 'roomRawPayload(%s)', id);
|
|
1649
1654
|
const cachedPayload = await this._payloadStore.room?.get(id);
|
|
1650
1655
|
if (cachedPayload) {
|
|
1651
|
-
|
|
1656
|
+
this.log.silly('PuppetService', 'roomRawPayload(%s) cache HIT', id);
|
|
1652
1657
|
return cachedPayload;
|
|
1653
1658
|
}
|
|
1654
1659
|
const request = new wechaty_grpc_1.puppet.RoomPayloadRequest();
|
|
@@ -1672,16 +1677,16 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1672
1677
|
payload.createTime = (0, timestamp_js_1.millisecondsFromTimestamp)(createTime);
|
|
1673
1678
|
}
|
|
1674
1679
|
await this._payloadStore.room?.set(id, payload);
|
|
1675
|
-
|
|
1680
|
+
this.log.silly('PuppetService', 'roomRawPayload(%s) cache SET', id);
|
|
1676
1681
|
return payload;
|
|
1677
1682
|
}
|
|
1678
1683
|
async roomRawPayloadParser(payload) {
|
|
1679
|
-
// log.silly('PuppetService', 'roomRawPayloadParser({id:%s})', payload.id)
|
|
1684
|
+
// this.log.silly('PuppetService', 'roomRawPayloadParser({id:%s})', payload.id)
|
|
1680
1685
|
// passthrough
|
|
1681
1686
|
return payload;
|
|
1682
1687
|
}
|
|
1683
1688
|
async batchRoomRawPayload(roomIdList) {
|
|
1684
|
-
|
|
1689
|
+
this.log.verbose('PuppetService', 'batchRoomRawPayload(%s)', roomIdList);
|
|
1685
1690
|
const result = new Map();
|
|
1686
1691
|
const roomIdSet = new Set(roomIdList);
|
|
1687
1692
|
const needGetSet = new Set();
|
|
@@ -1724,7 +1729,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1724
1729
|
}
|
|
1725
1730
|
}
|
|
1726
1731
|
catch (e) {
|
|
1727
|
-
|
|
1732
|
+
this.log.error('PuppetService', 'batchRoomRawPayload(%s, %s) error: %s, use one by one method', roomIdList, needGetSet, e);
|
|
1728
1733
|
for (const roomId of needGetSet) {
|
|
1729
1734
|
const payload = await this.roomRawPayload(roomId);
|
|
1730
1735
|
result.set(roomId, payload);
|
|
@@ -1734,13 +1739,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1734
1739
|
return result;
|
|
1735
1740
|
}
|
|
1736
1741
|
async roomList() {
|
|
1737
|
-
|
|
1742
|
+
this.log.verbose('PuppetService', 'roomList()');
|
|
1738
1743
|
const response = await util_1.default.promisify(this.grpcManager.client.roomList
|
|
1739
1744
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.RoomListRequest());
|
|
1740
1745
|
return response.getIdsList();
|
|
1741
1746
|
}
|
|
1742
1747
|
async roomDel(roomId, contactIds) {
|
|
1743
|
-
|
|
1748
|
+
this.log.verbose('PuppetService', 'roomDel(%s, %s)', roomId, contactIds);
|
|
1744
1749
|
const request = new wechaty_grpc_1.puppet.RoomDelRequest();
|
|
1745
1750
|
request.setId(roomId);
|
|
1746
1751
|
if (Array.isArray(contactIds)) {
|
|
@@ -1756,7 +1761,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1756
1761
|
.bind(this.grpcManager.client))(request);
|
|
1757
1762
|
}
|
|
1758
1763
|
async roomDelV2(roomId, contactIds) {
|
|
1759
|
-
|
|
1764
|
+
this.log.verbose('PuppetService', 'roomDelV2(%s, %s)', roomId, contactIds);
|
|
1760
1765
|
const request = new wechaty_grpc_1.puppet.RoomDelV2Request();
|
|
1761
1766
|
request.setId(roomId);
|
|
1762
1767
|
request.setContactIdsList(contactIds);
|
|
@@ -1769,7 +1774,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1769
1774
|
};
|
|
1770
1775
|
}
|
|
1771
1776
|
async roomAvatar(roomId) {
|
|
1772
|
-
|
|
1777
|
+
this.log.verbose('PuppetService', 'roomAvatar(%s)', roomId);
|
|
1773
1778
|
const request = new wechaty_grpc_1.puppet.RoomAvatarRequest();
|
|
1774
1779
|
request.setId(roomId);
|
|
1775
1780
|
const response = await util_1.default.promisify(this.grpcManager.client.roomAvatar
|
|
@@ -1778,7 +1783,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1778
1783
|
return this.FileBoxUuid.fromJSON(jsonText);
|
|
1779
1784
|
}
|
|
1780
1785
|
async roomAdd(roomId, contactId, inviteOnly, quoteIds) {
|
|
1781
|
-
|
|
1786
|
+
this.log.verbose('PuppetService', 'roomAdd(%s, %s)', roomId, contactId);
|
|
1782
1787
|
const request = new wechaty_grpc_1.puppet.RoomAddRequest();
|
|
1783
1788
|
request.setId(roomId);
|
|
1784
1789
|
if (Array.isArray(contactId)) {
|
|
@@ -1793,7 +1798,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1793
1798
|
.bind(this.grpcManager.client))(request);
|
|
1794
1799
|
}
|
|
1795
1800
|
async roomAddV2(roomId, contactIds, inviteOnly, quoteIds) {
|
|
1796
|
-
|
|
1801
|
+
this.log.verbose('PuppetService', 'roomAddV2(%s, %s)', roomId, contactIds);
|
|
1797
1802
|
const request = new wechaty_grpc_1.puppet.RoomAddV2Request();
|
|
1798
1803
|
request.setId(roomId);
|
|
1799
1804
|
request.setContactIdsList(contactIds);
|
|
@@ -1808,7 +1813,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1808
1813
|
};
|
|
1809
1814
|
}
|
|
1810
1815
|
async roomTopic(roomId, topic) {
|
|
1811
|
-
|
|
1816
|
+
this.log.verbose('PuppetService', 'roomTopic(%s, %s)', roomId, topic);
|
|
1812
1817
|
/**
|
|
1813
1818
|
* Get
|
|
1814
1819
|
*/
|
|
@@ -1846,7 +1851,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1846
1851
|
.bind(this.grpcManager.client))(request);
|
|
1847
1852
|
}
|
|
1848
1853
|
async roomRemark(roomId, remark) {
|
|
1849
|
-
|
|
1854
|
+
this.log.verbose('PuppetService', 'roomRemark(%s)', roomId);
|
|
1850
1855
|
const request = new wechaty_grpc_1.puppet.RoomRemarkRequest();
|
|
1851
1856
|
request.setId(roomId);
|
|
1852
1857
|
request.setRemark(remark);
|
|
@@ -1854,7 +1859,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1854
1859
|
.bind(this.grpcManager.client))(request);
|
|
1855
1860
|
}
|
|
1856
1861
|
async roomCreate(contactIdList, topic) {
|
|
1857
|
-
|
|
1862
|
+
this.log.verbose('PuppetService', 'roomCreate(%s, %s)', contactIdList, topic);
|
|
1858
1863
|
const request = new wechaty_grpc_1.puppet.RoomCreateRequest();
|
|
1859
1864
|
request.setContactIdsList(contactIdList);
|
|
1860
1865
|
request.setTopic(topic);
|
|
@@ -1863,14 +1868,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1863
1868
|
return response.getId();
|
|
1864
1869
|
}
|
|
1865
1870
|
async roomQuit(roomId) {
|
|
1866
|
-
|
|
1871
|
+
this.log.verbose('PuppetService', 'roomQuit(%s)', roomId);
|
|
1867
1872
|
const request = new wechaty_grpc_1.puppet.RoomQuitRequest();
|
|
1868
1873
|
request.setId(roomId);
|
|
1869
1874
|
await util_1.default.promisify(this.grpcManager.client.roomQuit
|
|
1870
1875
|
.bind(this.grpcManager.client))(request);
|
|
1871
1876
|
}
|
|
1872
1877
|
async roomQRCode(roomId) {
|
|
1873
|
-
|
|
1878
|
+
this.log.verbose('PuppetService', 'roomQRCode(%s)', roomId);
|
|
1874
1879
|
const request = new wechaty_grpc_1.puppet.RoomQRCodeRequest();
|
|
1875
1880
|
request.setId(roomId);
|
|
1876
1881
|
const response = await util_1.default.promisify(this.grpcManager.client.roomQRCode
|
|
@@ -1878,7 +1883,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1878
1883
|
return response.getQrcode();
|
|
1879
1884
|
}
|
|
1880
1885
|
async roomParseDynamicQRCode(url) {
|
|
1881
|
-
|
|
1886
|
+
this.log.verbose('PuppetService', 'roomParseDynamicQRCode(%s)', url);
|
|
1882
1887
|
const request = new wechaty_grpc_1.puppet.RoomParseDynamicQRCodeRequest();
|
|
1883
1888
|
request.setUrl(url);
|
|
1884
1889
|
const response = await util_1.default.promisify(this.grpcManager.client.roomParseDynamicQRCode
|
|
@@ -1890,7 +1895,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1890
1895
|
};
|
|
1891
1896
|
}
|
|
1892
1897
|
async roomMemberList(roomId) {
|
|
1893
|
-
|
|
1898
|
+
this.log.verbose('PuppetService', 'roomMemberList(%s)', roomId);
|
|
1894
1899
|
const request = new wechaty_grpc_1.puppet.RoomMemberListRequest();
|
|
1895
1900
|
request.setId(roomId);
|
|
1896
1901
|
const response = await util_1.default.promisify(this.grpcManager.client.roomMemberList
|
|
@@ -1898,11 +1903,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1898
1903
|
return response.getMemberIdsList();
|
|
1899
1904
|
}
|
|
1900
1905
|
async roomMemberRawPayload(roomId, contactId) {
|
|
1901
|
-
|
|
1906
|
+
this.log.verbose('PuppetService', 'roomMemberRawPayload(%s, %s)', roomId, contactId);
|
|
1902
1907
|
const cachedPayload = await this._payloadStore.roomMember?.get(roomId);
|
|
1903
1908
|
const cachedRoomMemberPayload = cachedPayload && cachedPayload[contactId];
|
|
1904
1909
|
if (cachedRoomMemberPayload) {
|
|
1905
|
-
|
|
1910
|
+
this.log.silly('PuppetService', 'roomMemberRawPayload(%s, %s) cache HIT', roomId, contactId);
|
|
1906
1911
|
return cachedRoomMemberPayload;
|
|
1907
1912
|
}
|
|
1908
1913
|
const request = new wechaty_grpc_1.puppet.RoomMemberPayloadRequest();
|
|
@@ -1924,16 +1929,16 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1924
1929
|
...cachedPayload,
|
|
1925
1930
|
[contactId]: payload,
|
|
1926
1931
|
});
|
|
1927
|
-
|
|
1932
|
+
this.log.silly('PuppetService', 'roomMemberRawPayload(%s, %s) cache SET', roomId, contactId);
|
|
1928
1933
|
return payload;
|
|
1929
1934
|
}
|
|
1930
1935
|
async roomMemberRawPayloadParser(payload) {
|
|
1931
|
-
// log.silly('PuppetService', 'roomMemberRawPayloadParser({id:%s})', payload.id)
|
|
1936
|
+
// this.log.silly('PuppetService', 'roomMemberRawPayloadParser({id:%s})', payload.id)
|
|
1932
1937
|
// passthrough
|
|
1933
1938
|
return payload;
|
|
1934
1939
|
}
|
|
1935
1940
|
async batchRoomMemberRawPayload(roomId, contactIdList) {
|
|
1936
|
-
|
|
1941
|
+
this.log.verbose('PuppetService', 'batchRoomMemberRawPayload(%s, %s)', roomId, contactIdList);
|
|
1937
1942
|
const result = new Map();
|
|
1938
1943
|
const contactIdSet = new Set(contactIdList);
|
|
1939
1944
|
let needGetSet = new Set();
|
|
@@ -1969,7 +1974,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1969
1974
|
await this._payloadStore.roomMember?.set(roomId, cachedPayload);
|
|
1970
1975
|
}
|
|
1971
1976
|
catch (e) {
|
|
1972
|
-
|
|
1977
|
+
this.log.error('PuppetService', 'batchRoomMemberRawPayload(%s, %s) error: %s, use one by one method', roomId, needGetSet, e);
|
|
1973
1978
|
for (const contactId of needGetSet) {
|
|
1974
1979
|
const payload = await this.roomMemberRawPayload(roomId, contactId);
|
|
1975
1980
|
result.set(contactId, payload);
|
|
@@ -1979,7 +1984,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1979
1984
|
return result;
|
|
1980
1985
|
}
|
|
1981
1986
|
async roomAnnounce(roomId, text) {
|
|
1982
|
-
|
|
1987
|
+
this.log.verbose('PuppetService', 'roomAnnounce(%s%s)', roomId, typeof text === 'undefined'
|
|
1983
1988
|
? ''
|
|
1984
1989
|
: `, ${text}`);
|
|
1985
1990
|
/**
|
|
@@ -2020,14 +2025,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2020
2025
|
return '';
|
|
2021
2026
|
}
|
|
2022
2027
|
async roomInvitationAccept(roomInvitationId) {
|
|
2023
|
-
|
|
2028
|
+
this.log.verbose('PuppetService', 'roomInvitationAccept(%s)', roomInvitationId);
|
|
2024
2029
|
const request = new wechaty_grpc_1.puppet.RoomInvitationAcceptRequest();
|
|
2025
2030
|
request.setId(roomInvitationId);
|
|
2026
2031
|
await util_1.default.promisify(this.grpcManager.client.roomInvitationAccept
|
|
2027
2032
|
.bind(this.grpcManager.client))(request);
|
|
2028
2033
|
}
|
|
2029
2034
|
async roomInvitationAcceptByQRCode(qrcode) {
|
|
2030
|
-
|
|
2035
|
+
this.log.verbose('PuppetService', 'roomInvitationAcceptByQRCode(%s)', qrcode);
|
|
2031
2036
|
const request = new wechaty_grpc_1.puppet.RoomInvitationAcceptByQRCodeRequest();
|
|
2032
2037
|
request.setQrcode(qrcode);
|
|
2033
2038
|
const response = await util_1.default.promisify(this.grpcManager.client.roomInvitationAcceptByQRCode
|
|
@@ -2038,7 +2043,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2038
2043
|
};
|
|
2039
2044
|
}
|
|
2040
2045
|
async roomInvitationRawPayload(id) {
|
|
2041
|
-
|
|
2046
|
+
this.log.verbose('PuppetService', 'roomInvitationRawPayload(%s)', id);
|
|
2042
2047
|
const request = new wechaty_grpc_1.puppet.RoomInvitationPayloadRequest();
|
|
2043
2048
|
request.setId(id);
|
|
2044
2049
|
const response = await util_1.default.promisify(this.grpcManager.client.roomInvitationPayload
|
|
@@ -2072,12 +2077,12 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2072
2077
|
return payload;
|
|
2073
2078
|
}
|
|
2074
2079
|
async roomInvitationRawPayloadParser(payload) {
|
|
2075
|
-
// log.silly('PuppetService', 'roomInvitationRawPayloadParser({id:%s})', payload.id)
|
|
2080
|
+
// this.log.silly('PuppetService', 'roomInvitationRawPayloadParser({id:%s})', payload.id)
|
|
2076
2081
|
// passthrough
|
|
2077
2082
|
return payload;
|
|
2078
2083
|
}
|
|
2079
2084
|
async roomPermission(roomId, permission) {
|
|
2080
|
-
|
|
2085
|
+
this.log.verbose('PuppetService', 'roomPermission(%s, %s)', roomId, JSON.stringify(permission));
|
|
2081
2086
|
const request = new wechaty_grpc_1.puppet.RoomPermissionRequest();
|
|
2082
2087
|
request.setId(roomId);
|
|
2083
2088
|
let set = false;
|
|
@@ -2103,7 +2108,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2103
2108
|
return set ? undefined : result;
|
|
2104
2109
|
}
|
|
2105
2110
|
async roomOwnerTransfer(roomId, contactId) {
|
|
2106
|
-
|
|
2111
|
+
this.log.verbose('PuppetService', 'roomOwnerTransfer(%s, %s)', roomId, contactId);
|
|
2107
2112
|
const request = new wechaty_grpc_1.puppet.RoomOwnerTransferRequest();
|
|
2108
2113
|
request.setId(roomId);
|
|
2109
2114
|
request.setContactId(contactId);
|
|
@@ -2111,7 +2116,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2111
2116
|
.bind(this.grpcManager.client))(request);
|
|
2112
2117
|
}
|
|
2113
2118
|
async roomAddAdmins(roomId, contactIdList) {
|
|
2114
|
-
|
|
2119
|
+
this.log.verbose('PuppetService', 'roomAddAdmins(%s, %s)', roomId, contactIdList);
|
|
2115
2120
|
const request = new wechaty_grpc_1.puppet.RoomAdminsRequest();
|
|
2116
2121
|
request.setId(roomId);
|
|
2117
2122
|
request.setContactIdsList(contactIdList);
|
|
@@ -2119,7 +2124,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2119
2124
|
.bind(this.grpcManager.client))(request);
|
|
2120
2125
|
}
|
|
2121
2126
|
async roomDelAdmins(roomId, contactIdList) {
|
|
2122
|
-
|
|
2127
|
+
this.log.verbose('PuppetService', 'roomDelAdmins(%s, %s)', roomId, contactIdList);
|
|
2123
2128
|
const request = new wechaty_grpc_1.puppet.RoomAdminsRequest();
|
|
2124
2129
|
request.setId(roomId);
|
|
2125
2130
|
request.setContactIdsList(contactIdList);
|
|
@@ -2127,7 +2132,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2127
2132
|
.bind(this.grpcManager.client))(request);
|
|
2128
2133
|
}
|
|
2129
2134
|
async roomDismiss(roomId) {
|
|
2130
|
-
|
|
2135
|
+
this.log.verbose('PuppetService', 'roomDelAdmins(%s)', roomId);
|
|
2131
2136
|
const request = new wechaty_grpc_1.puppet.RoomDismissRequest();
|
|
2132
2137
|
request.setId(roomId);
|
|
2133
2138
|
await util_1.default.promisify(this.grpcManager.client.roomDismiss
|
|
@@ -2139,7 +2144,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2139
2144
|
*
|
|
2140
2145
|
*/
|
|
2141
2146
|
async friendshipSearchPhone(phone, type) {
|
|
2142
|
-
|
|
2147
|
+
this.log.verbose('PuppetService', 'friendshipSearchPhone(%s)', phone);
|
|
2143
2148
|
const request = new wechaty_grpc_1.puppet.FriendshipSearchPhoneRequest();
|
|
2144
2149
|
request.setPhone(phone);
|
|
2145
2150
|
if (typeof (type) === 'undefined') {
|
|
@@ -2164,7 +2169,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2164
2169
|
return null;
|
|
2165
2170
|
}
|
|
2166
2171
|
async friendshipSearchHandle(handle, type) {
|
|
2167
|
-
|
|
2172
|
+
this.log.verbose('PuppetService', 'friendshipSearchHandle(%s)', handle);
|
|
2168
2173
|
const request = new wechaty_grpc_1.puppet.FriendshipSearchHandleRequest();
|
|
2169
2174
|
/**
|
|
2170
2175
|
* TODO: use `setHandle()` in v2.0.0
|
|
@@ -2193,7 +2198,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2193
2198
|
return null;
|
|
2194
2199
|
}
|
|
2195
2200
|
async friendshipRawPayload(id) {
|
|
2196
|
-
|
|
2201
|
+
this.log.verbose('PuppetService', 'friendshipRawPayload(%s)', id);
|
|
2197
2202
|
const request = new wechaty_grpc_1.puppet.FriendshipPayloadRequest();
|
|
2198
2203
|
request.setId(id);
|
|
2199
2204
|
const response = await util_1.default.promisify(this.grpcManager.client.friendshipPayload
|
|
@@ -2210,12 +2215,12 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2210
2215
|
return payload;
|
|
2211
2216
|
}
|
|
2212
2217
|
async friendshipRawPayloadParser(payload) {
|
|
2213
|
-
// log.silly('PuppetService', 'friendshipRawPayloadParser({id:%s})', payload.id)
|
|
2218
|
+
// this.log.silly('PuppetService', 'friendshipRawPayloadParser({id:%s})', payload.id)
|
|
2214
2219
|
// passthrough
|
|
2215
2220
|
return payload;
|
|
2216
2221
|
}
|
|
2217
2222
|
async friendshipAdd(contactId, options) {
|
|
2218
|
-
|
|
2223
|
+
this.log.verbose('PuppetService', 'friendshipAdd(%s, %s)', contactId, JSON.stringify(options));
|
|
2219
2224
|
const request = new wechaty_grpc_1.puppet.FriendshipAddRequest();
|
|
2220
2225
|
request.setContactId(contactId);
|
|
2221
2226
|
// FIXME: for backward compatibility, need to be removed after all puppet has updated.
|
|
@@ -2246,7 +2251,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2246
2251
|
.bind(this.grpcManager.client))(request);
|
|
2247
2252
|
}
|
|
2248
2253
|
async friendshipAccept(friendshipId) {
|
|
2249
|
-
|
|
2254
|
+
this.log.verbose('PuppetService', 'friendshipAccept(%s)', friendshipId);
|
|
2250
2255
|
const request = new wechaty_grpc_1.puppet.FriendshipAcceptRequest();
|
|
2251
2256
|
request.setId(friendshipId);
|
|
2252
2257
|
await util_1.default.promisify(this.grpcManager.client.friendshipAccept
|
|
@@ -2258,7 +2263,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2258
2263
|
*
|
|
2259
2264
|
*/
|
|
2260
2265
|
async tagContactTagAdd(tagIds, contactIds) {
|
|
2261
|
-
|
|
2266
|
+
this.log.verbose('PuppetService', 'tagContactTagAdd(%s, %s)', tagIds, contactIds);
|
|
2262
2267
|
const request = new wechaty_grpc_1.puppet.TagContactTagAddRequest();
|
|
2263
2268
|
request.setTagIdsList(tagIds);
|
|
2264
2269
|
request.setContactIdsList(contactIds);
|
|
@@ -2266,7 +2271,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2266
2271
|
.bind(this.grpcManager.client))(request);
|
|
2267
2272
|
}
|
|
2268
2273
|
async tagContactTagRemove(tagIds, contactIds) {
|
|
2269
|
-
|
|
2274
|
+
this.log.verbose('PuppetService', 'tagContactTagRemove(%s, %s)', tagIds, contactIds);
|
|
2270
2275
|
const request = new wechaty_grpc_1.puppet.TagContactTagRemoveRequest();
|
|
2271
2276
|
request.setTagIdsList(tagIds);
|
|
2272
2277
|
request.setContactIdsList(contactIds);
|
|
@@ -2274,7 +2279,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2274
2279
|
.bind(this.grpcManager.client))(request);
|
|
2275
2280
|
}
|
|
2276
2281
|
async tagGroupAdd(tagGroupName) {
|
|
2277
|
-
|
|
2282
|
+
this.log.verbose('PuppetService', 'tagGroupAdd(%s)', tagGroupName);
|
|
2278
2283
|
const request = new wechaty_grpc_1.puppet.TagGroupAddRequest();
|
|
2279
2284
|
request.setTagGroupName(tagGroupName);
|
|
2280
2285
|
const result = await util_1.default.promisify(this.grpcManager.client.tagGroupAdd
|
|
@@ -2283,14 +2288,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2283
2288
|
return id;
|
|
2284
2289
|
}
|
|
2285
2290
|
async tagGroupDelete(tagGroupId) {
|
|
2286
|
-
|
|
2291
|
+
this.log.verbose('PuppetService', 'tagGroupDelete(%s)', tagGroupId);
|
|
2287
2292
|
const request = new wechaty_grpc_1.puppet.TagGroupDeleteRequest();
|
|
2288
2293
|
request.setTagGroupId(tagGroupId);
|
|
2289
2294
|
await util_1.default.promisify(this.grpcManager.client.tagGroupDelete
|
|
2290
2295
|
.bind(this.grpcManager.client))(request);
|
|
2291
2296
|
}
|
|
2292
2297
|
async tagTagAdd(tagNameList, tagGroupId) {
|
|
2293
|
-
|
|
2298
|
+
this.log.verbose('PuppetService', 'tagTagAdd(%s, %s)', tagNameList, tagGroupId);
|
|
2294
2299
|
const request = new wechaty_grpc_1.puppet.TagTagAddRequest();
|
|
2295
2300
|
if (typeof tagGroupId !== 'undefined') {
|
|
2296
2301
|
request.setTagGroupId(tagGroupId);
|
|
@@ -2305,14 +2310,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2305
2310
|
return tagInfoList;
|
|
2306
2311
|
}
|
|
2307
2312
|
async tagTagDelete(tagIdList) {
|
|
2308
|
-
|
|
2313
|
+
this.log.verbose('PuppetService', 'tagTagDelete(%s)', tagIdList);
|
|
2309
2314
|
const request = new wechaty_grpc_1.puppet.TagTagDeleteRequest();
|
|
2310
2315
|
request.setTagIdList(tagIdList);
|
|
2311
2316
|
await util_1.default.promisify(this.grpcManager.client.tagTagDelete
|
|
2312
2317
|
.bind(this.grpcManager.client))(request);
|
|
2313
2318
|
}
|
|
2314
2319
|
async tagTagModify(tagNewInfoList) {
|
|
2315
|
-
|
|
2320
|
+
this.log.verbose('PuppetService', 'tagTagModify(%o)', tagNewInfoList);
|
|
2316
2321
|
const request = new wechaty_grpc_1.puppet.TagTagModifyRequest();
|
|
2317
2322
|
const newInfoList = tagNewInfoList.map(i => {
|
|
2318
2323
|
const tagInfo = new wechaty_grpc_1.puppet.TagTagInfo();
|
|
@@ -2330,7 +2335,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2330
2335
|
return tagInfoList;
|
|
2331
2336
|
}
|
|
2332
2337
|
async tagGroupList() {
|
|
2333
|
-
|
|
2338
|
+
this.log.verbose('PuppetService', 'tagGroupList()');
|
|
2334
2339
|
const request = new wechaty_grpc_1.puppet.TagGroupListRequest();
|
|
2335
2340
|
const result = await util_1.default.promisify(this.grpcManager.client.tagGroupList
|
|
2336
2341
|
.bind(this.grpcManager.client))(request);
|
|
@@ -2338,7 +2343,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2338
2343
|
return groupIds;
|
|
2339
2344
|
}
|
|
2340
2345
|
async tagGroupTagList(tagGroupId) {
|
|
2341
|
-
|
|
2346
|
+
this.log.verbose('PuppetService', 'tagGroupTagList(%s)', tagGroupId);
|
|
2342
2347
|
const request = new wechaty_grpc_1.puppet.TagGroupTagListRequest();
|
|
2343
2348
|
if (typeof tagGroupId !== 'undefined') {
|
|
2344
2349
|
request.setTagGroupId(tagGroupId);
|
|
@@ -2349,7 +2354,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2349
2354
|
return tagIds;
|
|
2350
2355
|
}
|
|
2351
2356
|
async tagTagList() {
|
|
2352
|
-
|
|
2357
|
+
this.log.verbose('PuppetService', 'tagTagList()');
|
|
2353
2358
|
const request = new wechaty_grpc_1.puppet.TagTagListRequest();
|
|
2354
2359
|
const result = await util_1.default.promisify(this.grpcManager.client.tagTagList
|
|
2355
2360
|
.bind(this.grpcManager.client))(request);
|
|
@@ -2357,7 +2362,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2357
2362
|
return tagIds;
|
|
2358
2363
|
}
|
|
2359
2364
|
async tagContactTagList(contactId) {
|
|
2360
|
-
|
|
2365
|
+
this.log.verbose('PuppetService', 'tagContactTagList(%s)', contactId);
|
|
2361
2366
|
const request = new wechaty_grpc_1.puppet.TagContactTagListRequest();
|
|
2362
2367
|
request.setContactId(contactId);
|
|
2363
2368
|
const result = await util_1.default.promisify(this.grpcManager.client.tagContactTagList
|
|
@@ -2366,7 +2371,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2366
2371
|
return tagIds;
|
|
2367
2372
|
}
|
|
2368
2373
|
async tagTagContactList(tagId) {
|
|
2369
|
-
|
|
2374
|
+
this.log.verbose('PuppetService', 'tagTagContactList(%s)', tagId);
|
|
2370
2375
|
const request = new wechaty_grpc_1.puppet.TagTagContactListRequest();
|
|
2371
2376
|
request.setTagId(tagId);
|
|
2372
2377
|
const result = await util_1.default.promisify(this.grpcManager.client.tagTagContactList
|
|
@@ -2375,10 +2380,10 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2375
2380
|
return contactIds;
|
|
2376
2381
|
}
|
|
2377
2382
|
async tagGroupPayloadPuppet(id) {
|
|
2378
|
-
|
|
2383
|
+
this.log.verbose('PuppetService', 'tagGroupPayload(%s)', id);
|
|
2379
2384
|
const cachedPayload = await this._payloadStore.tagGroup?.get(id);
|
|
2380
2385
|
if (cachedPayload) {
|
|
2381
|
-
|
|
2386
|
+
this.log.silly('PuppetService', 'tagGroupPayload(%s) cache HIT', id);
|
|
2382
2387
|
return cachedPayload;
|
|
2383
2388
|
}
|
|
2384
2389
|
const request = new wechaty_grpc_1.puppet.TagGroupPayloadRequest();
|
|
@@ -2395,14 +2400,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2395
2400
|
type: grpcPayload.getType(),
|
|
2396
2401
|
};
|
|
2397
2402
|
await this._payloadStore.tagGroup?.set(id, payload);
|
|
2398
|
-
|
|
2403
|
+
this.log.silly('PuppetService', 'tagGroupPayloadPuppet(%s) cache SET', id);
|
|
2399
2404
|
return payload;
|
|
2400
2405
|
}
|
|
2401
2406
|
async tagPayloadPuppet(tagId) {
|
|
2402
|
-
|
|
2407
|
+
this.log.verbose('PuppetService', 'tagPayloadPuppet(%s)', tagId);
|
|
2403
2408
|
const cachedPayload = await this._payloadStore.tag?.get(tagId);
|
|
2404
2409
|
if (cachedPayload) {
|
|
2405
|
-
|
|
2410
|
+
this.log.silly('PuppetService', 'tagPayloadPuppet(%s) cache HIT', tagId);
|
|
2406
2411
|
return cachedPayload;
|
|
2407
2412
|
}
|
|
2408
2413
|
const request = new wechaty_grpc_1.puppet.TagPayloadRequest();
|
|
@@ -2420,7 +2425,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2420
2425
|
type: grpcPayload.getType(),
|
|
2421
2426
|
};
|
|
2422
2427
|
await this._payloadStore.tag?.set(tagId, payload);
|
|
2423
|
-
|
|
2428
|
+
this.log.silly('PuppetService', 'tagPayloadPuppet(%s) cache SET', tagId);
|
|
2424
2429
|
return payload;
|
|
2425
2430
|
}
|
|
2426
2431
|
/**
|
|
@@ -2429,7 +2434,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2429
2434
|
*
|
|
2430
2435
|
*/
|
|
2431
2436
|
async postPublish(payload) {
|
|
2432
|
-
|
|
2437
|
+
this.log.verbose('PuppetService', 'postPublish(%s)', payload);
|
|
2433
2438
|
if (!PUPPET.payloads.isPostClient(payload)) {
|
|
2434
2439
|
throw new Error('can only publish client post now');
|
|
2435
2440
|
}
|
|
@@ -2442,13 +2447,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2442
2447
|
return momentId;
|
|
2443
2448
|
}
|
|
2444
2449
|
async postUnpublish(id) {
|
|
2445
|
-
|
|
2450
|
+
this.log.verbose('PuppetService', 'postUnpublish(%s)', id);
|
|
2446
2451
|
const request = new wechaty_grpc_1.puppet.MomentUnpublishRequest();
|
|
2447
2452
|
request.setMomentId(id);
|
|
2448
2453
|
await util_1.default.promisify(this.grpcManager.client.momentUnpublish.bind(this.grpcManager.client))(request);
|
|
2449
2454
|
}
|
|
2450
2455
|
async momentSignature(text) {
|
|
2451
|
-
|
|
2456
|
+
this.log.verbose('PuppetService', 'momentSignature(%s)', text);
|
|
2452
2457
|
const request = new wechaty_grpc_1.puppet.MomentSignatureRequest();
|
|
2453
2458
|
if (text) {
|
|
2454
2459
|
request.setText(text);
|
|
@@ -2459,7 +2464,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2459
2464
|
return signature;
|
|
2460
2465
|
}
|
|
2461
2466
|
async momentCoverage(cover) {
|
|
2462
|
-
|
|
2467
|
+
this.log.verbose('PuppetService', 'momentCoverage(%s)', JSON.stringify(cover));
|
|
2463
2468
|
const request = new wechaty_grpc_1.puppet.MomentCoverageRequest();
|
|
2464
2469
|
if (cover) {
|
|
2465
2470
|
const serializedFileBox = await this.serializeFileBox(cover);
|
|
@@ -2473,7 +2478,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2473
2478
|
}
|
|
2474
2479
|
}
|
|
2475
2480
|
async postPayloadSayable(postId, sayableId) {
|
|
2476
|
-
|
|
2481
|
+
this.log.verbose('PuppetService', 'postPayloadSayable(%s, %s)', postId, sayableId);
|
|
2477
2482
|
const request = new wechaty_grpc_1.puppet.PostPayloadSayableRequest();
|
|
2478
2483
|
request.setPostId(postId);
|
|
2479
2484
|
request.setSayableId(sayableId);
|
|
@@ -2525,7 +2530,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2525
2530
|
}
|
|
2526
2531
|
}
|
|
2527
2532
|
async postRawPayload(id) {
|
|
2528
|
-
|
|
2533
|
+
this.log.verbose('PuppetService', 'postRawPayload(%s)', id);
|
|
2529
2534
|
const request = new wechaty_grpc_1.puppet.PostPayloadRequest();
|
|
2530
2535
|
request.setPostId(id);
|
|
2531
2536
|
const response = await util_1.default.promisify(this.grpcManager.client.postPayload
|
|
@@ -2569,12 +2574,12 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2569
2574
|
return payload;
|
|
2570
2575
|
}
|
|
2571
2576
|
async postRawPayloadParser(payload) {
|
|
2572
|
-
// log.silly('PuppetService', 'postRawPayloadParser({id:%s})', payload.id)
|
|
2577
|
+
// this.log.silly('PuppetService', 'postRawPayloadParser({id:%s})', payload.id)
|
|
2573
2578
|
// passthrough
|
|
2574
2579
|
return payload;
|
|
2575
2580
|
}
|
|
2576
2581
|
async tap(postId, type, tap = true) {
|
|
2577
|
-
|
|
2582
|
+
this.log.verbose('PuppetService', 'tap(%s, %s, %s)', postId, type, tap);
|
|
2578
2583
|
const request = new wechaty_grpc_1.puppet.PostTapRequest();
|
|
2579
2584
|
request.setPostId(postId);
|
|
2580
2585
|
if (type) {
|
|
@@ -2587,14 +2592,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2587
2592
|
return result;
|
|
2588
2593
|
}
|
|
2589
2594
|
async momentVisibleList() {
|
|
2590
|
-
|
|
2595
|
+
this.log.verbose('PuppetService', 'momentVisibleList()');
|
|
2591
2596
|
const request = new wechaty_grpc_1.puppet.MomentVisibleListRequest();
|
|
2592
2597
|
const response = await util_1.default.promisify(this.grpcManager.client.momentVisibleList.bind(this.grpcManager.client))(request);
|
|
2593
2598
|
const contactIdsList = response.getContactIdsList();
|
|
2594
2599
|
return contactIdsList;
|
|
2595
2600
|
}
|
|
2596
2601
|
async getContactExternalUserId(contactIds, serviceProviderId) {
|
|
2597
|
-
|
|
2602
|
+
this.log.verbose('PuppetService', 'getContactExternalUserId(%s, %s)', JSON.stringify(contactIds), serviceProviderId);
|
|
2598
2603
|
const request = new wechaty_grpc_1.puppet.GetContactExternalUserIdRequest();
|
|
2599
2604
|
request.setContactIdsList(contactIds);
|
|
2600
2605
|
if (serviceProviderId) {
|
|
@@ -2612,7 +2617,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2612
2617
|
return result;
|
|
2613
2618
|
}
|
|
2614
2619
|
async getRoomAntiSpamStrategyList() {
|
|
2615
|
-
|
|
2620
|
+
this.log.verbose('PuppetService', 'getRoomAntiSpamStrategyList()');
|
|
2616
2621
|
const request = new wechaty_grpc_1.puppet.GetRoomAntiSpamStrategyListRequest();
|
|
2617
2622
|
const response = await util_1.default.promisify(this.grpcManager.client.getRoomAntiSpamStrategyList.bind(this.grpcManager.client))(request);
|
|
2618
2623
|
const result = [];
|
|
@@ -2626,7 +2631,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2626
2631
|
return result;
|
|
2627
2632
|
}
|
|
2628
2633
|
async getRoomAntiSpamStrategyEffectRoomList(strategyId) {
|
|
2629
|
-
|
|
2634
|
+
this.log.verbose('PuppetService', 'getRoomAntiSpamStrategyEffectRoomList(%s)', strategyId);
|
|
2630
2635
|
const request = new wechaty_grpc_1.puppet.GetRoomAntiSpamStrategyEffectRoomListRequest();
|
|
2631
2636
|
request.setStrategyId(strategyId);
|
|
2632
2637
|
const response = await util_1.default.promisify(this.grpcManager.client.getRoomAntiSpamStrategyEffectRoomList.bind(this.grpcManager.client))(request);
|
|
@@ -2634,7 +2639,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2634
2639
|
return result;
|
|
2635
2640
|
}
|
|
2636
2641
|
async applyRoomAntiSpamStrategy(strategyId, roomIds, active) {
|
|
2637
|
-
|
|
2642
|
+
this.log.verbose('PuppetService', 'applyRoomAntiSpamStrategy(%s, %s, %s)', strategyId, roomIds, active);
|
|
2638
2643
|
const request = new wechaty_grpc_1.puppet.ApplyRoomAntiSpamStrategyRequest();
|
|
2639
2644
|
request.setStrategyId(strategyId);
|
|
2640
2645
|
request.setRoomIdsList(roomIds);
|
|
@@ -2642,7 +2647,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2642
2647
|
await util_1.default.promisify(this.grpcManager.client.applyRoomAntiSpamStrategy.bind(this.grpcManager.client))(request);
|
|
2643
2648
|
}
|
|
2644
2649
|
async getCorpMessageInterceptionStrategies() {
|
|
2645
|
-
|
|
2650
|
+
this.log.verbose('PuppetService', 'getCorpMessageInterceptionStrategies()');
|
|
2646
2651
|
const request = new wechaty_grpc_1.puppet.GetCorpMessageInterceptionStrategiesRequest();
|
|
2647
2652
|
const response = await util_1.default.promisify(this.grpcManager.client.getCorpMessageInterceptionStrategies.bind(this.grpcManager.client))(request);
|
|
2648
2653
|
const result = [];
|
|
@@ -2675,15 +2680,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2675
2680
|
reconnectIndicator;
|
|
2676
2681
|
async reset() {
|
|
2677
2682
|
if (!this._grpcManager) {
|
|
2678
|
-
|
|
2683
|
+
this.log.warn('PuppetService', 'grpc manager not constructed, perform regular reset');
|
|
2679
2684
|
return super.reset();
|
|
2680
2685
|
}
|
|
2681
2686
|
if (!this.isLoggedIn) {
|
|
2682
|
-
|
|
2687
|
+
this.log.warn('PuppetService', 'puppet not logged in, perform regular reset');
|
|
2683
2688
|
return super.reset();
|
|
2684
2689
|
}
|
|
2685
2690
|
if (this.reconnectIndicator.value()) {
|
|
2686
|
-
|
|
2691
|
+
this.log.warn('PuppetService', 'already trying to reconnect, pass this one');
|
|
2687
2692
|
return;
|
|
2688
2693
|
}
|
|
2689
2694
|
this.reconnectIndicator.value(true);
|
|
@@ -2733,13 +2738,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2733
2738
|
}
|
|
2734
2739
|
catch (e) {
|
|
2735
2740
|
if (Date.now() - startTime < timeoutMilliseconds) {
|
|
2736
|
-
|
|
2741
|
+
this.log.warn('failed to start stream, will try again in 15 seconds');
|
|
2737
2742
|
await new Promise(resolve => {
|
|
2738
2743
|
setTimeout(resolve, 5000);
|
|
2739
2744
|
});
|
|
2740
2745
|
}
|
|
2741
2746
|
else {
|
|
2742
|
-
|
|
2747
|
+
this.log.warn('failed to start stream and reaches timeout, will perform regular reset');
|
|
2743
2748
|
this.reconnectIndicator.value(false);
|
|
2744
2749
|
return super.reset();
|
|
2745
2750
|
}
|
|
@@ -2756,7 +2761,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2756
2761
|
});
|
|
2757
2762
|
}
|
|
2758
2763
|
catch (e) {
|
|
2759
|
-
|
|
2764
|
+
this.log.warn('PuppetService', 'waiting for event reset login error, will perform regular reset');
|
|
2760
2765
|
return super.reset();
|
|
2761
2766
|
}
|
|
2762
2767
|
try {
|
|
@@ -2767,7 +2772,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2767
2772
|
});
|
|
2768
2773
|
}
|
|
2769
2774
|
catch (e) {
|
|
2770
|
-
|
|
2775
|
+
this.log.warn('PuppetService', 'waiting for event reset ready error, will do nothing');
|
|
2771
2776
|
}
|
|
2772
2777
|
}
|
|
2773
2778
|
async getMiscellaneousStoreData() {
|
|
@@ -2781,7 +2786,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2781
2786
|
const lastEventTimestamp = await this._payloadStore.miscellaneous?.get('lastEventTimestamp');
|
|
2782
2787
|
let lastEventSeq = await this._payloadStore.miscellaneous?.get('lastEventSeq');
|
|
2783
2788
|
if ((Date.now() - Number(lastEventTimestamp || 0)) > this.timeoutMilliseconds) {
|
|
2784
|
-
|
|
2789
|
+
this.log.warn(`last event was ${(Date.now() - Number(lastEventTimestamp || 0)) / 1000} seconds ago, will not request event cache`);
|
|
2785
2790
|
lastEventSeq = undefined;
|
|
2786
2791
|
}
|
|
2787
2792
|
const accountId = await this._payloadStore.miscellaneous?.get('accountId');
|