@juzi/wechaty-puppet-service 1.0.123 → 1.0.125
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 +336 -227
- 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/cjs/tests/dirty-gen-guard.spec.d.ts +3 -0
- package/dist/cjs/tests/dirty-gen-guard.spec.d.ts.map +1 -0
- package/dist/cjs/tests/dirty-gen-guard.spec.js +206 -0
- package/dist/cjs/tests/dirty-gen-guard.spec.js.map +1 -0
- 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 +336 -227
- 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/dist/esm/tests/dirty-gen-guard.spec.d.ts +3 -0
- package/dist/esm/tests/dirty-gen-guard.spec.d.ts.map +1 -0
- package/dist/esm/tests/dirty-gen-guard.spec.js +178 -0
- package/dist/esm/tests/dirty-gen-guard.spec.js.map +1 -0
- 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 +337 -228
- 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,11 +290,39 @@ 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: {
|
|
296
297
|
const dirtyPayload = JSON.parse(payload);
|
|
298
|
+
/**
|
|
299
|
+
* Bump the generation counter *before* awaiting fastDirty so the
|
|
300
|
+
* whole fastDirty window is covered: any raw fetch that started
|
|
301
|
+
* before this dirty and resolves while fastDirty is deleting the
|
|
302
|
+
* FlashStore row must be judged stale by `isFreshWrite` and skip
|
|
303
|
+
* its write-back -- otherwise it re-poisons the row we just
|
|
304
|
+
* cleared and the value only refreshes after a *second* dirty.
|
|
305
|
+
*
|
|
306
|
+
* Upstream cache-mixin.onDirty bumps the same (type, id) again
|
|
307
|
+
* after `emit('dirty')` below; double-bumping is harmless because
|
|
308
|
+
* the counter only moves forward and `isFreshWrite` compares by
|
|
309
|
+
* equality.
|
|
310
|
+
*/
|
|
311
|
+
this.cache.bumpGen(dirtyPayload.payloadType, dirtyPayload.payloadId);
|
|
312
|
+
/**
|
|
313
|
+
* A compound RoomMember dirty (`${roomId}${SEP}${memberId}`) must
|
|
314
|
+
* also bump the bare roomId key: roomMember write-backs are
|
|
315
|
+
* row-level read-modify-writes keyed by roomId, so a single-member
|
|
316
|
+
* dirty has to move that key too or an in-flight roomMember fetch
|
|
317
|
+
* could still write the whole row back stale.
|
|
318
|
+
*/
|
|
319
|
+
if (dirtyPayload.payloadType === PUPPET.types.Dirty.RoomMember
|
|
320
|
+
&& dirtyPayload.payloadId.includes(PUPPET.STRING_SPLITTER)) {
|
|
321
|
+
const [roomId] = dirtyPayload.payloadId.split(PUPPET.STRING_SPLITTER);
|
|
322
|
+
if (roomId) {
|
|
323
|
+
this.cache.bumpGen(PUPPET.types.Dirty.RoomMember, roomId);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
297
326
|
await this.fastDirty(dirtyPayload);
|
|
298
327
|
this.emit('dirty', dirtyPayload);
|
|
299
328
|
break;
|
|
@@ -312,7 +341,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
312
341
|
break;
|
|
313
342
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_READY:
|
|
314
343
|
if (this.waitingForReady && this.readyIndicator.value()) {
|
|
315
|
-
|
|
344
|
+
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
345
|
return;
|
|
317
346
|
}
|
|
318
347
|
this.emit('ready', JSON.parse(payload));
|
|
@@ -342,14 +371,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
342
371
|
this.emit('tag-group', JSON.parse(payload));
|
|
343
372
|
break;
|
|
344
373
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_RESET:
|
|
345
|
-
|
|
374
|
+
this.log.warn('PuppetService', 'onGrpcStreamEvent() got an EventType.EVENT_TYPE_RESET ?');
|
|
346
375
|
// the `reset` event should be dealed not send out
|
|
347
376
|
break;
|
|
348
377
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_VERIFY_CODE:
|
|
349
378
|
this.emit('verify-code', JSON.parse(payload));
|
|
350
379
|
break;
|
|
351
380
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_UNSPECIFIED:
|
|
352
|
-
|
|
381
|
+
this.log.error('PuppetService', 'onGrpcStreamEvent() got an EventType.EVENT_TYPE_UNSPECIFIED ?');
|
|
353
382
|
break;
|
|
354
383
|
case wechaty_grpc_1.puppet.EventType.EVENT_TYPE_VERIFY_SLIDE:
|
|
355
384
|
this.emit('verify-slide', JSON.parse(payload));
|
|
@@ -359,27 +388,27 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
359
388
|
break;
|
|
360
389
|
default:
|
|
361
390
|
// Huan(202003): in default, the `type` type should be `never`, please check.
|
|
362
|
-
|
|
391
|
+
this.log.error(`eventType ${type} unsupported! data: ${payload}`);
|
|
363
392
|
}
|
|
364
393
|
}
|
|
365
394
|
async logout(reason) {
|
|
366
|
-
|
|
395
|
+
this.log.verbose('PuppetService', 'logout(%s)', reason ? `"${reason}"` : '');
|
|
367
396
|
await super.logout(reason);
|
|
368
397
|
try {
|
|
369
398
|
await util_1.default.promisify(this.grpcManager.client.logout
|
|
370
399
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.LogoutRequest());
|
|
371
400
|
}
|
|
372
401
|
catch (e) {
|
|
373
|
-
|
|
402
|
+
this.log.silly('PuppetService', 'logout() no grpc client');
|
|
374
403
|
}
|
|
375
404
|
}
|
|
376
405
|
ding(data) {
|
|
377
|
-
|
|
406
|
+
this.log.silly('PuppetService', 'ding(%s)', data);
|
|
378
407
|
const request = new wechaty_grpc_1.puppet.DingRequest();
|
|
379
408
|
request.setData(data || '');
|
|
380
409
|
this.grpcManager.client.ding(request, (error, _response) => {
|
|
381
410
|
if (error) {
|
|
382
|
-
|
|
411
|
+
this.log.error('PuppetService', 'ding() rejection: %s', error);
|
|
383
412
|
}
|
|
384
413
|
});
|
|
385
414
|
}
|
|
@@ -392,7 +421,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
392
421
|
*
|
|
393
422
|
*/
|
|
394
423
|
async dirtyPayload(type, id) {
|
|
395
|
-
|
|
424
|
+
this.log.verbose('PuppetService', 'dirtyPayload(%s, %s)', type, id);
|
|
396
425
|
const request = new wechaty_grpc_1.puppet.DirtyPayloadRequest();
|
|
397
426
|
request.setId(id);
|
|
398
427
|
request.setType(type);
|
|
@@ -401,7 +430,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
401
430
|
.bind(this.grpcManager.client))(request);
|
|
402
431
|
}
|
|
403
432
|
catch (e) {
|
|
404
|
-
|
|
433
|
+
this.log.error('PuppetService', 'dirtyPayload() rejection: %s', e && e.message);
|
|
405
434
|
throw e;
|
|
406
435
|
}
|
|
407
436
|
}
|
|
@@ -483,7 +512,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
483
512
|
[PUPPET.types.Dirty.Call]: async (_) => { },
|
|
484
513
|
[PUPPET.types.Dirty.Unspecified]: async (id) => {
|
|
485
514
|
const msg = `fastDirty() received Unspecified dirty type (id=${id}); upstream puppet is leaking protobuf default — this is a server-side contract bug`;
|
|
486
|
-
|
|
515
|
+
this.log.error('PuppetService', msg);
|
|
487
516
|
this.emit('error', new Error(msg));
|
|
488
517
|
},
|
|
489
518
|
};
|
|
@@ -493,14 +522,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
493
522
|
* the event listener will be registered in `start()` from the `PuppetAbstract` class
|
|
494
523
|
*/
|
|
495
524
|
async fastDirty({ payloadType, payloadId, }) {
|
|
496
|
-
|
|
525
|
+
this.log.verbose('PuppetService', 'fastDirty(%s<%s>, %s)', PUPPET.types.Dirty[payloadType], payloadType, payloadId);
|
|
497
526
|
// payloadType is typed as the enum, but at runtime the server may emit a
|
|
498
527
|
// value outside our enum (forward-compat). Look it up via a
|
|
499
528
|
// possibly-undefined view so the runtime guard stays meaningful.
|
|
500
529
|
const lookup = this._dirtyHandlerMap;
|
|
501
530
|
const handler = lookup[payloadType];
|
|
502
531
|
if (!handler) {
|
|
503
|
-
|
|
532
|
+
this.log.warn('PuppetService', 'fastDirty() no handler for payloadType=%s', payloadType);
|
|
504
533
|
return;
|
|
505
534
|
}
|
|
506
535
|
try {
|
|
@@ -511,7 +540,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
511
540
|
}
|
|
512
541
|
}
|
|
513
542
|
async enterVerifyCode(id, code) {
|
|
514
|
-
|
|
543
|
+
this.log.verbose('PuppetService', 'enterVerifyCode(%s, %s)', id, code);
|
|
515
544
|
const request = new wechaty_grpc_1.puppet.EnterVerifyCodeRequest();
|
|
516
545
|
request.setId(id);
|
|
517
546
|
request.setCode(code);
|
|
@@ -519,20 +548,20 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
519
548
|
.bind(this.grpcManager.client))(request);
|
|
520
549
|
}
|
|
521
550
|
async cancelVerifyCode(id) {
|
|
522
|
-
|
|
551
|
+
this.log.verbose('PuppetService', 'cancelVerifyCode(%s)', id);
|
|
523
552
|
const request = new wechaty_grpc_1.puppet.CancelVerifyCodeRequest();
|
|
524
553
|
request.setId(id);
|
|
525
554
|
await util_1.default.promisify(this.grpcManager.client.cancelVerifyCode
|
|
526
555
|
.bind(this.grpcManager.client))(request);
|
|
527
556
|
}
|
|
528
557
|
async refreshQRCode() {
|
|
529
|
-
|
|
558
|
+
this.log.verbose('PuppetService', 'refreshQRCode(%s)');
|
|
530
559
|
const request = new wechaty_grpc_1.puppet.RefreshQRCodeRequest();
|
|
531
560
|
await util_1.default.promisify(this.grpcManager.client.refreshQRCode
|
|
532
561
|
.bind(this.grpcManager.client))(request);
|
|
533
562
|
}
|
|
534
563
|
async contactAlias(contactId, alias) {
|
|
535
|
-
|
|
564
|
+
this.log.verbose('PuppetService', 'contactAlias(%s, %s)', contactId, alias);
|
|
536
565
|
/**
|
|
537
566
|
* Get alias
|
|
538
567
|
*/
|
|
@@ -570,7 +599,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
570
599
|
.bind(this.grpcManager.client))(request);
|
|
571
600
|
}
|
|
572
601
|
async contactPhone(contactId, phoneList) {
|
|
573
|
-
|
|
602
|
+
this.log.verbose('PuppetService', 'contactPhone(%s, %s)', contactId, phoneList);
|
|
574
603
|
const request = new wechaty_grpc_1.puppet.ContactPhoneRequest();
|
|
575
604
|
request.setContactId(contactId);
|
|
576
605
|
request.setPhonesList(phoneList);
|
|
@@ -578,7 +607,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
578
607
|
.bind(this.grpcManager.client))(request);
|
|
579
608
|
}
|
|
580
609
|
async contactCorporationRemark(contactId, corporationRemark) {
|
|
581
|
-
|
|
610
|
+
this.log.verbose('PuppetService', 'contactCorporationRemark(%s, %s)', contactId, corporationRemark);
|
|
582
611
|
const request = new wechaty_grpc_1.puppet.ContactCorporationRemarkRequest();
|
|
583
612
|
request.setContactId(contactId);
|
|
584
613
|
if (corporationRemark) {
|
|
@@ -596,7 +625,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
596
625
|
.bind(this.grpcManager.client))(request);
|
|
597
626
|
}
|
|
598
627
|
async contactDescription(contactId, description) {
|
|
599
|
-
|
|
628
|
+
this.log.verbose('PuppetService', 'contactDescription(%s, %s)', contactId, description);
|
|
600
629
|
const request = new wechaty_grpc_1.puppet.ContactDescriptionRequest();
|
|
601
630
|
request.setContactId(contactId);
|
|
602
631
|
if (description) {
|
|
@@ -614,13 +643,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
614
643
|
.bind(this.grpcManager.client))(request);
|
|
615
644
|
}
|
|
616
645
|
async contactList() {
|
|
617
|
-
|
|
646
|
+
this.log.verbose('PuppetService', 'contactList()');
|
|
618
647
|
const response = await util_1.default.promisify(this.grpcManager.client.contactList
|
|
619
648
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.ContactListRequest());
|
|
620
649
|
return response.getIdsList();
|
|
621
650
|
}
|
|
622
651
|
async contactAvatar(contactId, fileBox) {
|
|
623
|
-
|
|
652
|
+
this.log.verbose('PuppetService', 'contactAvatar(%s)', contactId);
|
|
624
653
|
/**
|
|
625
654
|
* 1. set
|
|
626
655
|
*/
|
|
@@ -657,12 +686,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
657
686
|
return this.FileBoxUuid.fromJSON(jsonText);
|
|
658
687
|
}
|
|
659
688
|
async contactRawPayload(id) {
|
|
660
|
-
|
|
689
|
+
this.log.verbose('PuppetService', 'contactRawPayload(%s)', id);
|
|
661
690
|
const cachedPayload = await this._payloadStore.contact?.get(id);
|
|
662
691
|
if (cachedPayload) {
|
|
663
|
-
|
|
692
|
+
this.log.silly('PuppetService', 'contactRawPayload(%s) cache HIT', id);
|
|
664
693
|
return cachedPayload;
|
|
665
694
|
}
|
|
695
|
+
// Snapshot the gen before the raw fetch so a dirty that lands while
|
|
696
|
+
// the gRPC round-trip is in flight makes the write-back below stale.
|
|
697
|
+
const gen = this.cache.snapshotGen(PUPPET.types.Dirty.Contact, id);
|
|
666
698
|
const request = new wechaty_grpc_1.puppet.ContactPayloadRequest();
|
|
667
699
|
request.setId(id);
|
|
668
700
|
const response = await util_1.default.promisify(this.grpcManager.client.contactPayload
|
|
@@ -700,17 +732,22 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
700
732
|
realName: response.getRealName(),
|
|
701
733
|
aka: response.getAka(),
|
|
702
734
|
};
|
|
703
|
-
|
|
704
|
-
|
|
735
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.Contact, id, gen)) {
|
|
736
|
+
await this._payloadStore.contact?.set(id, payload);
|
|
737
|
+
this.log.silly('PuppetService', 'contactRawPayload(%s) cache SET', id);
|
|
738
|
+
}
|
|
739
|
+
else {
|
|
740
|
+
this.log.silly('PuppetService', 'contactRawPayload(%s) cache SET skipped: dirty landed during raw fetch', id);
|
|
741
|
+
}
|
|
705
742
|
return payload;
|
|
706
743
|
}
|
|
707
744
|
async contactRawPayloadParser(payload) {
|
|
708
|
-
// log.silly('PuppetService', 'contactRawPayloadParser({id:%s})', payload.id)
|
|
745
|
+
// this.log.silly('PuppetService', 'contactRawPayloadParser({id:%s})', payload.id)
|
|
709
746
|
// passthrough
|
|
710
747
|
return payload;
|
|
711
748
|
}
|
|
712
749
|
async batchContactRawPayload(contactIdList) {
|
|
713
|
-
|
|
750
|
+
this.log.verbose('PuppetService', 'batchContactRawPayload(%s)', contactIdList);
|
|
714
751
|
const result = new Map();
|
|
715
752
|
const contactIdSet = new Set(contactIdList);
|
|
716
753
|
const needGetSet = new Set();
|
|
@@ -725,6 +762,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
725
762
|
}
|
|
726
763
|
if (needGetSet.size > 0) {
|
|
727
764
|
try {
|
|
765
|
+
// Snapshot each id's gen before the batch fetch; write-backs below
|
|
766
|
+
// are validated per id so a dirty on one contact mid-flight only
|
|
767
|
+
// skips that contact's stale write, not the whole batch.
|
|
768
|
+
const genSnap = new Map();
|
|
769
|
+
for (const contactId of needGetSet) {
|
|
770
|
+
genSnap.set(contactId, this.cache.snapshotGen(PUPPET.types.Dirty.Contact, contactId));
|
|
771
|
+
}
|
|
728
772
|
const request = new wechaty_grpc_1.puppet.BatchContactPayloadRequest();
|
|
729
773
|
request.setIdsList(Array.from(needGetSet));
|
|
730
774
|
const response = await util_1.default.promisify(this.grpcManager.client.batchContactPayload
|
|
@@ -734,11 +778,16 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
734
778
|
const contactId = payload.getId();
|
|
735
779
|
const puppetPayload = (0, pb_payload_helper_js_1.contactPbToPayload)(payload);
|
|
736
780
|
result.set(contactId, puppetPayload);
|
|
737
|
-
|
|
781
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.Contact, contactId, genSnap.get(contactId) ?? 0)) {
|
|
782
|
+
await this._payloadStore.contact?.set(contactId, puppetPayload);
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
this.log.silly('PuppetService', 'batchContactRawPayload(%s) cache SET skipped: dirty landed during raw fetch', contactId);
|
|
786
|
+
}
|
|
738
787
|
}
|
|
739
788
|
}
|
|
740
789
|
catch (e) {
|
|
741
|
-
|
|
790
|
+
this.log.error('PuppetService', 'batchContactRawPayload(%s, %s) error: %s, use one by one method', contactIdList, needGetSet, e);
|
|
742
791
|
for (const contactId of needGetSet) {
|
|
743
792
|
const payload = await this.contactRawPayload(contactId);
|
|
744
793
|
result.set(contactId, payload);
|
|
@@ -748,7 +797,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
748
797
|
return result;
|
|
749
798
|
}
|
|
750
799
|
async contactPayloadModify(contactId, payload) {
|
|
751
|
-
|
|
800
|
+
this.log.verbose('PuppetService', 'contactPayloadModify(%s, %s)', contactId, JSON.stringify(payload));
|
|
752
801
|
const request = new wechaty_grpc_1.puppet.ContactPayloadModifyRequest();
|
|
753
802
|
request.setId(contactId);
|
|
754
803
|
if (payload.id) {
|
|
@@ -818,41 +867,41 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
818
867
|
.bind(this.grpcManager.client))(request);
|
|
819
868
|
}
|
|
820
869
|
async contactSelfName(name) {
|
|
821
|
-
|
|
870
|
+
this.log.verbose('PuppetService', 'contactSelfName(%s)', name);
|
|
822
871
|
const request = new wechaty_grpc_1.puppet.ContactSelfNameRequest();
|
|
823
872
|
request.setName(name);
|
|
824
873
|
await util_1.default.promisify(this.grpcManager.client.contactSelfName
|
|
825
874
|
.bind(this.grpcManager.client))(request);
|
|
826
875
|
}
|
|
827
876
|
async contactSelfRealName(realName) {
|
|
828
|
-
|
|
877
|
+
this.log.verbose('PuppetService', 'contactSelfRealName(%s)', realName);
|
|
829
878
|
const request = new wechaty_grpc_1.puppet.ContactSelfRealNameRequest();
|
|
830
879
|
request.setRealName(realName);
|
|
831
880
|
await util_1.default.promisify(this.grpcManager.client.contactSelfRealName
|
|
832
881
|
.bind(this.grpcManager.client))(request);
|
|
833
882
|
}
|
|
834
883
|
async contactSelfAka(aka) {
|
|
835
|
-
|
|
884
|
+
this.log.verbose('PuppetService', 'contactSelfAka(%s)', aka);
|
|
836
885
|
const request = new wechaty_grpc_1.puppet.ContactSelfAkaRequest();
|
|
837
886
|
request.setAka(aka);
|
|
838
887
|
await util_1.default.promisify(this.grpcManager.client.contactSelfAka
|
|
839
888
|
.bind(this.grpcManager.client))(request);
|
|
840
889
|
}
|
|
841
890
|
async contactSelfQRCode() {
|
|
842
|
-
|
|
891
|
+
this.log.verbose('PuppetService', 'contactSelfQRCode()');
|
|
843
892
|
const response = await util_1.default.promisify(this.grpcManager.client.contactSelfQRCode
|
|
844
893
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.ContactSelfQRCodeRequest());
|
|
845
894
|
return response.getQrcode();
|
|
846
895
|
}
|
|
847
896
|
async contactSelfSignature(signature) {
|
|
848
|
-
|
|
897
|
+
this.log.verbose('PuppetService', 'contactSelfSignature(%s)', signature);
|
|
849
898
|
const request = new wechaty_grpc_1.puppet.ContactSelfSignatureRequest();
|
|
850
899
|
request.setSignature(signature);
|
|
851
900
|
await util_1.default.promisify(this.grpcManager.client.contactSelfSignature
|
|
852
901
|
.bind(this.grpcManager.client))(request);
|
|
853
902
|
}
|
|
854
903
|
async contactSelfRoomAlias(roomId, alias) {
|
|
855
|
-
|
|
904
|
+
this.log.verbose('PuppetService', 'contactSelfRoomAlias(%s, %s)', roomId, alias);
|
|
856
905
|
const request = new wechaty_grpc_1.puppet.ContactSelfRoomAliasRequest();
|
|
857
906
|
request.setRoomId(roomId);
|
|
858
907
|
request.setAlias(alias);
|
|
@@ -860,7 +909,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
860
909
|
.bind(this.grpcManager.client))(request);
|
|
861
910
|
}
|
|
862
911
|
async contactDelete(contactId) {
|
|
863
|
-
|
|
912
|
+
this.log.verbose('PuppetService', 'contactDelete(%s)', contactId);
|
|
864
913
|
const request = new wechaty_grpc_1.puppet.ContactDeleteRequest();
|
|
865
914
|
request.setContactId(contactId);
|
|
866
915
|
await util_1.default.promisify(this.grpcManager.client.contactDelete
|
|
@@ -872,7 +921,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
872
921
|
*
|
|
873
922
|
*/
|
|
874
923
|
async conversationReadMark(conversationId, hasRead = true) {
|
|
875
|
-
|
|
924
|
+
this.log.verbose('PuppetService', 'conversationMarkRead(%s, %s)', conversationId, hasRead);
|
|
876
925
|
const request = new wechaty_grpc_1.puppet.ConversationReadRequest();
|
|
877
926
|
request.setConversationId(conversationId);
|
|
878
927
|
request.setHasRead(hasRead);
|
|
@@ -885,7 +934,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
885
934
|
*
|
|
886
935
|
*/
|
|
887
936
|
async messageMiniProgram(messageId) {
|
|
888
|
-
|
|
937
|
+
this.log.verbose('PuppetService', 'messageMiniProgram(%s)', messageId);
|
|
889
938
|
const request = new wechaty_grpc_1.puppet.MessageMiniProgramRequest();
|
|
890
939
|
request.setId(messageId);
|
|
891
940
|
const response = await util_1.default.promisify(this.grpcManager.client.messageMiniProgram
|
|
@@ -904,7 +953,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
904
953
|
return payload;
|
|
905
954
|
}
|
|
906
955
|
async messageLocation(messageId) {
|
|
907
|
-
|
|
956
|
+
this.log.verbose('PuppetService', 'messageLocation(%s)', messageId);
|
|
908
957
|
const request = new wechaty_grpc_1.puppet.MessageLocationRequest();
|
|
909
958
|
request.setId(messageId);
|
|
910
959
|
const response = await util_1.default.promisify(this.grpcManager.client.messageLocation
|
|
@@ -920,7 +969,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
920
969
|
return payload;
|
|
921
970
|
}
|
|
922
971
|
async messageImage(messageId, imageType) {
|
|
923
|
-
|
|
972
|
+
this.log.verbose('PuppetService', 'messageImage(%s, %s[%s])', messageId, imageType, PUPPET.types.Image[imageType]);
|
|
924
973
|
const request = new wechaty_grpc_1.puppet.MessageImageRequest();
|
|
925
974
|
request.setId(messageId);
|
|
926
975
|
request.setType(imageType);
|
|
@@ -933,7 +982,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
933
982
|
throw new Error(`failed to get image filebox for message ${messageId}`);
|
|
934
983
|
}
|
|
935
984
|
async messageContact(messageId) {
|
|
936
|
-
|
|
985
|
+
this.log.verbose('PuppetService', 'messageContact(%s)', messageId);
|
|
937
986
|
const request = new wechaty_grpc_1.puppet.MessageContactRequest();
|
|
938
987
|
request.setId(messageId);
|
|
939
988
|
const response = await util_1.default.promisify(this.grpcManager.client.messageContact
|
|
@@ -942,7 +991,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
942
991
|
return contactId;
|
|
943
992
|
}
|
|
944
993
|
async messageChannel(messageId) {
|
|
945
|
-
|
|
994
|
+
this.log.verbose('PuppetService', 'messageChannel(%s)', messageId);
|
|
946
995
|
const request = new wechaty_grpc_1.puppet.MessageChannelRequest();
|
|
947
996
|
request.setId(messageId);
|
|
948
997
|
const response = await util_1.default.promisify(this.grpcManager.client.messageChannel
|
|
@@ -951,7 +1000,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
951
1000
|
return payload;
|
|
952
1001
|
}
|
|
953
1002
|
async messageChannelCard(messageId) {
|
|
954
|
-
|
|
1003
|
+
this.log.verbose('PuppetService', 'messageChannelCard(%s)', messageId);
|
|
955
1004
|
const request = new wechaty_grpc_1.puppet.MessageChannelCardRequest();
|
|
956
1005
|
request.setId(messageId);
|
|
957
1006
|
const response = await util_1.default.promisify(this.grpcManager.client.messageChannelCard
|
|
@@ -960,7 +1009,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
960
1009
|
return payload;
|
|
961
1010
|
}
|
|
962
1011
|
async messageCallRecord(messageId) {
|
|
963
|
-
|
|
1012
|
+
this.log.verbose('PuppetService', 'messageCallRecord(%s)', messageId);
|
|
964
1013
|
const request = new wechaty_grpc_1.puppet.MessageCallRecordRequest();
|
|
965
1014
|
request.setId(messageId);
|
|
966
1015
|
const response = await util_1.default.promisify(this.grpcManager.client.messageCallRecord
|
|
@@ -969,7 +1018,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
969
1018
|
return payload;
|
|
970
1019
|
}
|
|
971
1020
|
async callInvite(contactIds, media) {
|
|
972
|
-
|
|
1021
|
+
this.log.verbose('PuppetService', 'callInvite(%s, %s)', contactIds, media);
|
|
973
1022
|
const request = new wechaty_grpc_1.puppet.CallInviteRequest();
|
|
974
1023
|
request.setContactIdsList(contactIds);
|
|
975
1024
|
request.setMedia((0, call_media_mapping_js_1.puppetCallMediaTypeToGrpc)(media));
|
|
@@ -982,20 +1031,20 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
982
1031
|
return callId;
|
|
983
1032
|
}
|
|
984
1033
|
async callAdd(callId, contactIds) {
|
|
985
|
-
|
|
1034
|
+
this.log.verbose('PuppetService', 'callAdd(%s, %s)', callId, contactIds);
|
|
986
1035
|
const request = new wechaty_grpc_1.puppet.CallAddRequest();
|
|
987
1036
|
request.setCallId(callId);
|
|
988
1037
|
request.setContactIdsList(contactIds);
|
|
989
1038
|
await this.grpcUnary(this.grpcManager.client.callAdd, request);
|
|
990
1039
|
}
|
|
991
1040
|
async callAccept(callId) {
|
|
992
|
-
|
|
1041
|
+
this.log.verbose('PuppetService', 'callAccept(%s)', callId);
|
|
993
1042
|
const request = new wechaty_grpc_1.puppet.CallAcceptRequest();
|
|
994
1043
|
request.setCallId(callId);
|
|
995
1044
|
await this.grpcUnary(this.grpcManager.client.callAccept, request);
|
|
996
1045
|
}
|
|
997
1046
|
async callReject(callId, reason) {
|
|
998
|
-
|
|
1047
|
+
this.log.verbose('PuppetService', 'callReject(%s, %s)', callId, reason);
|
|
999
1048
|
const request = new wechaty_grpc_1.puppet.CallRejectRequest();
|
|
1000
1049
|
request.setCallId(callId);
|
|
1001
1050
|
if (reason !== undefined && reason !== '') {
|
|
@@ -1004,13 +1053,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1004
1053
|
await this.grpcUnary(this.grpcManager.client.callReject, request);
|
|
1005
1054
|
}
|
|
1006
1055
|
async callCancel(callId) {
|
|
1007
|
-
|
|
1056
|
+
this.log.verbose('PuppetService', 'callCancel(%s)', callId);
|
|
1008
1057
|
const request = new wechaty_grpc_1.puppet.CallCancelRequest();
|
|
1009
1058
|
request.setCallId(callId);
|
|
1010
1059
|
await this.grpcUnary(this.grpcManager.client.callCancel, request);
|
|
1011
1060
|
}
|
|
1012
1061
|
async callHangup(callId, reason) {
|
|
1013
|
-
|
|
1062
|
+
this.log.verbose('PuppetService', 'callHangup(%s, %s)', callId, reason);
|
|
1014
1063
|
const request = new wechaty_grpc_1.puppet.CallHangupRequest();
|
|
1015
1064
|
request.setCallId(callId);
|
|
1016
1065
|
if (reason !== undefined && reason !== '') {
|
|
@@ -1019,7 +1068,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1019
1068
|
await this.grpcUnary(this.grpcManager.client.callHangup, request);
|
|
1020
1069
|
}
|
|
1021
1070
|
async callMediaEndpoint(callId) {
|
|
1022
|
-
|
|
1071
|
+
this.log.verbose('PuppetService', 'callMediaEndpoint(%s)', callId);
|
|
1023
1072
|
const request = new wechaty_grpc_1.puppet.CallMediaEndpointRequest();
|
|
1024
1073
|
request.setCallId(callId);
|
|
1025
1074
|
const response = await util_1.default.promisify(this.grpcManager.client.callMediaEndpoint
|
|
@@ -1043,7 +1092,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1043
1092
|
return payload;
|
|
1044
1093
|
}
|
|
1045
1094
|
async callRawPayload(callId) {
|
|
1046
|
-
|
|
1095
|
+
this.log.verbose('PuppetService', 'callRawPayload(%s)', callId);
|
|
1047
1096
|
const request = new wechaty_grpc_1.puppet.CallPayloadRequest();
|
|
1048
1097
|
request.setId(callId);
|
|
1049
1098
|
const response = await util_1.default.promisify(this.grpcManager.client.callPayload
|
|
@@ -1051,6 +1100,10 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1051
1100
|
return response.toObject();
|
|
1052
1101
|
}
|
|
1053
1102
|
async callRawPayloadParser(rawPayload) {
|
|
1103
|
+
// Intentionally uses the module-level `log` instead of `this.log`: the
|
|
1104
|
+
// matching unit spec invokes this parser via `prototype.call({}, raw)` and
|
|
1105
|
+
// never binds a real PuppetService instance. Keep this `this`-free so that
|
|
1106
|
+
// contract survives the pluggable-logger migration.
|
|
1054
1107
|
config_js_1.log.verbose('PuppetService', 'callRawPayloadParser({id:%s})', rawPayload.id);
|
|
1055
1108
|
const media = (0, call_media_mapping_js_1.grpcCallTypeToPuppetMedia)(rawPayload.media);
|
|
1056
1109
|
if (media === undefined) {
|
|
@@ -1074,7 +1127,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1074
1127
|
return payload;
|
|
1075
1128
|
}
|
|
1076
1129
|
async messageChatHistory(messageId) {
|
|
1077
|
-
|
|
1130
|
+
this.log.verbose('PuppetService', 'messageChatHistory(%s)', messageId);
|
|
1078
1131
|
const request = new wechaty_grpc_1.puppet.MessageChatHistoryRequest();
|
|
1079
1132
|
request.setId(messageId);
|
|
1080
1133
|
const response = await util_1.default.promisify(this.grpcManager.client.messageChatHistory
|
|
@@ -1083,7 +1136,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1083
1136
|
return payload;
|
|
1084
1137
|
}
|
|
1085
1138
|
async messageSendMiniProgram(conversationId, miniProgramPayload) {
|
|
1086
|
-
|
|
1139
|
+
this.log.verbose('PuppetService', 'messageSendMiniProgram(%s, "%s")', conversationId, JSON.stringify(miniProgramPayload));
|
|
1087
1140
|
const request = new wechaty_grpc_1.puppet.MessageSendMiniProgramRequest();
|
|
1088
1141
|
request.setConversationId(conversationId);
|
|
1089
1142
|
const pbMiniProgramPayload = new wechaty_grpc_1.puppet.MiniProgramPayload();
|
|
@@ -1119,11 +1172,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1119
1172
|
* Deprecated: will be removed after Dec 31, 2022
|
|
1120
1173
|
*/
|
|
1121
1174
|
request.setMiniProgramDeprecated(JSON.stringify(miniProgramPayload));
|
|
1122
|
-
|
|
1175
|
+
this.log.info('PuppetService', `messageSendMiniProgram(${conversationId}, ${miniProgramPayload.description}) about to call grpc`);
|
|
1123
1176
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendMiniProgram
|
|
1124
1177
|
.bind(this.grpcManager.client))(request);
|
|
1125
1178
|
const messageId = response.getId();
|
|
1126
|
-
|
|
1179
|
+
this.log.info('PuppetService', `messageSendMiniProgram(${conversationId}, ${miniProgramPayload.description}) grpc called, messageId: ${messageId}`);
|
|
1127
1180
|
if (messageId) {
|
|
1128
1181
|
return messageId;
|
|
1129
1182
|
}
|
|
@@ -1138,7 +1191,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1138
1191
|
}
|
|
1139
1192
|
}
|
|
1140
1193
|
async messageSendLocation(conversationId, locationPayload) {
|
|
1141
|
-
|
|
1194
|
+
this.log.verbose('PuppetService', 'messageSendLocation(%s)', conversationId, JSON.stringify(locationPayload));
|
|
1142
1195
|
const request = new wechaty_grpc_1.puppet.MessageSendLocationRequest();
|
|
1143
1196
|
request.setConversationId(conversationId);
|
|
1144
1197
|
const pbLocationPayload = new wechaty_grpc_1.puppet.LocationPayload();
|
|
@@ -1148,47 +1201,47 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1148
1201
|
pbLocationPayload.setLongitude(locationPayload.longitude);
|
|
1149
1202
|
pbLocationPayload.setName(locationPayload.name);
|
|
1150
1203
|
request.setLocation(pbLocationPayload);
|
|
1151
|
-
|
|
1204
|
+
this.log.info('PuppetService', `messageSendLocation(${conversationId}, ${locationPayload.name}) about to call grpc`);
|
|
1152
1205
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendLocation
|
|
1153
1206
|
.bind(this.grpcManager.client))(request);
|
|
1154
1207
|
const id = response.getId();
|
|
1155
|
-
|
|
1208
|
+
this.log.info('PuppetService', `messageSendMiniProgram(${conversationId}, ${locationPayload.name}) grpc called, messageId: ${id}`);
|
|
1156
1209
|
if (id) {
|
|
1157
1210
|
return id;
|
|
1158
1211
|
}
|
|
1159
1212
|
}
|
|
1160
1213
|
async messageSendChannel(conversationId, channelPayload) {
|
|
1161
|
-
|
|
1214
|
+
this.log.verbose('PuppetService', 'messageSendChannel(%s, "%s")', conversationId, JSON.stringify(channelPayload));
|
|
1162
1215
|
const request = new wechaty_grpc_1.puppet.MessageSendChannelRequest();
|
|
1163
1216
|
request.setConversationId(conversationId);
|
|
1164
1217
|
const pbChannelPayload = (0, pb_payload_helper_js_1.channelPayloadToPb)(wechaty_grpc_1.puppet, channelPayload);
|
|
1165
1218
|
request.setChannel(pbChannelPayload);
|
|
1166
|
-
|
|
1219
|
+
this.log.info('PuppetService', `messageSendChannel(${conversationId}, ${channelPayload.desc}) about to call grpc`);
|
|
1167
1220
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendChannel
|
|
1168
1221
|
.bind(this.grpcManager.client))(request);
|
|
1169
1222
|
const messageId = response.getId();
|
|
1170
|
-
|
|
1223
|
+
this.log.info('PuppetService', `messageSendChannel(${conversationId}, ${channelPayload.desc}) grpc called, messageId: ${messageId}`);
|
|
1171
1224
|
if (messageId) {
|
|
1172
1225
|
return messageId;
|
|
1173
1226
|
}
|
|
1174
1227
|
}
|
|
1175
1228
|
async messageSendChannelCard(conversationId, channelCardPayload) {
|
|
1176
|
-
|
|
1229
|
+
this.log.verbose('PuppetService', 'messageSendChannelCard(%s, "%s")', conversationId, JSON.stringify(channelCardPayload));
|
|
1177
1230
|
const request = new wechaty_grpc_1.puppet.MessageSendChannelCardRequest();
|
|
1178
1231
|
request.setConversationId(conversationId);
|
|
1179
1232
|
const pbChannelCardPayload = (0, pb_payload_helper_js_1.channelCardPayloadToPb)(wechaty_grpc_1.puppet, channelCardPayload);
|
|
1180
1233
|
request.setChannelCard(pbChannelCardPayload);
|
|
1181
|
-
|
|
1234
|
+
this.log.info('PuppetService', `messageSendChannelCard(${conversationId}, ${channelCardPayload.nickname}) about to call grpc`);
|
|
1182
1235
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendChannelCard
|
|
1183
1236
|
.bind(this.grpcManager.client))(request);
|
|
1184
1237
|
const messageId = response.getId();
|
|
1185
|
-
|
|
1238
|
+
this.log.info('PuppetService', `messageSendChannelCard(${conversationId}, ${channelCardPayload.nickname}) grpc called, messageId: ${messageId}`);
|
|
1186
1239
|
if (messageId) {
|
|
1187
1240
|
return messageId;
|
|
1188
1241
|
}
|
|
1189
1242
|
}
|
|
1190
1243
|
async messageRecall(messageId) {
|
|
1191
|
-
|
|
1244
|
+
this.log.verbose('PuppetService', 'messageRecall(%s)', messageId);
|
|
1192
1245
|
const request = new wechaty_grpc_1.puppet.MessageRecallRequest();
|
|
1193
1246
|
request.setId(messageId);
|
|
1194
1247
|
const response = await util_1.default.promisify(this.grpcManager.client.messageRecall
|
|
@@ -1196,7 +1249,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1196
1249
|
return response.getSuccess();
|
|
1197
1250
|
}
|
|
1198
1251
|
async messageFile(id) {
|
|
1199
|
-
|
|
1252
|
+
this.log.verbose('PuppetService', 'messageFile(%s)', id);
|
|
1200
1253
|
const request = new wechaty_grpc_1.puppet.MessageFileRequest();
|
|
1201
1254
|
request.setId(id);
|
|
1202
1255
|
const response = await util_1.default.promisify(this.grpcManager.client.messageFile
|
|
@@ -1208,7 +1261,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1208
1261
|
throw new Error(`failed to get filebox for message ${id}`);
|
|
1209
1262
|
}
|
|
1210
1263
|
async messageVoice(id) {
|
|
1211
|
-
|
|
1264
|
+
this.log.verbose('PuppetService', 'messageVoice(%s)', id);
|
|
1212
1265
|
const request = new wechaty_grpc_1.puppet.MessageVoiceRequest();
|
|
1213
1266
|
request.setId(id);
|
|
1214
1267
|
const response = await util_1.default.promisify(this.grpcManager.client.messageVoice
|
|
@@ -1220,7 +1273,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1220
1273
|
throw new Error(`failed to get voice filebox for message ${id}`);
|
|
1221
1274
|
}
|
|
1222
1275
|
async messageVoiceText(id) {
|
|
1223
|
-
|
|
1276
|
+
this.log.verbose('PuppetService', 'messageVoiceText(%s)', id);
|
|
1224
1277
|
const request = new wechaty_grpc_1.puppet.MessageVoiceTextRequest();
|
|
1225
1278
|
request.setId(id);
|
|
1226
1279
|
const response = await util_1.default.promisify(this.grpcManager.client.messageVoiceText
|
|
@@ -1231,7 +1284,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1231
1284
|
};
|
|
1232
1285
|
}
|
|
1233
1286
|
async messagePreview(id) {
|
|
1234
|
-
|
|
1287
|
+
this.log.verbose('PuppetService', 'messagePreview(%s)', id);
|
|
1235
1288
|
const request = new wechaty_grpc_1.puppet.MessagePreviewRequest();
|
|
1236
1289
|
request.setId(id);
|
|
1237
1290
|
const response = await util_1.default.promisify(this.grpcManager.client.messagePreview
|
|
@@ -1243,7 +1296,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1243
1296
|
return undefined;
|
|
1244
1297
|
}
|
|
1245
1298
|
async messageForward(conversationId, messageIds) {
|
|
1246
|
-
|
|
1299
|
+
this.log.verbose('PuppetService', 'messageForward(%s, %s)', conversationId, messageIds);
|
|
1247
1300
|
const request = new wechaty_grpc_1.puppet.MessageForwardRequest();
|
|
1248
1301
|
request.setConversationId(conversationId);
|
|
1249
1302
|
if (Array.isArray(messageIds)) {
|
|
@@ -1255,11 +1308,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1255
1308
|
else {
|
|
1256
1309
|
request.setMessageId(messageIds);
|
|
1257
1310
|
}
|
|
1258
|
-
|
|
1311
|
+
this.log.info('PuppetService', `messageForward(${conversationId}, ${messageIds}) about to call grpc`);
|
|
1259
1312
|
const response = await util_1.default.promisify(this.grpcManager.client.messageForward
|
|
1260
1313
|
.bind(this.grpcManager.client))(request);
|
|
1261
1314
|
const forwardedMessageId = response.getId();
|
|
1262
|
-
|
|
1315
|
+
this.log.info('PuppetService', `messageForward(${conversationId}, ${messageIds}) grpc called, messageId: ${forwardedMessageId}`);
|
|
1263
1316
|
if (forwardedMessageId) {
|
|
1264
1317
|
return forwardedMessageId;
|
|
1265
1318
|
}
|
|
@@ -1274,10 +1327,10 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1274
1327
|
}
|
|
1275
1328
|
}
|
|
1276
1329
|
async messageRawPayload(id) {
|
|
1277
|
-
|
|
1330
|
+
this.log.verbose('PuppetService', 'messageRawPayload(%s)', id);
|
|
1278
1331
|
// const cachedPayload = await this.payloadStore.message?.get(id)
|
|
1279
1332
|
// if (cachedPayload) {
|
|
1280
|
-
// log.silly('PuppetService', 'messageRawPayload(%s) cache HIT', id)
|
|
1333
|
+
// this.log.silly('PuppetService', 'messageRawPayload(%s) cache HIT', id)
|
|
1281
1334
|
// return cachedPayload
|
|
1282
1335
|
// }
|
|
1283
1336
|
const request = new wechaty_grpc_1.puppet.MessagePayloadRequest();
|
|
@@ -1326,21 +1379,21 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1326
1379
|
break;
|
|
1327
1380
|
}
|
|
1328
1381
|
default:
|
|
1329
|
-
|
|
1382
|
+
this.log.warn('PuppetService', `unknown text content type ${type}`);
|
|
1330
1383
|
}
|
|
1331
1384
|
payload.textContent?.push(contentData);
|
|
1332
1385
|
}
|
|
1333
|
-
// log.silly('PuppetService', 'messageRawPayload(%s) cache SET', id)
|
|
1386
|
+
// this.log.silly('PuppetService', 'messageRawPayload(%s) cache SET', id)
|
|
1334
1387
|
// await this.payloadStore.message?.set(id, payload)
|
|
1335
1388
|
return payload;
|
|
1336
1389
|
}
|
|
1337
1390
|
async messageRawPayloadParser(payload) {
|
|
1338
|
-
// log.silly('PuppetService', 'messagePayload({id:%s})', payload.id)
|
|
1391
|
+
// this.log.silly('PuppetService', 'messagePayload({id:%s})', payload.id)
|
|
1339
1392
|
// passthrough
|
|
1340
1393
|
return payload;
|
|
1341
1394
|
}
|
|
1342
1395
|
async messageSendText(conversationId, text, options) {
|
|
1343
|
-
|
|
1396
|
+
this.log.verbose('PuppetService', 'messageSend(%s, %s)', conversationId, text);
|
|
1344
1397
|
let mentionIdList;
|
|
1345
1398
|
let quoteId;
|
|
1346
1399
|
if (Array.isArray(options)) {
|
|
@@ -1359,11 +1412,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1359
1412
|
if (typeof quoteId !== 'undefined') {
|
|
1360
1413
|
request.setQuoteId(quoteId);
|
|
1361
1414
|
}
|
|
1362
|
-
|
|
1415
|
+
this.log.info('PuppetService', `messageSend(${conversationId}, ${text}) about to call grpc`);
|
|
1363
1416
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendText
|
|
1364
1417
|
.bind(this.grpcManager.client))(request);
|
|
1365
1418
|
const messageId = response.getId();
|
|
1366
|
-
|
|
1419
|
+
this.log.info('PuppetService', `messageSend(${conversationId}, ${text}) grpc called, messageId: ${messageId}`);
|
|
1367
1420
|
if (messageId) {
|
|
1368
1421
|
return messageId;
|
|
1369
1422
|
}
|
|
@@ -1378,7 +1431,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1378
1431
|
}
|
|
1379
1432
|
}
|
|
1380
1433
|
async messageBatchSendText(conversationIds, text, batchTaskId) {
|
|
1381
|
-
|
|
1434
|
+
this.log.verbose('PuppetService', 'messageBatchSendText(%s)', conversationIds.join(','));
|
|
1382
1435
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendTextRequest();
|
|
1383
1436
|
request.setConversationIdsList(conversationIds);
|
|
1384
1437
|
request.setText(text);
|
|
@@ -1389,7 +1442,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1389
1442
|
return grpcBatchResultsToPayload(response);
|
|
1390
1443
|
}
|
|
1391
1444
|
async messageBatchSendFile(conversationIds, fileBox, batchTaskId) {
|
|
1392
|
-
|
|
1445
|
+
this.log.verbose('PuppetService', 'messageBatchSendFile(%s)', conversationIds.join(','));
|
|
1393
1446
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendFileRequest();
|
|
1394
1447
|
request.setConversationIdsList(conversationIds);
|
|
1395
1448
|
request.setFileBox(await this.serializeFileBox(fileBox));
|
|
@@ -1400,7 +1453,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1400
1453
|
return grpcBatchResultsToPayload(response);
|
|
1401
1454
|
}
|
|
1402
1455
|
async messageBatchForward(conversationIds, messageIds, batchTaskId) {
|
|
1403
|
-
|
|
1456
|
+
this.log.verbose('PuppetService', 'messageBatchForward(%s, %s)', conversationIds.join(','), messageIds);
|
|
1404
1457
|
const request = new wechaty_grpc_1.puppet.MessageBatchForwardRequest();
|
|
1405
1458
|
request.setConversationIdsList(conversationIds);
|
|
1406
1459
|
if (Array.isArray(messageIds)) {
|
|
@@ -1419,7 +1472,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1419
1472
|
return grpcBatchResultsToPayload(response);
|
|
1420
1473
|
}
|
|
1421
1474
|
async messageBatchSendContact(conversationIds, contactId, batchTaskId) {
|
|
1422
|
-
|
|
1475
|
+
this.log.verbose('PuppetService', 'messageBatchSendContact(%s, %s)', conversationIds.join(','), contactId);
|
|
1423
1476
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendContactRequest();
|
|
1424
1477
|
request.setConversationIdsList(conversationIds);
|
|
1425
1478
|
request.setContactId(contactId);
|
|
@@ -1430,7 +1483,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1430
1483
|
return grpcBatchResultsToPayload(response);
|
|
1431
1484
|
}
|
|
1432
1485
|
async messageBatchSendUrl(conversationIds, urlLinkPayload, batchTaskId) {
|
|
1433
|
-
|
|
1486
|
+
this.log.verbose('PuppetService', 'messageBatchSendUrl(%s)', conversationIds.join(','));
|
|
1434
1487
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendUrlRequest();
|
|
1435
1488
|
request.setConversationIdsList(conversationIds);
|
|
1436
1489
|
request.setUrlLink((0, pb_payload_helper_js_1.urlLinkPayloadToPb)(wechaty_grpc_1.puppet, urlLinkPayload));
|
|
@@ -1441,7 +1494,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1441
1494
|
return grpcBatchResultsToPayload(response);
|
|
1442
1495
|
}
|
|
1443
1496
|
async messageBatchSendMiniProgram(conversationIds, miniProgramPayload, batchTaskId) {
|
|
1444
|
-
|
|
1497
|
+
this.log.verbose('PuppetService', 'messageBatchSendMiniProgram(%s)', conversationIds.join(','));
|
|
1445
1498
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendMiniProgramRequest();
|
|
1446
1499
|
request.setConversationIdsList(conversationIds);
|
|
1447
1500
|
request.setMiniProgram((0, pb_payload_helper_js_1.miniProgramPayloadToPb)(wechaty_grpc_1.puppet, miniProgramPayload));
|
|
@@ -1452,7 +1505,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1452
1505
|
return grpcBatchResultsToPayload(response);
|
|
1453
1506
|
}
|
|
1454
1507
|
async messageBatchSendLocation(conversationIds, locationPayload, batchTaskId) {
|
|
1455
|
-
|
|
1508
|
+
this.log.verbose('PuppetService', 'messageBatchSendLocation(%s)', conversationIds.join(','));
|
|
1456
1509
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendLocationRequest();
|
|
1457
1510
|
request.setConversationIdsList(conversationIds);
|
|
1458
1511
|
request.setLocation((0, pb_payload_helper_js_1.locationPayloadToPb)(wechaty_grpc_1.puppet, locationPayload));
|
|
@@ -1463,7 +1516,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1463
1516
|
return grpcBatchResultsToPayload(response);
|
|
1464
1517
|
}
|
|
1465
1518
|
async messageBatchSendChannel(conversationIds, channelPayload, batchTaskId) {
|
|
1466
|
-
|
|
1519
|
+
this.log.verbose('PuppetService', 'messageBatchSendChannel(%s)', conversationIds.join(','));
|
|
1467
1520
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendChannelRequest();
|
|
1468
1521
|
request.setConversationIdsList(conversationIds);
|
|
1469
1522
|
request.setChannel((0, pb_payload_helper_js_1.channelPayloadToPb)(wechaty_grpc_1.puppet, channelPayload));
|
|
@@ -1474,7 +1527,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1474
1527
|
return grpcBatchResultsToPayload(response);
|
|
1475
1528
|
}
|
|
1476
1529
|
async messageBatchSendChannelCard(conversationIds, channelCardPayload, batchTaskId) {
|
|
1477
|
-
|
|
1530
|
+
this.log.verbose('PuppetService', 'messageBatchSendChannelCard(%s)', conversationIds.join(','));
|
|
1478
1531
|
const request = new wechaty_grpc_1.puppet.MessageBatchSendChannelCardRequest();
|
|
1479
1532
|
request.setConversationIdsList(conversationIds);
|
|
1480
1533
|
request.setChannelCard((0, pb_payload_helper_js_1.channelCardPayloadToPb)(wechaty_grpc_1.puppet, channelCardPayload));
|
|
@@ -1485,16 +1538,16 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1485
1538
|
return grpcBatchResultsToPayload(response);
|
|
1486
1539
|
}
|
|
1487
1540
|
async messageSendFile(conversationId, fileBox) {
|
|
1488
|
-
|
|
1541
|
+
this.log.verbose('PuppetService', 'messageSendFile(%s, %s)', conversationId, fileBox);
|
|
1489
1542
|
const request = new wechaty_grpc_1.puppet.MessageSendFileRequest();
|
|
1490
1543
|
request.setConversationId(conversationId);
|
|
1491
1544
|
const serializedFileBox = await this.serializeFileBox(fileBox);
|
|
1492
1545
|
request.setFileBox(serializedFileBox);
|
|
1493
|
-
|
|
1546
|
+
this.log.info('PuppetService', `messageSendFile(${conversationId}, ${fileBox}) about to call grpc`);
|
|
1494
1547
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendFile
|
|
1495
1548
|
.bind(this.grpcManager.client))(request);
|
|
1496
1549
|
const messageId = response.getId();
|
|
1497
|
-
|
|
1550
|
+
this.log.info('PuppetService', `messageSendFile(${conversationId}, ${fileBox}) grpc called, messageId: ${messageId}`);
|
|
1498
1551
|
if (messageId) {
|
|
1499
1552
|
return messageId;
|
|
1500
1553
|
}
|
|
@@ -1509,15 +1562,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1509
1562
|
}
|
|
1510
1563
|
}
|
|
1511
1564
|
async messageSendContact(conversationId, contactId) {
|
|
1512
|
-
|
|
1565
|
+
this.log.verbose('PuppetService', 'messageSend("%s", %s)', conversationId, contactId);
|
|
1513
1566
|
const request = new wechaty_grpc_1.puppet.MessageSendContactRequest();
|
|
1514
1567
|
request.setConversationId(conversationId);
|
|
1515
1568
|
request.setContactId(contactId);
|
|
1516
|
-
|
|
1569
|
+
this.log.info('PuppetService', `messageSendContact(${conversationId}, ${contactId}) about to call grpc`);
|
|
1517
1570
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendContact
|
|
1518
1571
|
.bind(this.grpcManager.client))(request);
|
|
1519
1572
|
const messageId = response.getId();
|
|
1520
|
-
|
|
1573
|
+
this.log.info('PuppetService', `messageSendContact(${conversationId}, ${contactId}) grpc called, messageId: ${messageId}`);
|
|
1521
1574
|
if (messageId) {
|
|
1522
1575
|
return messageId;
|
|
1523
1576
|
}
|
|
@@ -1532,7 +1585,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1532
1585
|
}
|
|
1533
1586
|
}
|
|
1534
1587
|
async messageSendUrl(conversationId, urlLinkPayload) {
|
|
1535
|
-
|
|
1588
|
+
this.log.verbose('PuppetService', 'messageSendUrl("%s", %s)', conversationId, JSON.stringify(urlLinkPayload));
|
|
1536
1589
|
const request = new wechaty_grpc_1.puppet.MessageSendUrlRequest();
|
|
1537
1590
|
request.setConversationId(conversationId);
|
|
1538
1591
|
const pbUrlLinkPayload = new wechaty_grpc_1.puppet.UrlLinkPayload();
|
|
@@ -1547,11 +1600,11 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1547
1600
|
request.setUrlLink(pbUrlLinkPayload);
|
|
1548
1601
|
// Deprecated: will be removed after Dec 31, 2022
|
|
1549
1602
|
request.setUrlLinkDeprecated(JSON.stringify(urlLinkPayload));
|
|
1550
|
-
|
|
1603
|
+
this.log.info('PuppetService', `messageSendUrl(${conversationId}, ${urlLinkPayload}) about to call grpc`);
|
|
1551
1604
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendUrl
|
|
1552
1605
|
.bind(this.grpcManager.client))(request);
|
|
1553
1606
|
const messageId = response.getId();
|
|
1554
|
-
|
|
1607
|
+
this.log.info('PuppetService', `messageSendUrl(${conversationId}, ${urlLinkPayload}) grpc called, messageId: ${messageId}`);
|
|
1555
1608
|
if (messageId) {
|
|
1556
1609
|
return messageId;
|
|
1557
1610
|
}
|
|
@@ -1566,22 +1619,22 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1566
1619
|
}
|
|
1567
1620
|
}
|
|
1568
1621
|
async messageSendPost(conversationId, postPayload) {
|
|
1569
|
-
|
|
1622
|
+
this.log.verbose('PuppetService', 'messageSendPost("%s", %s)', conversationId, JSON.stringify(postPayload));
|
|
1570
1623
|
const request = new wechaty_grpc_1.puppet.MessageSendPostRequest();
|
|
1571
1624
|
const post = await (0, pb_payload_helper_js_1.postPayloadToPb)(wechaty_grpc_1.puppet, postPayload, this.serializeFileBox.bind(this));
|
|
1572
1625
|
request.setContent(post);
|
|
1573
1626
|
request.setConversationId(conversationId);
|
|
1574
|
-
|
|
1627
|
+
this.log.info('PuppetService', `messageSendPost(${conversationId}, ${postPayload}) about to call grpc`);
|
|
1575
1628
|
const response = await util_1.default.promisify(this.grpcManager.client.messageSendPost
|
|
1576
1629
|
.bind(this.grpcManager.client))(request);
|
|
1577
1630
|
const messageId = response.getId();
|
|
1578
|
-
|
|
1631
|
+
this.log.info('PuppetService', `messageSendPost(${conversationId}, ${postPayload}) grpc called, messageId: ${messageId}`);
|
|
1579
1632
|
if (messageId) {
|
|
1580
1633
|
return messageId;
|
|
1581
1634
|
}
|
|
1582
1635
|
}
|
|
1583
1636
|
async messageUrl(messageId) {
|
|
1584
|
-
|
|
1637
|
+
this.log.verbose('PuppetService', 'messageUrl(%s)', messageId);
|
|
1585
1638
|
const request = new wechaty_grpc_1.puppet.MessageUrlRequest();
|
|
1586
1639
|
request.setId(messageId);
|
|
1587
1640
|
const response = await util_1.default.promisify(this.grpcManager.client.messageUrl
|
|
@@ -1600,7 +1653,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1600
1653
|
return payload;
|
|
1601
1654
|
}
|
|
1602
1655
|
async getMessageBroadcastTarget() {
|
|
1603
|
-
|
|
1656
|
+
this.log.verbose('PuppetService', 'getMessageBroadcastTarget()');
|
|
1604
1657
|
const request = new wechaty_grpc_1.puppet.GetMessageBroadcastTargetRequest();
|
|
1605
1658
|
const response = await util_1.default.promisify(this.grpcManager.client.getMessageBroadcastTarget.bind(this.grpcManager.client))(request);
|
|
1606
1659
|
return {
|
|
@@ -1609,7 +1662,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1609
1662
|
};
|
|
1610
1663
|
}
|
|
1611
1664
|
async createMessageBroadcast(targets, content) {
|
|
1612
|
-
|
|
1665
|
+
this.log.verbose('PuppetService', 'createMessageBroadcast()');
|
|
1613
1666
|
if (!PUPPET.payloads.isPostClient(content)) {
|
|
1614
1667
|
throw new Error('can only create broadcast with client post');
|
|
1615
1668
|
}
|
|
@@ -1621,7 +1674,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1621
1674
|
return response.getId();
|
|
1622
1675
|
}
|
|
1623
1676
|
async getMessageBroadcastStatus(id) {
|
|
1624
|
-
|
|
1677
|
+
this.log.verbose('PuppetService', 'getMessageBroadcastStatus()');
|
|
1625
1678
|
const request = new wechaty_grpc_1.puppet.GetMessageBroadcastStatusRequest();
|
|
1626
1679
|
request.setId(id);
|
|
1627
1680
|
const response = await util_1.default.promisify(this.grpcManager.client.getMessageBroadcastStatus.bind(this.grpcManager.client))(request);
|
|
@@ -1645,12 +1698,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1645
1698
|
*
|
|
1646
1699
|
*/
|
|
1647
1700
|
async roomRawPayload(id) {
|
|
1648
|
-
|
|
1701
|
+
this.log.verbose('PuppetService', 'roomRawPayload(%s)', id);
|
|
1649
1702
|
const cachedPayload = await this._payloadStore.room?.get(id);
|
|
1650
1703
|
if (cachedPayload) {
|
|
1651
|
-
|
|
1704
|
+
this.log.silly('PuppetService', 'roomRawPayload(%s) cache HIT', id);
|
|
1652
1705
|
return cachedPayload;
|
|
1653
1706
|
}
|
|
1707
|
+
// Snapshot the gen before the raw fetch so a dirty that lands while
|
|
1708
|
+
// the gRPC round-trip is in flight makes the write-back below stale.
|
|
1709
|
+
const gen = this.cache.snapshotGen(PUPPET.types.Dirty.Room, id);
|
|
1654
1710
|
const request = new wechaty_grpc_1.puppet.RoomPayloadRequest();
|
|
1655
1711
|
request.setId(id);
|
|
1656
1712
|
const response = await util_1.default.promisify(this.grpcManager.client.roomPayload
|
|
@@ -1671,17 +1727,22 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1671
1727
|
if (createTime) {
|
|
1672
1728
|
payload.createTime = (0, timestamp_js_1.millisecondsFromTimestamp)(createTime);
|
|
1673
1729
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1730
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.Room, id, gen)) {
|
|
1731
|
+
await this._payloadStore.room?.set(id, payload);
|
|
1732
|
+
this.log.silly('PuppetService', 'roomRawPayload(%s) cache SET', id);
|
|
1733
|
+
}
|
|
1734
|
+
else {
|
|
1735
|
+
this.log.silly('PuppetService', 'roomRawPayload(%s) cache SET skipped: dirty landed during raw fetch', id);
|
|
1736
|
+
}
|
|
1676
1737
|
return payload;
|
|
1677
1738
|
}
|
|
1678
1739
|
async roomRawPayloadParser(payload) {
|
|
1679
|
-
// log.silly('PuppetService', 'roomRawPayloadParser({id:%s})', payload.id)
|
|
1740
|
+
// this.log.silly('PuppetService', 'roomRawPayloadParser({id:%s})', payload.id)
|
|
1680
1741
|
// passthrough
|
|
1681
1742
|
return payload;
|
|
1682
1743
|
}
|
|
1683
1744
|
async batchRoomRawPayload(roomIdList) {
|
|
1684
|
-
|
|
1745
|
+
this.log.verbose('PuppetService', 'batchRoomRawPayload(%s)', roomIdList);
|
|
1685
1746
|
const result = new Map();
|
|
1686
1747
|
const roomIdSet = new Set(roomIdList);
|
|
1687
1748
|
const needGetSet = new Set();
|
|
@@ -1696,6 +1757,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1696
1757
|
}
|
|
1697
1758
|
if (needGetSet.size > 0) {
|
|
1698
1759
|
try {
|
|
1760
|
+
// Snapshot each id's gen before the batch fetch; write-backs below
|
|
1761
|
+
// are validated per id so a dirty on one room mid-flight only skips
|
|
1762
|
+
// that room's stale write, not the whole batch.
|
|
1763
|
+
const genSnap = new Map();
|
|
1764
|
+
for (const roomId of needGetSet) {
|
|
1765
|
+
genSnap.set(roomId, this.cache.snapshotGen(PUPPET.types.Dirty.Room, roomId));
|
|
1766
|
+
}
|
|
1699
1767
|
const request = new wechaty_grpc_1.puppet.BatchRoomPayloadRequest();
|
|
1700
1768
|
request.setIdsList(Array.from(needGetSet));
|
|
1701
1769
|
const response = await util_1.default.promisify(this.grpcManager.client.batchRoomPayload
|
|
@@ -1720,11 +1788,16 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1720
1788
|
puppetPayload.createTime = (0, timestamp_js_1.millisecondsFromTimestamp)(createTime);
|
|
1721
1789
|
}
|
|
1722
1790
|
result.set(roomId, puppetPayload);
|
|
1723
|
-
|
|
1791
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.Room, roomId, genSnap.get(roomId) ?? 0)) {
|
|
1792
|
+
await this._payloadStore.room?.set(roomId, puppetPayload);
|
|
1793
|
+
}
|
|
1794
|
+
else {
|
|
1795
|
+
this.log.silly('PuppetService', 'batchRoomRawPayload(%s) cache SET skipped: dirty landed during raw fetch', roomId);
|
|
1796
|
+
}
|
|
1724
1797
|
}
|
|
1725
1798
|
}
|
|
1726
1799
|
catch (e) {
|
|
1727
|
-
|
|
1800
|
+
this.log.error('PuppetService', 'batchRoomRawPayload(%s, %s) error: %s, use one by one method', roomIdList, needGetSet, e);
|
|
1728
1801
|
for (const roomId of needGetSet) {
|
|
1729
1802
|
const payload = await this.roomRawPayload(roomId);
|
|
1730
1803
|
result.set(roomId, payload);
|
|
@@ -1734,13 +1807,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1734
1807
|
return result;
|
|
1735
1808
|
}
|
|
1736
1809
|
async roomList() {
|
|
1737
|
-
|
|
1810
|
+
this.log.verbose('PuppetService', 'roomList()');
|
|
1738
1811
|
const response = await util_1.default.promisify(this.grpcManager.client.roomList
|
|
1739
1812
|
.bind(this.grpcManager.client))(new wechaty_grpc_1.puppet.RoomListRequest());
|
|
1740
1813
|
return response.getIdsList();
|
|
1741
1814
|
}
|
|
1742
1815
|
async roomDel(roomId, contactIds) {
|
|
1743
|
-
|
|
1816
|
+
this.log.verbose('PuppetService', 'roomDel(%s, %s)', roomId, contactIds);
|
|
1744
1817
|
const request = new wechaty_grpc_1.puppet.RoomDelRequest();
|
|
1745
1818
|
request.setId(roomId);
|
|
1746
1819
|
if (Array.isArray(contactIds)) {
|
|
@@ -1756,7 +1829,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1756
1829
|
.bind(this.grpcManager.client))(request);
|
|
1757
1830
|
}
|
|
1758
1831
|
async roomDelV2(roomId, contactIds) {
|
|
1759
|
-
|
|
1832
|
+
this.log.verbose('PuppetService', 'roomDelV2(%s, %s)', roomId, contactIds);
|
|
1760
1833
|
const request = new wechaty_grpc_1.puppet.RoomDelV2Request();
|
|
1761
1834
|
request.setId(roomId);
|
|
1762
1835
|
request.setContactIdsList(contactIds);
|
|
@@ -1769,7 +1842,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1769
1842
|
};
|
|
1770
1843
|
}
|
|
1771
1844
|
async roomAvatar(roomId) {
|
|
1772
|
-
|
|
1845
|
+
this.log.verbose('PuppetService', 'roomAvatar(%s)', roomId);
|
|
1773
1846
|
const request = new wechaty_grpc_1.puppet.RoomAvatarRequest();
|
|
1774
1847
|
request.setId(roomId);
|
|
1775
1848
|
const response = await util_1.default.promisify(this.grpcManager.client.roomAvatar
|
|
@@ -1778,7 +1851,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1778
1851
|
return this.FileBoxUuid.fromJSON(jsonText);
|
|
1779
1852
|
}
|
|
1780
1853
|
async roomAdd(roomId, contactId, inviteOnly, quoteIds) {
|
|
1781
|
-
|
|
1854
|
+
this.log.verbose('PuppetService', 'roomAdd(%s, %s)', roomId, contactId);
|
|
1782
1855
|
const request = new wechaty_grpc_1.puppet.RoomAddRequest();
|
|
1783
1856
|
request.setId(roomId);
|
|
1784
1857
|
if (Array.isArray(contactId)) {
|
|
@@ -1793,7 +1866,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1793
1866
|
.bind(this.grpcManager.client))(request);
|
|
1794
1867
|
}
|
|
1795
1868
|
async roomAddV2(roomId, contactIds, inviteOnly, quoteIds) {
|
|
1796
|
-
|
|
1869
|
+
this.log.verbose('PuppetService', 'roomAddV2(%s, %s)', roomId, contactIds);
|
|
1797
1870
|
const request = new wechaty_grpc_1.puppet.RoomAddV2Request();
|
|
1798
1871
|
request.setId(roomId);
|
|
1799
1872
|
request.setContactIdsList(contactIds);
|
|
@@ -1808,7 +1881,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1808
1881
|
};
|
|
1809
1882
|
}
|
|
1810
1883
|
async roomTopic(roomId, topic) {
|
|
1811
|
-
|
|
1884
|
+
this.log.verbose('PuppetService', 'roomTopic(%s, %s)', roomId, topic);
|
|
1812
1885
|
/**
|
|
1813
1886
|
* Get
|
|
1814
1887
|
*/
|
|
@@ -1846,7 +1919,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1846
1919
|
.bind(this.grpcManager.client))(request);
|
|
1847
1920
|
}
|
|
1848
1921
|
async roomRemark(roomId, remark) {
|
|
1849
|
-
|
|
1922
|
+
this.log.verbose('PuppetService', 'roomRemark(%s)', roomId);
|
|
1850
1923
|
const request = new wechaty_grpc_1.puppet.RoomRemarkRequest();
|
|
1851
1924
|
request.setId(roomId);
|
|
1852
1925
|
request.setRemark(remark);
|
|
@@ -1854,7 +1927,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1854
1927
|
.bind(this.grpcManager.client))(request);
|
|
1855
1928
|
}
|
|
1856
1929
|
async roomCreate(contactIdList, topic) {
|
|
1857
|
-
|
|
1930
|
+
this.log.verbose('PuppetService', 'roomCreate(%s, %s)', contactIdList, topic);
|
|
1858
1931
|
const request = new wechaty_grpc_1.puppet.RoomCreateRequest();
|
|
1859
1932
|
request.setContactIdsList(contactIdList);
|
|
1860
1933
|
request.setTopic(topic);
|
|
@@ -1863,14 +1936,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1863
1936
|
return response.getId();
|
|
1864
1937
|
}
|
|
1865
1938
|
async roomQuit(roomId) {
|
|
1866
|
-
|
|
1939
|
+
this.log.verbose('PuppetService', 'roomQuit(%s)', roomId);
|
|
1867
1940
|
const request = new wechaty_grpc_1.puppet.RoomQuitRequest();
|
|
1868
1941
|
request.setId(roomId);
|
|
1869
1942
|
await util_1.default.promisify(this.grpcManager.client.roomQuit
|
|
1870
1943
|
.bind(this.grpcManager.client))(request);
|
|
1871
1944
|
}
|
|
1872
1945
|
async roomQRCode(roomId) {
|
|
1873
|
-
|
|
1946
|
+
this.log.verbose('PuppetService', 'roomQRCode(%s)', roomId);
|
|
1874
1947
|
const request = new wechaty_grpc_1.puppet.RoomQRCodeRequest();
|
|
1875
1948
|
request.setId(roomId);
|
|
1876
1949
|
const response = await util_1.default.promisify(this.grpcManager.client.roomQRCode
|
|
@@ -1878,7 +1951,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1878
1951
|
return response.getQrcode();
|
|
1879
1952
|
}
|
|
1880
1953
|
async roomParseDynamicQRCode(url) {
|
|
1881
|
-
|
|
1954
|
+
this.log.verbose('PuppetService', 'roomParseDynamicQRCode(%s)', url);
|
|
1882
1955
|
const request = new wechaty_grpc_1.puppet.RoomParseDynamicQRCodeRequest();
|
|
1883
1956
|
request.setUrl(url);
|
|
1884
1957
|
const response = await util_1.default.promisify(this.grpcManager.client.roomParseDynamicQRCode
|
|
@@ -1890,7 +1963,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1890
1963
|
};
|
|
1891
1964
|
}
|
|
1892
1965
|
async roomMemberList(roomId) {
|
|
1893
|
-
|
|
1966
|
+
this.log.verbose('PuppetService', 'roomMemberList(%s)', roomId);
|
|
1894
1967
|
const request = new wechaty_grpc_1.puppet.RoomMemberListRequest();
|
|
1895
1968
|
request.setId(roomId);
|
|
1896
1969
|
const response = await util_1.default.promisify(this.grpcManager.client.roomMemberList
|
|
@@ -1898,11 +1971,17 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1898
1971
|
return response.getMemberIdsList();
|
|
1899
1972
|
}
|
|
1900
1973
|
async roomMemberRawPayload(roomId, contactId) {
|
|
1901
|
-
|
|
1974
|
+
this.log.verbose('PuppetService', 'roomMemberRawPayload(%s, %s)', roomId, contactId);
|
|
1975
|
+
// Row-level read-modify-write: the write-back merges the fetched
|
|
1976
|
+
// member into the existing row, so snapshot the room-level gen before
|
|
1977
|
+
// even reading the row. A room-level dirty (bare roomId, or the
|
|
1978
|
+
// room-level bump a compound RoomMember dirty triggers) that lands
|
|
1979
|
+
// anywhere in this window then skips the merge write-back.
|
|
1980
|
+
const roomGen = this.cache.snapshotGen(PUPPET.types.Dirty.RoomMember, roomId);
|
|
1902
1981
|
const cachedPayload = await this._payloadStore.roomMember?.get(roomId);
|
|
1903
1982
|
const cachedRoomMemberPayload = cachedPayload && cachedPayload[contactId];
|
|
1904
1983
|
if (cachedRoomMemberPayload) {
|
|
1905
|
-
|
|
1984
|
+
this.log.silly('PuppetService', 'roomMemberRawPayload(%s, %s) cache HIT', roomId, contactId);
|
|
1906
1985
|
return cachedRoomMemberPayload;
|
|
1907
1986
|
}
|
|
1908
1987
|
const request = new wechaty_grpc_1.puppet.RoomMemberPayloadRequest();
|
|
@@ -1920,23 +1999,32 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1920
1999
|
joinScene: response.getJoinScene(),
|
|
1921
2000
|
joinTime: response.getJoinTime(),
|
|
1922
2001
|
};
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
2002
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.RoomMember, roomId, roomGen)) {
|
|
2003
|
+
await this._payloadStore.roomMember?.set(roomId, {
|
|
2004
|
+
...cachedPayload,
|
|
2005
|
+
[contactId]: payload,
|
|
2006
|
+
});
|
|
2007
|
+
this.log.silly('PuppetService', 'roomMemberRawPayload(%s, %s) cache SET', roomId, contactId);
|
|
2008
|
+
}
|
|
2009
|
+
else {
|
|
2010
|
+
this.log.silly('PuppetService', 'roomMemberRawPayload(%s, %s) cache SET skipped: dirty landed during raw fetch', roomId, contactId);
|
|
2011
|
+
}
|
|
1928
2012
|
return payload;
|
|
1929
2013
|
}
|
|
1930
2014
|
async roomMemberRawPayloadParser(payload) {
|
|
1931
|
-
// log.silly('PuppetService', 'roomMemberRawPayloadParser({id:%s})', payload.id)
|
|
2015
|
+
// this.log.silly('PuppetService', 'roomMemberRawPayloadParser({id:%s})', payload.id)
|
|
1932
2016
|
// passthrough
|
|
1933
2017
|
return payload;
|
|
1934
2018
|
}
|
|
1935
2019
|
async batchRoomMemberRawPayload(roomId, contactIdList) {
|
|
1936
|
-
|
|
2020
|
+
this.log.verbose('PuppetService', 'batchRoomMemberRawPayload(%s, %s)', roomId, contactIdList);
|
|
1937
2021
|
const result = new Map();
|
|
1938
2022
|
const contactIdSet = new Set(contactIdList);
|
|
1939
2023
|
let needGetSet = new Set();
|
|
2024
|
+
// Row-level read-modify-write keyed by roomId: snapshot the room-level
|
|
2025
|
+
// gen before reading the row so a dirty landing anywhere in the window
|
|
2026
|
+
// skips the merged write-back.
|
|
2027
|
+
const roomGen = this.cache.snapshotGen(PUPPET.types.Dirty.RoomMember, roomId);
|
|
1940
2028
|
const cachedPayload = await this._payloadStore.roomMember?.get(roomId) || {};
|
|
1941
2029
|
if (Object.keys(cachedPayload).length > 0) {
|
|
1942
2030
|
for (const contactId of contactIdSet) {
|
|
@@ -1966,10 +2054,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1966
2054
|
result.set(contactId, puppetPayload);
|
|
1967
2055
|
cachedPayload[contactId] = puppetPayload;
|
|
1968
2056
|
}
|
|
1969
|
-
|
|
2057
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.RoomMember, roomId, roomGen)) {
|
|
2058
|
+
await this._payloadStore.roomMember?.set(roomId, cachedPayload);
|
|
2059
|
+
}
|
|
2060
|
+
else {
|
|
2061
|
+
this.log.silly('PuppetService', 'batchRoomMemberRawPayload(%s) cache SET skipped: dirty landed during raw fetch', roomId);
|
|
2062
|
+
}
|
|
1970
2063
|
}
|
|
1971
2064
|
catch (e) {
|
|
1972
|
-
|
|
2065
|
+
this.log.error('PuppetService', 'batchRoomMemberRawPayload(%s, %s) error: %s, use one by one method', roomId, needGetSet, e);
|
|
1973
2066
|
for (const contactId of needGetSet) {
|
|
1974
2067
|
const payload = await this.roomMemberRawPayload(roomId, contactId);
|
|
1975
2068
|
result.set(contactId, payload);
|
|
@@ -1979,7 +2072,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1979
2072
|
return result;
|
|
1980
2073
|
}
|
|
1981
2074
|
async roomAnnounce(roomId, text) {
|
|
1982
|
-
|
|
2075
|
+
this.log.verbose('PuppetService', 'roomAnnounce(%s%s)', roomId, typeof text === 'undefined'
|
|
1983
2076
|
? ''
|
|
1984
2077
|
: `, ${text}`);
|
|
1985
2078
|
/**
|
|
@@ -2020,14 +2113,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2020
2113
|
return '';
|
|
2021
2114
|
}
|
|
2022
2115
|
async roomInvitationAccept(roomInvitationId) {
|
|
2023
|
-
|
|
2116
|
+
this.log.verbose('PuppetService', 'roomInvitationAccept(%s)', roomInvitationId);
|
|
2024
2117
|
const request = new wechaty_grpc_1.puppet.RoomInvitationAcceptRequest();
|
|
2025
2118
|
request.setId(roomInvitationId);
|
|
2026
2119
|
await util_1.default.promisify(this.grpcManager.client.roomInvitationAccept
|
|
2027
2120
|
.bind(this.grpcManager.client))(request);
|
|
2028
2121
|
}
|
|
2029
2122
|
async roomInvitationAcceptByQRCode(qrcode) {
|
|
2030
|
-
|
|
2123
|
+
this.log.verbose('PuppetService', 'roomInvitationAcceptByQRCode(%s)', qrcode);
|
|
2031
2124
|
const request = new wechaty_grpc_1.puppet.RoomInvitationAcceptByQRCodeRequest();
|
|
2032
2125
|
request.setQrcode(qrcode);
|
|
2033
2126
|
const response = await util_1.default.promisify(this.grpcManager.client.roomInvitationAcceptByQRCode
|
|
@@ -2038,7 +2131,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2038
2131
|
};
|
|
2039
2132
|
}
|
|
2040
2133
|
async roomInvitationRawPayload(id) {
|
|
2041
|
-
|
|
2134
|
+
this.log.verbose('PuppetService', 'roomInvitationRawPayload(%s)', id);
|
|
2042
2135
|
const request = new wechaty_grpc_1.puppet.RoomInvitationPayloadRequest();
|
|
2043
2136
|
request.setId(id);
|
|
2044
2137
|
const response = await util_1.default.promisify(this.grpcManager.client.roomInvitationPayload
|
|
@@ -2072,12 +2165,12 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2072
2165
|
return payload;
|
|
2073
2166
|
}
|
|
2074
2167
|
async roomInvitationRawPayloadParser(payload) {
|
|
2075
|
-
// log.silly('PuppetService', 'roomInvitationRawPayloadParser({id:%s})', payload.id)
|
|
2168
|
+
// this.log.silly('PuppetService', 'roomInvitationRawPayloadParser({id:%s})', payload.id)
|
|
2076
2169
|
// passthrough
|
|
2077
2170
|
return payload;
|
|
2078
2171
|
}
|
|
2079
2172
|
async roomPermission(roomId, permission) {
|
|
2080
|
-
|
|
2173
|
+
this.log.verbose('PuppetService', 'roomPermission(%s, %s)', roomId, JSON.stringify(permission));
|
|
2081
2174
|
const request = new wechaty_grpc_1.puppet.RoomPermissionRequest();
|
|
2082
2175
|
request.setId(roomId);
|
|
2083
2176
|
let set = false;
|
|
@@ -2103,7 +2196,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2103
2196
|
return set ? undefined : result;
|
|
2104
2197
|
}
|
|
2105
2198
|
async roomOwnerTransfer(roomId, contactId) {
|
|
2106
|
-
|
|
2199
|
+
this.log.verbose('PuppetService', 'roomOwnerTransfer(%s, %s)', roomId, contactId);
|
|
2107
2200
|
const request = new wechaty_grpc_1.puppet.RoomOwnerTransferRequest();
|
|
2108
2201
|
request.setId(roomId);
|
|
2109
2202
|
request.setContactId(contactId);
|
|
@@ -2111,7 +2204,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2111
2204
|
.bind(this.grpcManager.client))(request);
|
|
2112
2205
|
}
|
|
2113
2206
|
async roomAddAdmins(roomId, contactIdList) {
|
|
2114
|
-
|
|
2207
|
+
this.log.verbose('PuppetService', 'roomAddAdmins(%s, %s)', roomId, contactIdList);
|
|
2115
2208
|
const request = new wechaty_grpc_1.puppet.RoomAdminsRequest();
|
|
2116
2209
|
request.setId(roomId);
|
|
2117
2210
|
request.setContactIdsList(contactIdList);
|
|
@@ -2119,7 +2212,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2119
2212
|
.bind(this.grpcManager.client))(request);
|
|
2120
2213
|
}
|
|
2121
2214
|
async roomDelAdmins(roomId, contactIdList) {
|
|
2122
|
-
|
|
2215
|
+
this.log.verbose('PuppetService', 'roomDelAdmins(%s, %s)', roomId, contactIdList);
|
|
2123
2216
|
const request = new wechaty_grpc_1.puppet.RoomAdminsRequest();
|
|
2124
2217
|
request.setId(roomId);
|
|
2125
2218
|
request.setContactIdsList(contactIdList);
|
|
@@ -2127,7 +2220,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2127
2220
|
.bind(this.grpcManager.client))(request);
|
|
2128
2221
|
}
|
|
2129
2222
|
async roomDismiss(roomId) {
|
|
2130
|
-
|
|
2223
|
+
this.log.verbose('PuppetService', 'roomDelAdmins(%s)', roomId);
|
|
2131
2224
|
const request = new wechaty_grpc_1.puppet.RoomDismissRequest();
|
|
2132
2225
|
request.setId(roomId);
|
|
2133
2226
|
await util_1.default.promisify(this.grpcManager.client.roomDismiss
|
|
@@ -2139,7 +2232,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2139
2232
|
*
|
|
2140
2233
|
*/
|
|
2141
2234
|
async friendshipSearchPhone(phone, type) {
|
|
2142
|
-
|
|
2235
|
+
this.log.verbose('PuppetService', 'friendshipSearchPhone(%s)', phone);
|
|
2143
2236
|
const request = new wechaty_grpc_1.puppet.FriendshipSearchPhoneRequest();
|
|
2144
2237
|
request.setPhone(phone);
|
|
2145
2238
|
if (typeof (type) === 'undefined') {
|
|
@@ -2164,7 +2257,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2164
2257
|
return null;
|
|
2165
2258
|
}
|
|
2166
2259
|
async friendshipSearchHandle(handle, type) {
|
|
2167
|
-
|
|
2260
|
+
this.log.verbose('PuppetService', 'friendshipSearchHandle(%s)', handle);
|
|
2168
2261
|
const request = new wechaty_grpc_1.puppet.FriendshipSearchHandleRequest();
|
|
2169
2262
|
/**
|
|
2170
2263
|
* TODO: use `setHandle()` in v2.0.0
|
|
@@ -2193,7 +2286,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2193
2286
|
return null;
|
|
2194
2287
|
}
|
|
2195
2288
|
async friendshipRawPayload(id) {
|
|
2196
|
-
|
|
2289
|
+
this.log.verbose('PuppetService', 'friendshipRawPayload(%s)', id);
|
|
2197
2290
|
const request = new wechaty_grpc_1.puppet.FriendshipPayloadRequest();
|
|
2198
2291
|
request.setId(id);
|
|
2199
2292
|
const response = await util_1.default.promisify(this.grpcManager.client.friendshipPayload
|
|
@@ -2210,12 +2303,12 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2210
2303
|
return payload;
|
|
2211
2304
|
}
|
|
2212
2305
|
async friendshipRawPayloadParser(payload) {
|
|
2213
|
-
// log.silly('PuppetService', 'friendshipRawPayloadParser({id:%s})', payload.id)
|
|
2306
|
+
// this.log.silly('PuppetService', 'friendshipRawPayloadParser({id:%s})', payload.id)
|
|
2214
2307
|
// passthrough
|
|
2215
2308
|
return payload;
|
|
2216
2309
|
}
|
|
2217
2310
|
async friendshipAdd(contactId, options) {
|
|
2218
|
-
|
|
2311
|
+
this.log.verbose('PuppetService', 'friendshipAdd(%s, %s)', contactId, JSON.stringify(options));
|
|
2219
2312
|
const request = new wechaty_grpc_1.puppet.FriendshipAddRequest();
|
|
2220
2313
|
request.setContactId(contactId);
|
|
2221
2314
|
// FIXME: for backward compatibility, need to be removed after all puppet has updated.
|
|
@@ -2246,7 +2339,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2246
2339
|
.bind(this.grpcManager.client))(request);
|
|
2247
2340
|
}
|
|
2248
2341
|
async friendshipAccept(friendshipId) {
|
|
2249
|
-
|
|
2342
|
+
this.log.verbose('PuppetService', 'friendshipAccept(%s)', friendshipId);
|
|
2250
2343
|
const request = new wechaty_grpc_1.puppet.FriendshipAcceptRequest();
|
|
2251
2344
|
request.setId(friendshipId);
|
|
2252
2345
|
await util_1.default.promisify(this.grpcManager.client.friendshipAccept
|
|
@@ -2258,7 +2351,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2258
2351
|
*
|
|
2259
2352
|
*/
|
|
2260
2353
|
async tagContactTagAdd(tagIds, contactIds) {
|
|
2261
|
-
|
|
2354
|
+
this.log.verbose('PuppetService', 'tagContactTagAdd(%s, %s)', tagIds, contactIds);
|
|
2262
2355
|
const request = new wechaty_grpc_1.puppet.TagContactTagAddRequest();
|
|
2263
2356
|
request.setTagIdsList(tagIds);
|
|
2264
2357
|
request.setContactIdsList(contactIds);
|
|
@@ -2266,7 +2359,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2266
2359
|
.bind(this.grpcManager.client))(request);
|
|
2267
2360
|
}
|
|
2268
2361
|
async tagContactTagRemove(tagIds, contactIds) {
|
|
2269
|
-
|
|
2362
|
+
this.log.verbose('PuppetService', 'tagContactTagRemove(%s, %s)', tagIds, contactIds);
|
|
2270
2363
|
const request = new wechaty_grpc_1.puppet.TagContactTagRemoveRequest();
|
|
2271
2364
|
request.setTagIdsList(tagIds);
|
|
2272
2365
|
request.setContactIdsList(contactIds);
|
|
@@ -2274,7 +2367,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2274
2367
|
.bind(this.grpcManager.client))(request);
|
|
2275
2368
|
}
|
|
2276
2369
|
async tagGroupAdd(tagGroupName) {
|
|
2277
|
-
|
|
2370
|
+
this.log.verbose('PuppetService', 'tagGroupAdd(%s)', tagGroupName);
|
|
2278
2371
|
const request = new wechaty_grpc_1.puppet.TagGroupAddRequest();
|
|
2279
2372
|
request.setTagGroupName(tagGroupName);
|
|
2280
2373
|
const result = await util_1.default.promisify(this.grpcManager.client.tagGroupAdd
|
|
@@ -2283,14 +2376,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2283
2376
|
return id;
|
|
2284
2377
|
}
|
|
2285
2378
|
async tagGroupDelete(tagGroupId) {
|
|
2286
|
-
|
|
2379
|
+
this.log.verbose('PuppetService', 'tagGroupDelete(%s)', tagGroupId);
|
|
2287
2380
|
const request = new wechaty_grpc_1.puppet.TagGroupDeleteRequest();
|
|
2288
2381
|
request.setTagGroupId(tagGroupId);
|
|
2289
2382
|
await util_1.default.promisify(this.grpcManager.client.tagGroupDelete
|
|
2290
2383
|
.bind(this.grpcManager.client))(request);
|
|
2291
2384
|
}
|
|
2292
2385
|
async tagTagAdd(tagNameList, tagGroupId) {
|
|
2293
|
-
|
|
2386
|
+
this.log.verbose('PuppetService', 'tagTagAdd(%s, %s)', tagNameList, tagGroupId);
|
|
2294
2387
|
const request = new wechaty_grpc_1.puppet.TagTagAddRequest();
|
|
2295
2388
|
if (typeof tagGroupId !== 'undefined') {
|
|
2296
2389
|
request.setTagGroupId(tagGroupId);
|
|
@@ -2305,14 +2398,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2305
2398
|
return tagInfoList;
|
|
2306
2399
|
}
|
|
2307
2400
|
async tagTagDelete(tagIdList) {
|
|
2308
|
-
|
|
2401
|
+
this.log.verbose('PuppetService', 'tagTagDelete(%s)', tagIdList);
|
|
2309
2402
|
const request = new wechaty_grpc_1.puppet.TagTagDeleteRequest();
|
|
2310
2403
|
request.setTagIdList(tagIdList);
|
|
2311
2404
|
await util_1.default.promisify(this.grpcManager.client.tagTagDelete
|
|
2312
2405
|
.bind(this.grpcManager.client))(request);
|
|
2313
2406
|
}
|
|
2314
2407
|
async tagTagModify(tagNewInfoList) {
|
|
2315
|
-
|
|
2408
|
+
this.log.verbose('PuppetService', 'tagTagModify(%o)', tagNewInfoList);
|
|
2316
2409
|
const request = new wechaty_grpc_1.puppet.TagTagModifyRequest();
|
|
2317
2410
|
const newInfoList = tagNewInfoList.map(i => {
|
|
2318
2411
|
const tagInfo = new wechaty_grpc_1.puppet.TagTagInfo();
|
|
@@ -2330,7 +2423,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2330
2423
|
return tagInfoList;
|
|
2331
2424
|
}
|
|
2332
2425
|
async tagGroupList() {
|
|
2333
|
-
|
|
2426
|
+
this.log.verbose('PuppetService', 'tagGroupList()');
|
|
2334
2427
|
const request = new wechaty_grpc_1.puppet.TagGroupListRequest();
|
|
2335
2428
|
const result = await util_1.default.promisify(this.grpcManager.client.tagGroupList
|
|
2336
2429
|
.bind(this.grpcManager.client))(request);
|
|
@@ -2338,7 +2431,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2338
2431
|
return groupIds;
|
|
2339
2432
|
}
|
|
2340
2433
|
async tagGroupTagList(tagGroupId) {
|
|
2341
|
-
|
|
2434
|
+
this.log.verbose('PuppetService', 'tagGroupTagList(%s)', tagGroupId);
|
|
2342
2435
|
const request = new wechaty_grpc_1.puppet.TagGroupTagListRequest();
|
|
2343
2436
|
if (typeof tagGroupId !== 'undefined') {
|
|
2344
2437
|
request.setTagGroupId(tagGroupId);
|
|
@@ -2349,7 +2442,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2349
2442
|
return tagIds;
|
|
2350
2443
|
}
|
|
2351
2444
|
async tagTagList() {
|
|
2352
|
-
|
|
2445
|
+
this.log.verbose('PuppetService', 'tagTagList()');
|
|
2353
2446
|
const request = new wechaty_grpc_1.puppet.TagTagListRequest();
|
|
2354
2447
|
const result = await util_1.default.promisify(this.grpcManager.client.tagTagList
|
|
2355
2448
|
.bind(this.grpcManager.client))(request);
|
|
@@ -2357,7 +2450,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2357
2450
|
return tagIds;
|
|
2358
2451
|
}
|
|
2359
2452
|
async tagContactTagList(contactId) {
|
|
2360
|
-
|
|
2453
|
+
this.log.verbose('PuppetService', 'tagContactTagList(%s)', contactId);
|
|
2361
2454
|
const request = new wechaty_grpc_1.puppet.TagContactTagListRequest();
|
|
2362
2455
|
request.setContactId(contactId);
|
|
2363
2456
|
const result = await util_1.default.promisify(this.grpcManager.client.tagContactTagList
|
|
@@ -2366,7 +2459,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2366
2459
|
return tagIds;
|
|
2367
2460
|
}
|
|
2368
2461
|
async tagTagContactList(tagId) {
|
|
2369
|
-
|
|
2462
|
+
this.log.verbose('PuppetService', 'tagTagContactList(%s)', tagId);
|
|
2370
2463
|
const request = new wechaty_grpc_1.puppet.TagTagContactListRequest();
|
|
2371
2464
|
request.setTagId(tagId);
|
|
2372
2465
|
const result = await util_1.default.promisify(this.grpcManager.client.tagTagContactList
|
|
@@ -2375,12 +2468,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2375
2468
|
return contactIds;
|
|
2376
2469
|
}
|
|
2377
2470
|
async tagGroupPayloadPuppet(id) {
|
|
2378
|
-
|
|
2471
|
+
this.log.verbose('PuppetService', 'tagGroupPayload(%s)', id);
|
|
2379
2472
|
const cachedPayload = await this._payloadStore.tagGroup?.get(id);
|
|
2380
2473
|
if (cachedPayload) {
|
|
2381
|
-
|
|
2474
|
+
this.log.silly('PuppetService', 'tagGroupPayload(%s) cache HIT', id);
|
|
2382
2475
|
return cachedPayload;
|
|
2383
2476
|
}
|
|
2477
|
+
// Snapshot the gen before the raw fetch so a dirty that lands while
|
|
2478
|
+
// the gRPC round-trip is in flight makes the write-back below stale.
|
|
2479
|
+
const gen = this.cache.snapshotGen(PUPPET.types.Dirty.TagGroup, id);
|
|
2384
2480
|
const request = new wechaty_grpc_1.puppet.TagGroupPayloadRequest();
|
|
2385
2481
|
request.setGroupId(id);
|
|
2386
2482
|
const response = await util_1.default.promisify(this.grpcManager.client.tagGroupPayload
|
|
@@ -2394,17 +2490,25 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2394
2490
|
name: grpcPayload.getName(),
|
|
2395
2491
|
type: grpcPayload.getType(),
|
|
2396
2492
|
};
|
|
2397
|
-
|
|
2398
|
-
|
|
2493
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.TagGroup, id, gen)) {
|
|
2494
|
+
await this._payloadStore.tagGroup?.set(id, payload);
|
|
2495
|
+
this.log.silly('PuppetService', 'tagGroupPayloadPuppet(%s) cache SET', id);
|
|
2496
|
+
}
|
|
2497
|
+
else {
|
|
2498
|
+
this.log.silly('PuppetService', 'tagGroupPayloadPuppet(%s) cache SET skipped: dirty landed during raw fetch', id);
|
|
2499
|
+
}
|
|
2399
2500
|
return payload;
|
|
2400
2501
|
}
|
|
2401
2502
|
async tagPayloadPuppet(tagId) {
|
|
2402
|
-
|
|
2503
|
+
this.log.verbose('PuppetService', 'tagPayloadPuppet(%s)', tagId);
|
|
2403
2504
|
const cachedPayload = await this._payloadStore.tag?.get(tagId);
|
|
2404
2505
|
if (cachedPayload) {
|
|
2405
|
-
|
|
2506
|
+
this.log.silly('PuppetService', 'tagPayloadPuppet(%s) cache HIT', tagId);
|
|
2406
2507
|
return cachedPayload;
|
|
2407
2508
|
}
|
|
2509
|
+
// Snapshot the gen before the raw fetch so a dirty that lands while
|
|
2510
|
+
// the gRPC round-trip is in flight makes the write-back below stale.
|
|
2511
|
+
const gen = this.cache.snapshotGen(PUPPET.types.Dirty.Tag, tagId);
|
|
2408
2512
|
const request = new wechaty_grpc_1.puppet.TagPayloadRequest();
|
|
2409
2513
|
request.setTagId(tagId);
|
|
2410
2514
|
const response = await util_1.default.promisify(this.grpcManager.client.tagPayload
|
|
@@ -2419,8 +2523,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2419
2523
|
groupId: grpcPayload.getGroupId(),
|
|
2420
2524
|
type: grpcPayload.getType(),
|
|
2421
2525
|
};
|
|
2422
|
-
|
|
2423
|
-
|
|
2526
|
+
if (this.cache.isFreshWrite(PUPPET.types.Dirty.Tag, tagId, gen)) {
|
|
2527
|
+
await this._payloadStore.tag?.set(tagId, payload);
|
|
2528
|
+
this.log.silly('PuppetService', 'tagPayloadPuppet(%s) cache SET', tagId);
|
|
2529
|
+
}
|
|
2530
|
+
else {
|
|
2531
|
+
this.log.silly('PuppetService', 'tagPayloadPuppet(%s) cache SET skipped: dirty landed during raw fetch', tagId);
|
|
2532
|
+
}
|
|
2424
2533
|
return payload;
|
|
2425
2534
|
}
|
|
2426
2535
|
/**
|
|
@@ -2429,7 +2538,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2429
2538
|
*
|
|
2430
2539
|
*/
|
|
2431
2540
|
async postPublish(payload) {
|
|
2432
|
-
|
|
2541
|
+
this.log.verbose('PuppetService', 'postPublish(%s)', payload);
|
|
2433
2542
|
if (!PUPPET.payloads.isPostClient(payload)) {
|
|
2434
2543
|
throw new Error('can only publish client post now');
|
|
2435
2544
|
}
|
|
@@ -2442,13 +2551,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2442
2551
|
return momentId;
|
|
2443
2552
|
}
|
|
2444
2553
|
async postUnpublish(id) {
|
|
2445
|
-
|
|
2554
|
+
this.log.verbose('PuppetService', 'postUnpublish(%s)', id);
|
|
2446
2555
|
const request = new wechaty_grpc_1.puppet.MomentUnpublishRequest();
|
|
2447
2556
|
request.setMomentId(id);
|
|
2448
2557
|
await util_1.default.promisify(this.grpcManager.client.momentUnpublish.bind(this.grpcManager.client))(request);
|
|
2449
2558
|
}
|
|
2450
2559
|
async momentSignature(text) {
|
|
2451
|
-
|
|
2560
|
+
this.log.verbose('PuppetService', 'momentSignature(%s)', text);
|
|
2452
2561
|
const request = new wechaty_grpc_1.puppet.MomentSignatureRequest();
|
|
2453
2562
|
if (text) {
|
|
2454
2563
|
request.setText(text);
|
|
@@ -2459,7 +2568,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2459
2568
|
return signature;
|
|
2460
2569
|
}
|
|
2461
2570
|
async momentCoverage(cover) {
|
|
2462
|
-
|
|
2571
|
+
this.log.verbose('PuppetService', 'momentCoverage(%s)', JSON.stringify(cover));
|
|
2463
2572
|
const request = new wechaty_grpc_1.puppet.MomentCoverageRequest();
|
|
2464
2573
|
if (cover) {
|
|
2465
2574
|
const serializedFileBox = await this.serializeFileBox(cover);
|
|
@@ -2473,7 +2582,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2473
2582
|
}
|
|
2474
2583
|
}
|
|
2475
2584
|
async postPayloadSayable(postId, sayableId) {
|
|
2476
|
-
|
|
2585
|
+
this.log.verbose('PuppetService', 'postPayloadSayable(%s, %s)', postId, sayableId);
|
|
2477
2586
|
const request = new wechaty_grpc_1.puppet.PostPayloadSayableRequest();
|
|
2478
2587
|
request.setPostId(postId);
|
|
2479
2588
|
request.setSayableId(sayableId);
|
|
@@ -2525,7 +2634,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2525
2634
|
}
|
|
2526
2635
|
}
|
|
2527
2636
|
async postRawPayload(id) {
|
|
2528
|
-
|
|
2637
|
+
this.log.verbose('PuppetService', 'postRawPayload(%s)', id);
|
|
2529
2638
|
const request = new wechaty_grpc_1.puppet.PostPayloadRequest();
|
|
2530
2639
|
request.setPostId(id);
|
|
2531
2640
|
const response = await util_1.default.promisify(this.grpcManager.client.postPayload
|
|
@@ -2569,12 +2678,12 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2569
2678
|
return payload;
|
|
2570
2679
|
}
|
|
2571
2680
|
async postRawPayloadParser(payload) {
|
|
2572
|
-
// log.silly('PuppetService', 'postRawPayloadParser({id:%s})', payload.id)
|
|
2681
|
+
// this.log.silly('PuppetService', 'postRawPayloadParser({id:%s})', payload.id)
|
|
2573
2682
|
// passthrough
|
|
2574
2683
|
return payload;
|
|
2575
2684
|
}
|
|
2576
2685
|
async tap(postId, type, tap = true) {
|
|
2577
|
-
|
|
2686
|
+
this.log.verbose('PuppetService', 'tap(%s, %s, %s)', postId, type, tap);
|
|
2578
2687
|
const request = new wechaty_grpc_1.puppet.PostTapRequest();
|
|
2579
2688
|
request.setPostId(postId);
|
|
2580
2689
|
if (type) {
|
|
@@ -2587,14 +2696,14 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2587
2696
|
return result;
|
|
2588
2697
|
}
|
|
2589
2698
|
async momentVisibleList() {
|
|
2590
|
-
|
|
2699
|
+
this.log.verbose('PuppetService', 'momentVisibleList()');
|
|
2591
2700
|
const request = new wechaty_grpc_1.puppet.MomentVisibleListRequest();
|
|
2592
2701
|
const response = await util_1.default.promisify(this.grpcManager.client.momentVisibleList.bind(this.grpcManager.client))(request);
|
|
2593
2702
|
const contactIdsList = response.getContactIdsList();
|
|
2594
2703
|
return contactIdsList;
|
|
2595
2704
|
}
|
|
2596
2705
|
async getContactExternalUserId(contactIds, serviceProviderId) {
|
|
2597
|
-
|
|
2706
|
+
this.log.verbose('PuppetService', 'getContactExternalUserId(%s, %s)', JSON.stringify(contactIds), serviceProviderId);
|
|
2598
2707
|
const request = new wechaty_grpc_1.puppet.GetContactExternalUserIdRequest();
|
|
2599
2708
|
request.setContactIdsList(contactIds);
|
|
2600
2709
|
if (serviceProviderId) {
|
|
@@ -2612,7 +2721,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2612
2721
|
return result;
|
|
2613
2722
|
}
|
|
2614
2723
|
async getRoomAntiSpamStrategyList() {
|
|
2615
|
-
|
|
2724
|
+
this.log.verbose('PuppetService', 'getRoomAntiSpamStrategyList()');
|
|
2616
2725
|
const request = new wechaty_grpc_1.puppet.GetRoomAntiSpamStrategyListRequest();
|
|
2617
2726
|
const response = await util_1.default.promisify(this.grpcManager.client.getRoomAntiSpamStrategyList.bind(this.grpcManager.client))(request);
|
|
2618
2727
|
const result = [];
|
|
@@ -2626,7 +2735,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2626
2735
|
return result;
|
|
2627
2736
|
}
|
|
2628
2737
|
async getRoomAntiSpamStrategyEffectRoomList(strategyId) {
|
|
2629
|
-
|
|
2738
|
+
this.log.verbose('PuppetService', 'getRoomAntiSpamStrategyEffectRoomList(%s)', strategyId);
|
|
2630
2739
|
const request = new wechaty_grpc_1.puppet.GetRoomAntiSpamStrategyEffectRoomListRequest();
|
|
2631
2740
|
request.setStrategyId(strategyId);
|
|
2632
2741
|
const response = await util_1.default.promisify(this.grpcManager.client.getRoomAntiSpamStrategyEffectRoomList.bind(this.grpcManager.client))(request);
|
|
@@ -2634,7 +2743,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2634
2743
|
return result;
|
|
2635
2744
|
}
|
|
2636
2745
|
async applyRoomAntiSpamStrategy(strategyId, roomIds, active) {
|
|
2637
|
-
|
|
2746
|
+
this.log.verbose('PuppetService', 'applyRoomAntiSpamStrategy(%s, %s, %s)', strategyId, roomIds, active);
|
|
2638
2747
|
const request = new wechaty_grpc_1.puppet.ApplyRoomAntiSpamStrategyRequest();
|
|
2639
2748
|
request.setStrategyId(strategyId);
|
|
2640
2749
|
request.setRoomIdsList(roomIds);
|
|
@@ -2642,7 +2751,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2642
2751
|
await util_1.default.promisify(this.grpcManager.client.applyRoomAntiSpamStrategy.bind(this.grpcManager.client))(request);
|
|
2643
2752
|
}
|
|
2644
2753
|
async getCorpMessageInterceptionStrategies() {
|
|
2645
|
-
|
|
2754
|
+
this.log.verbose('PuppetService', 'getCorpMessageInterceptionStrategies()');
|
|
2646
2755
|
const request = new wechaty_grpc_1.puppet.GetCorpMessageInterceptionStrategiesRequest();
|
|
2647
2756
|
const response = await util_1.default.promisify(this.grpcManager.client.getCorpMessageInterceptionStrategies.bind(this.grpcManager.client))(request);
|
|
2648
2757
|
const result = [];
|
|
@@ -2675,15 +2784,15 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2675
2784
|
reconnectIndicator;
|
|
2676
2785
|
async reset() {
|
|
2677
2786
|
if (!this._grpcManager) {
|
|
2678
|
-
|
|
2787
|
+
this.log.warn('PuppetService', 'grpc manager not constructed, perform regular reset');
|
|
2679
2788
|
return super.reset();
|
|
2680
2789
|
}
|
|
2681
2790
|
if (!this.isLoggedIn) {
|
|
2682
|
-
|
|
2791
|
+
this.log.warn('PuppetService', 'puppet not logged in, perform regular reset');
|
|
2683
2792
|
return super.reset();
|
|
2684
2793
|
}
|
|
2685
2794
|
if (this.reconnectIndicator.value()) {
|
|
2686
|
-
|
|
2795
|
+
this.log.warn('PuppetService', 'already trying to reconnect, pass this one');
|
|
2687
2796
|
return;
|
|
2688
2797
|
}
|
|
2689
2798
|
this.reconnectIndicator.value(true);
|
|
@@ -2733,13 +2842,13 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2733
2842
|
}
|
|
2734
2843
|
catch (e) {
|
|
2735
2844
|
if (Date.now() - startTime < timeoutMilliseconds) {
|
|
2736
|
-
|
|
2845
|
+
this.log.warn('failed to start stream, will try again in 15 seconds');
|
|
2737
2846
|
await new Promise(resolve => {
|
|
2738
2847
|
setTimeout(resolve, 5000);
|
|
2739
2848
|
});
|
|
2740
2849
|
}
|
|
2741
2850
|
else {
|
|
2742
|
-
|
|
2851
|
+
this.log.warn('failed to start stream and reaches timeout, will perform regular reset');
|
|
2743
2852
|
this.reconnectIndicator.value(false);
|
|
2744
2853
|
return super.reset();
|
|
2745
2854
|
}
|
|
@@ -2756,7 +2865,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2756
2865
|
});
|
|
2757
2866
|
}
|
|
2758
2867
|
catch (e) {
|
|
2759
|
-
|
|
2868
|
+
this.log.warn('PuppetService', 'waiting for event reset login error, will perform regular reset');
|
|
2760
2869
|
return super.reset();
|
|
2761
2870
|
}
|
|
2762
2871
|
try {
|
|
@@ -2767,7 +2876,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2767
2876
|
});
|
|
2768
2877
|
}
|
|
2769
2878
|
catch (e) {
|
|
2770
|
-
|
|
2879
|
+
this.log.warn('PuppetService', 'waiting for event reset ready error, will do nothing');
|
|
2771
2880
|
}
|
|
2772
2881
|
}
|
|
2773
2882
|
async getMiscellaneousStoreData() {
|
|
@@ -2781,7 +2890,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2781
2890
|
const lastEventTimestamp = await this._payloadStore.miscellaneous?.get('lastEventTimestamp');
|
|
2782
2891
|
let lastEventSeq = await this._payloadStore.miscellaneous?.get('lastEventSeq');
|
|
2783
2892
|
if ((Date.now() - Number(lastEventTimestamp || 0)) > this.timeoutMilliseconds) {
|
|
2784
|
-
|
|
2893
|
+
this.log.warn(`last event was ${(Date.now() - Number(lastEventTimestamp || 0)) / 1000} seconds ago, will not request event cache`);
|
|
2785
2894
|
lastEventSeq = undefined;
|
|
2786
2895
|
}
|
|
2787
2896
|
const accountId = await this._payloadStore.miscellaneous?.get('accountId');
|