@juzi/wechaty-puppet-service 1.0.43 → 1.0.45
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/puppet-service.d.ts +3 -4
- package/dist/cjs/src/client/puppet-service.d.ts.map +1 -1
- package/dist/cjs/src/client/puppet-service.js +80 -198
- 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/src/server/puppet-implementation.d.ts.map +1 -1
- package/dist/cjs/src/server/puppet-implementation.js +41 -127
- package/dist/cjs/src/server/puppet-implementation.js.map +1 -1
- package/dist/cjs/src/utils/pb-payload-helper.d.ts +5 -2
- package/dist/cjs/src/utils/pb-payload-helper.d.ts.map +1 -1
- package/dist/cjs/src/utils/pb-payload-helper.js +146 -1
- package/dist/cjs/src/utils/pb-payload-helper.js.map +1 -1
- package/dist/esm/src/client/puppet-service.d.ts +3 -4
- package/dist/esm/src/client/puppet-service.d.ts.map +1 -1
- package/dist/esm/src/client/puppet-service.js +78 -196
- 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/src/server/puppet-implementation.d.ts.map +1 -1
- package/dist/esm/src/server/puppet-implementation.js +40 -126
- package/dist/esm/src/server/puppet-implementation.js.map +1 -1
- package/dist/esm/src/utils/pb-payload-helper.d.ts +5 -2
- package/dist/esm/src/utils/pb-payload-helper.d.ts.map +1 -1
- package/dist/esm/src/utils/pb-payload-helper.js +120 -0
- package/dist/esm/src/utils/pb-payload-helper.js.map +1 -1
- package/package.json +4 -3
- package/src/client/puppet-service.ts +97 -214
- package/src/package-json.ts +4 -3
- package/src/server/puppet-implementation.ts +50 -144
- package/src/utils/pb-payload-helper.ts +119 -2
- package/dist/cjs/src/deprecated/chunk-pb.d.ts +0 -15
- package/dist/cjs/src/deprecated/chunk-pb.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/chunk-pb.js +0 -60
- package/dist/cjs/src/deprecated/chunk-pb.js.map +0 -1
- package/dist/cjs/src/deprecated/chunk-pb.spec.d.ts +0 -3
- package/dist/cjs/src/deprecated/chunk-pb.spec.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/chunk-pb.spec.js +0 -144
- package/dist/cjs/src/deprecated/chunk-pb.spec.js.map +0 -1
- package/dist/cjs/src/deprecated/conversation-id-file-box.d.ts +0 -21
- package/dist/cjs/src/deprecated/conversation-id-file-box.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/conversation-id-file-box.js +0 -43
- package/dist/cjs/src/deprecated/conversation-id-file-box.js.map +0 -1
- package/dist/cjs/src/deprecated/conversation-id-file-box.spec.d.ts +0 -3
- package/dist/cjs/src/deprecated/conversation-id-file-box.spec.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/conversation-id-file-box.spec.js +0 -94
- package/dist/cjs/src/deprecated/conversation-id-file-box.spec.js.map +0 -1
- package/dist/cjs/src/deprecated/file-box-chunk.d.ts +0 -14
- package/dist/cjs/src/deprecated/file-box-chunk.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/file-box-chunk.js +0 -67
- package/dist/cjs/src/deprecated/file-box-chunk.js.map +0 -1
- package/dist/cjs/src/deprecated/file-box-chunk.spec.d.ts +0 -3
- package/dist/cjs/src/deprecated/file-box-chunk.spec.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/file-box-chunk.spec.js +0 -134
- package/dist/cjs/src/deprecated/file-box-chunk.spec.js.map +0 -1
- package/dist/cjs/src/deprecated/file-box-pb.d.ts +0 -15
- package/dist/cjs/src/deprecated/file-box-pb.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/file-box-pb.js +0 -26
- package/dist/cjs/src/deprecated/file-box-pb.js.map +0 -1
- package/dist/cjs/src/deprecated/file-box-pb.spec.d.ts +0 -3
- package/dist/cjs/src/deprecated/file-box-pb.spec.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/file-box-pb.spec.js +0 -18
- package/dist/cjs/src/deprecated/file-box-pb.spec.js.map +0 -1
- package/dist/cjs/src/deprecated/file-box-pb.type.d.ts +0 -15
- package/dist/cjs/src/deprecated/file-box-pb.type.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/file-box-pb.type.js +0 -3
- package/dist/cjs/src/deprecated/file-box-pb.type.js.map +0 -1
- package/dist/cjs/src/deprecated/mod.d.ts +0 -3
- package/dist/cjs/src/deprecated/mod.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/mod.js +0 -10
- package/dist/cjs/src/deprecated/mod.js.map +0 -1
- package/dist/cjs/src/deprecated/next-data.d.ts +0 -7
- package/dist/cjs/src/deprecated/next-data.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/next-data.js +0 -26
- package/dist/cjs/src/deprecated/next-data.js.map +0 -1
- package/dist/cjs/src/deprecated/serialize-file-box.d.ts +0 -6
- package/dist/cjs/src/deprecated/serialize-file-box.d.ts.map +0 -1
- package/dist/cjs/src/deprecated/serialize-file-box.js +0 -22
- package/dist/cjs/src/deprecated/serialize-file-box.js.map +0 -1
- package/dist/esm/src/deprecated/chunk-pb.d.ts +0 -15
- package/dist/esm/src/deprecated/chunk-pb.d.ts.map +0 -1
- package/dist/esm/src/deprecated/chunk-pb.js +0 -56
- package/dist/esm/src/deprecated/chunk-pb.js.map +0 -1
- package/dist/esm/src/deprecated/chunk-pb.spec.d.ts +0 -3
- package/dist/esm/src/deprecated/chunk-pb.spec.d.ts.map +0 -1
- package/dist/esm/src/deprecated/chunk-pb.spec.js +0 -142
- package/dist/esm/src/deprecated/chunk-pb.spec.js.map +0 -1
- package/dist/esm/src/deprecated/conversation-id-file-box.d.ts +0 -21
- package/dist/esm/src/deprecated/conversation-id-file-box.d.ts.map +0 -1
- package/dist/esm/src/deprecated/conversation-id-file-box.js +0 -39
- package/dist/esm/src/deprecated/conversation-id-file-box.js.map +0 -1
- package/dist/esm/src/deprecated/conversation-id-file-box.spec.d.ts +0 -3
- package/dist/esm/src/deprecated/conversation-id-file-box.spec.d.ts.map +0 -1
- package/dist/esm/src/deprecated/conversation-id-file-box.spec.js +0 -92
- package/dist/esm/src/deprecated/conversation-id-file-box.spec.js.map +0 -1
- package/dist/esm/src/deprecated/file-box-chunk.d.ts +0 -14
- package/dist/esm/src/deprecated/file-box-chunk.d.ts.map +0 -1
- package/dist/esm/src/deprecated/file-box-chunk.js +0 -63
- package/dist/esm/src/deprecated/file-box-chunk.js.map +0 -1
- package/dist/esm/src/deprecated/file-box-chunk.spec.d.ts +0 -3
- package/dist/esm/src/deprecated/file-box-chunk.spec.d.ts.map +0 -1
- package/dist/esm/src/deprecated/file-box-chunk.spec.js +0 -132
- package/dist/esm/src/deprecated/file-box-chunk.spec.js.map +0 -1
- package/dist/esm/src/deprecated/file-box-pb.d.ts +0 -15
- package/dist/esm/src/deprecated/file-box-pb.d.ts.map +0 -1
- package/dist/esm/src/deprecated/file-box-pb.js +0 -22
- package/dist/esm/src/deprecated/file-box-pb.js.map +0 -1
- package/dist/esm/src/deprecated/file-box-pb.spec.d.ts +0 -3
- package/dist/esm/src/deprecated/file-box-pb.spec.d.ts.map +0 -1
- package/dist/esm/src/deprecated/file-box-pb.spec.js +0 -16
- package/dist/esm/src/deprecated/file-box-pb.spec.js.map +0 -1
- package/dist/esm/src/deprecated/file-box-pb.type.d.ts +0 -15
- package/dist/esm/src/deprecated/file-box-pb.type.d.ts.map +0 -1
- package/dist/esm/src/deprecated/file-box-pb.type.js +0 -2
- package/dist/esm/src/deprecated/file-box-pb.type.js.map +0 -1
- package/dist/esm/src/deprecated/mod.d.ts +0 -3
- package/dist/esm/src/deprecated/mod.d.ts.map +0 -1
- package/dist/esm/src/deprecated/mod.js +0 -3
- package/dist/esm/src/deprecated/mod.js.map +0 -1
- package/dist/esm/src/deprecated/next-data.d.ts +0 -7
- package/dist/esm/src/deprecated/next-data.d.ts.map +0 -1
- package/dist/esm/src/deprecated/next-data.js +0 -23
- package/dist/esm/src/deprecated/next-data.js.map +0 -1
- package/dist/esm/src/deprecated/serialize-file-box.d.ts +0 -6
- package/dist/esm/src/deprecated/serialize-file-box.d.ts.map +0 -1
- package/dist/esm/src/deprecated/serialize-file-box.js +0 -18
- package/dist/esm/src/deprecated/serialize-file-box.js.map +0 -1
- package/src/deprecated/chunk-pb.spec.ts +0 -210
- package/src/deprecated/chunk-pb.ts +0 -75
- package/src/deprecated/conversation-id-file-box.spec.ts +0 -131
- package/src/deprecated/conversation-id-file-box.ts +0 -72
- package/src/deprecated/file-box-chunk.spec.ts +0 -184
- package/src/deprecated/file-box-chunk.ts +0 -87
- package/src/deprecated/file-box-pb.spec.ts +0 -31
- package/src/deprecated/file-box-pb.ts +0 -41
- package/src/deprecated/file-box-pb.type.ts +0 -16
- package/src/deprecated/mod.ts +0 -8
- package/src/deprecated/next-data.ts +0 -35
- package/src/deprecated/serialize-file-box.ts +0 -24
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
import util from 'util'
|
|
21
|
-
import type { Writable } from 'stream'
|
|
22
21
|
import * as PUPPET from '@juzi/wechaty-puppet'
|
|
23
22
|
|
|
24
23
|
import type {
|
|
@@ -40,15 +39,6 @@ import {
|
|
|
40
39
|
import type { Store } from 'redux'
|
|
41
40
|
// import type { Subscription } from 'rxjs'
|
|
42
41
|
|
|
43
|
-
/**
|
|
44
|
-
* Deprecated. Will be removed after Dec 31, 2022
|
|
45
|
-
*/
|
|
46
|
-
import {
|
|
47
|
-
packConversationIdFileBoxToPb,
|
|
48
|
-
unpackFileBoxFromPb,
|
|
49
|
-
} from '../deprecated/mod.js'
|
|
50
|
-
import { serializeFileBox } from '../deprecated/serialize-file-box.js'
|
|
51
|
-
|
|
52
42
|
import { millisecondsFromTimestamp } from '../pure-functions/timestamp.js'
|
|
53
43
|
|
|
54
44
|
import {
|
|
@@ -68,7 +58,8 @@ import { packageJson } from '../package-json.js'
|
|
|
68
58
|
|
|
69
59
|
import { GrpcManager } from './grpc-manager.js'
|
|
70
60
|
import { PayloadStore } from './payload-store.js'
|
|
71
|
-
import { channelPayloadToPb, channelPbToPayload,
|
|
61
|
+
import { channelPayloadToPb, channelPbToPayload, postPayloadToPb, urlLinkPbToPayload } from '../utils/pb-payload-helper.js'
|
|
62
|
+
import type { MessageBroadcastTargets, MessageBroadcastTargetType } from '@juzi/wechaty-puppet/dist/esm/src/schemas/message.js'
|
|
72
63
|
|
|
73
64
|
export type PuppetServiceOptions = PUPPET.PuppetOptions & {
|
|
74
65
|
authority? : string
|
|
@@ -617,13 +608,6 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
617
608
|
const serializedFileBox = await this.serializeFileBox(fileBox)
|
|
618
609
|
request.setFileBox(serializedFileBox)
|
|
619
610
|
|
|
620
|
-
{
|
|
621
|
-
// DEPRECATED, will be removed after Dec 31, 2022
|
|
622
|
-
const fileboxWrapper = new StringValue()
|
|
623
|
-
fileboxWrapper.setValue(await serializeFileBox(fileBox))
|
|
624
|
-
request.setFileboxStringValueDeprecated(fileboxWrapper)
|
|
625
|
-
}
|
|
626
|
-
|
|
627
611
|
await util.promisify(
|
|
628
612
|
this.grpcManager.client.contactAvatar
|
|
629
613
|
.bind(this.grpcManager.client),
|
|
@@ -732,24 +716,24 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
732
716
|
if (payload.id) {
|
|
733
717
|
throw new Error('cannot modify contactId')
|
|
734
718
|
}
|
|
735
|
-
if (payload.gender) { request.setGender(payload.gender) }
|
|
736
|
-
if (payload.type) { request.setType(payload.type) }
|
|
737
|
-
if (payload.name) { request.setName(payload.name) }
|
|
738
|
-
if (payload.avatar) { request.setAvatar(payload.avatar) }
|
|
739
|
-
if (payload.address) { request.setAddress(payload.address) }
|
|
740
|
-
if (payload.alias) { request.setAlias(payload.alias) }
|
|
741
|
-
if (payload.city) { request.setCity(payload.city) }
|
|
742
|
-
if (payload.friend) { request.setFriend(payload.friend) }
|
|
743
|
-
if (payload.province) { request.setProvince(payload.province) }
|
|
744
|
-
if (payload.star) { request.setStar(payload.star) }
|
|
745
|
-
if (payload.weixin) { request.setWeixin(payload.weixin) }
|
|
746
|
-
if (payload.corporation) { request.setCorporation(payload.corporation) }
|
|
747
|
-
if (payload.title) { request.setTitle(payload.title) }
|
|
748
|
-
if (payload.description) { request.setDescription(payload.description) }
|
|
749
|
-
if (payload.coworker) { request.setCoworker(payload.coworker) }
|
|
750
|
-
if (payload.phone) { request.setPhonesList(payload.phone) }
|
|
751
|
-
if (payload.additionalInfo) { request.setAdditionalInfo(payload.additionalInfo) }
|
|
752
|
-
if (payload.tags) { request.setTagIdsList(payload.tags) }
|
|
719
|
+
if (typeof payload.gender !== 'undefined') { request.setGender(payload.gender) }
|
|
720
|
+
if (typeof payload.type !== 'undefined') { request.setType(payload.type) }
|
|
721
|
+
if (typeof payload.name !== 'undefined') { request.setName(payload.name) }
|
|
722
|
+
if (typeof payload.avatar !== 'undefined') { request.setAvatar(payload.avatar) }
|
|
723
|
+
if (typeof payload.address !== 'undefined') { request.setAddress(payload.address) }
|
|
724
|
+
if (typeof payload.alias !== 'undefined') { request.setAlias(payload.alias) }
|
|
725
|
+
if (typeof payload.city !== 'undefined') { request.setCity(payload.city) }
|
|
726
|
+
if (typeof payload.friend !== 'undefined') { request.setFriend(payload.friend) }
|
|
727
|
+
if (typeof payload.province !== 'undefined') { request.setProvince(payload.province) }
|
|
728
|
+
if (typeof payload.star !== 'undefined') { request.setStar(payload.star) }
|
|
729
|
+
if (typeof payload.weixin !== 'undefined') { request.setWeixin(payload.weixin) }
|
|
730
|
+
if (typeof payload.corporation !== 'undefined') { request.setCorporation(payload.corporation) }
|
|
731
|
+
if (typeof payload.title !== 'undefined') { request.setTitle(payload.title) }
|
|
732
|
+
if (typeof payload.description !== 'undefined') { request.setDescription(payload.description) }
|
|
733
|
+
if (typeof payload.coworker !== 'undefined') { request.setCoworker(payload.coworker) }
|
|
734
|
+
if (typeof payload.phone !== 'undefined') { request.setPhonesList(payload.phone) }
|
|
735
|
+
if (typeof payload.additionalInfo !== 'undefined') { request.setAdditionalInfo(payload.additionalInfo) }
|
|
736
|
+
if (typeof payload.tags !== 'undefined') { request.setTagIdsList(payload.tags) }
|
|
753
737
|
|
|
754
738
|
await util.promisify(
|
|
755
739
|
this.grpcManager.client.contactPayloadModify
|
|
@@ -893,39 +877,22 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
893
877
|
imageType,
|
|
894
878
|
PUPPET.types.Image[imageType],
|
|
895
879
|
)
|
|
880
|
+
const request = new grpcPuppet.MessageImageRequest()
|
|
881
|
+
request.setId(messageId)
|
|
882
|
+
request.setType(imageType)
|
|
896
883
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
const response = await util.promisify(
|
|
903
|
-
this.grpcManager.client.messageImage
|
|
904
|
-
.bind(this.grpcManager.client),
|
|
905
|
-
)(request)
|
|
906
|
-
|
|
907
|
-
const jsonText = response.getFileBox()
|
|
884
|
+
const response = await util.promisify(
|
|
885
|
+
this.grpcManager.client.messageImage
|
|
886
|
+
.bind(this.grpcManager.client),
|
|
887
|
+
)(request)
|
|
908
888
|
|
|
909
|
-
|
|
910
|
-
return this.FileBoxUuid.fromJSON(jsonText)
|
|
911
|
-
}
|
|
889
|
+
const jsonText = response.getFileBox()
|
|
912
890
|
|
|
913
|
-
|
|
914
|
-
|
|
891
|
+
if (jsonText) {
|
|
892
|
+
return this.FileBoxUuid.fromJSON(jsonText)
|
|
915
893
|
}
|
|
916
894
|
|
|
917
|
-
{
|
|
918
|
-
// Deprecated. Will be removed after Dec 31, 2022
|
|
919
|
-
const request = new grpcPuppet.MessageImageStreamRequest()
|
|
920
|
-
request.setId(messageId)
|
|
921
|
-
request.setType(imageType)
|
|
922
|
-
|
|
923
|
-
const pbStream = this.grpcManager.client.messageImageStream(request)
|
|
924
|
-
const fileBox = await unpackFileBoxFromPb(pbStream)
|
|
925
|
-
// const fileBoxChunkStream = unpackFileBoxChunk(stream)
|
|
926
|
-
// return unpackFileBox(fileBoxChunkStream)
|
|
927
|
-
return fileBox
|
|
928
|
-
}
|
|
895
|
+
throw new Error(`failed to get image filebox for message ${messageId}`)
|
|
929
896
|
}
|
|
930
897
|
|
|
931
898
|
override async messageContact (
|
|
@@ -1091,40 +1058,19 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1091
1058
|
override async messageFile (id: string): Promise<FileBoxInterface> {
|
|
1092
1059
|
log.verbose('PuppetService', 'messageFile(%s)', id)
|
|
1093
1060
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
this.grpcManager.client
|
|
1099
|
-
|
|
1100
|
-
)(request)
|
|
1061
|
+
const request = new grpcPuppet.MessageFileRequest()
|
|
1062
|
+
request.setId(id)
|
|
1063
|
+
const response = await util.promisify(
|
|
1064
|
+
this.grpcManager.client.messageFile
|
|
1065
|
+
.bind(this.grpcManager.client),
|
|
1066
|
+
)(request)
|
|
1101
1067
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1106
|
-
} catch (e) {
|
|
1107
|
-
log.warn('PuppetService', 'messageFile() rejection: %s', (e as Error).message)
|
|
1108
|
-
log.warn('PuppetService', [
|
|
1109
|
-
'This might because you are using Wechaty v1.x with a Puppet Service v0.x',
|
|
1110
|
-
'Contact your Wechaty Puppet Service provided to report this problem',
|
|
1111
|
-
'Related issues:',
|
|
1112
|
-
' - https://github.com/wechaty/puppet-service/issues/179',
|
|
1113
|
-
' - https://github.com/wechaty/puppet-service/pull/170',
|
|
1114
|
-
].join('\n'))
|
|
1068
|
+
const jsonText = response.getFileBox()
|
|
1069
|
+
if (jsonText) {
|
|
1070
|
+
return this.FileBoxUuid.fromJSON(jsonText)
|
|
1115
1071
|
}
|
|
1116
1072
|
|
|
1117
|
-
{
|
|
1118
|
-
// Deprecated. `MessageFileStream` Will be removed after Dec 31, 2022
|
|
1119
|
-
const request = new grpcPuppet.MessageFileStreamRequest()
|
|
1120
|
-
request.setId(id)
|
|
1121
|
-
|
|
1122
|
-
const pbStream = this.grpcManager.client.messageFileStream(request)
|
|
1123
|
-
// const fileBoxChunkStream = unpackFileBoxChunk(pbStream)
|
|
1124
|
-
// return unpackFileBox(fileBoxChunkStream)
|
|
1125
|
-
const fileBox = await unpackFileBoxFromPb(pbStream)
|
|
1126
|
-
return fileBox
|
|
1127
|
-
}
|
|
1073
|
+
throw new Error(`failed to get filebox for message ${id}`)
|
|
1128
1074
|
}
|
|
1129
1075
|
|
|
1130
1076
|
override async messagePreview (id: string): Promise<FileBoxInterface | undefined> {
|
|
@@ -1286,47 +1232,32 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1286
1232
|
): Promise<void | string> {
|
|
1287
1233
|
log.verbose('PuppetService', 'messageSendFile(%s, %s)', conversationId, fileBox)
|
|
1288
1234
|
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
request.setConversationId(conversationId)
|
|
1235
|
+
const request = new grpcPuppet.MessageSendFileRequest()
|
|
1236
|
+
request.setConversationId(conversationId)
|
|
1292
1237
|
|
|
1293
|
-
|
|
1294
|
-
|
|
1238
|
+
const serializedFileBox = await this.serializeFileBox(fileBox)
|
|
1239
|
+
request.setFileBox(serializedFileBox)
|
|
1295
1240
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1241
|
+
log.info('PuppetService', `messageSendFile(${conversationId}, ${fileBox}) about to call grpc`)
|
|
1242
|
+
const response = await util.promisify(
|
|
1243
|
+
this.grpcManager.client.messageSendFile
|
|
1244
|
+
.bind(this.grpcManager.client),
|
|
1245
|
+
)(request)
|
|
1301
1246
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1247
|
+
const messageId = response.getId()
|
|
1248
|
+
log.info('PuppetService', `messageSendFile(${conversationId}, ${fileBox}) grpc called, messageId: ${messageId}`)
|
|
1304
1249
|
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
}
|
|
1250
|
+
if (messageId) {
|
|
1251
|
+
return messageId
|
|
1252
|
+
} else {
|
|
1253
|
+
/**
|
|
1254
|
+
* Huan(202110): Deprecated: will be removed after Dec 31, 2022
|
|
1255
|
+
*/
|
|
1256
|
+
const messageIdWrapper = response.getIdStringValueDeprecated()
|
|
1257
|
+
if (messageIdWrapper) {
|
|
1258
|
+
return messageIdWrapper.getValue()
|
|
1315
1259
|
}
|
|
1316
|
-
|
|
1317
|
-
return // void
|
|
1318
|
-
|
|
1319
|
-
} catch (e) {
|
|
1320
|
-
log.verbose('PuppetService', 'messageSendFile() rejection: %s', (e as Error).message)
|
|
1321
1260
|
}
|
|
1322
|
-
|
|
1323
|
-
/**
|
|
1324
|
-
* Huan(202110): Deprecated: will be removed after Dec 31, 2022
|
|
1325
|
-
* The old server will not support `Upload` gRPC method,
|
|
1326
|
-
* which I'm expecting the above code will throw a exception,
|
|
1327
|
-
* then the below code will be executed.
|
|
1328
|
-
*/
|
|
1329
|
-
return this.messageSendFileStream(conversationId, fileBox)
|
|
1330
1261
|
}
|
|
1331
1262
|
|
|
1332
1263
|
override async messageSendContact (
|
|
@@ -1434,6 +1365,41 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
1434
1365
|
return payload
|
|
1435
1366
|
}
|
|
1436
1367
|
|
|
1368
|
+
override async getMessageBroadcastTarget (): Promise<MessageBroadcastTargets> {
|
|
1369
|
+
log.verbose('PuppetService', 'getMessageBroadcastTarget()')
|
|
1370
|
+
|
|
1371
|
+
const request = new grpcPuppet.GetMessageBroadcastTargetRequest()
|
|
1372
|
+
|
|
1373
|
+
const response = await util.promisify(
|
|
1374
|
+
this.grpcManager.client.getMessageBroadcastTarget.bind(this.grpcManager.client),
|
|
1375
|
+
)(request)
|
|
1376
|
+
|
|
1377
|
+
return {
|
|
1378
|
+
contactIds: response.getContactIdsList(),
|
|
1379
|
+
roomIds: response.getRoomIdsList(),
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
override async createMessageBroadcast (targets: string[], type: MessageBroadcastTargetType, content: PUPPET.payloads.Post): Promise<string | void> {
|
|
1384
|
+
log.verbose('PuppetService', 'createMessageBroadcast()')
|
|
1385
|
+
|
|
1386
|
+
if (!PUPPET.payloads.isPostClient(content)) {
|
|
1387
|
+
throw new Error('can only create broadcast with client post')
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
const request = new grpcPuppet.CreateMessageBroadcastRequest()
|
|
1391
|
+
const post = await postPayloadToPb(grpcPuppet, content, this.serializeFileBox.bind(this))
|
|
1392
|
+
request.setContent(post)
|
|
1393
|
+
request.setTargetIdsList(targets)
|
|
1394
|
+
request.setType(type)
|
|
1395
|
+
|
|
1396
|
+
const response = await util.promisify(
|
|
1397
|
+
this.grpcManager.client.createMessageBroadcast.bind(this.grpcManager.client),
|
|
1398
|
+
)(request)
|
|
1399
|
+
|
|
1400
|
+
return response.getId()
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1437
1403
|
/**
|
|
1438
1404
|
*
|
|
1439
1405
|
* Room
|
|
@@ -2276,53 +2242,7 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2276
2242
|
throw new Error('can only publish client post now')
|
|
2277
2243
|
}
|
|
2278
2244
|
const request = new grpcPuppet.MomentPublishRequest()
|
|
2279
|
-
const post =
|
|
2280
|
-
post.setType(grpcPuppet.PostType.POST_TYPE_MOMENT)
|
|
2281
|
-
for (const item of payload.sayableList) {
|
|
2282
|
-
const sayable = new grpcPuppet.PostSayable()
|
|
2283
|
-
switch (item.type) {
|
|
2284
|
-
case PUPPET.types.Sayable.Text:
|
|
2285
|
-
sayable.setType(grpcPuppet.SayableType.SAYABLE_TYPE_TEXT)
|
|
2286
|
-
sayable.setText(item.payload.text)
|
|
2287
|
-
sayable.setMentionIdListList(item.payload.mentions)
|
|
2288
|
-
break
|
|
2289
|
-
case PUPPET.types.Sayable.Attachment: {
|
|
2290
|
-
sayable.setType(grpcPuppet.SayableType.SAYABLE_TYPE_FILE)
|
|
2291
|
-
const serializedFileBox = typeof item.payload.filebox === 'string' ? item.payload.filebox : await this.serializeFileBox(item.payload.filebox)
|
|
2292
|
-
sayable.setFileBox(serializedFileBox)
|
|
2293
|
-
break
|
|
2294
|
-
}
|
|
2295
|
-
case PUPPET.types.Sayable.Url: {
|
|
2296
|
-
sayable.setType(grpcPuppet.SayableType.SAYABLE_TYPE_URL)
|
|
2297
|
-
const urlLinkPayload = item.payload
|
|
2298
|
-
const pbUrlLinkPayload = urlLinkPayloadToPb(grpcPuppet, urlLinkPayload)
|
|
2299
|
-
sayable.setUrlLink(pbUrlLinkPayload)
|
|
2300
|
-
break
|
|
2301
|
-
}
|
|
2302
|
-
case PUPPET.types.Sayable.Channel: {
|
|
2303
|
-
sayable.setType(grpcPuppet.SayableType.SAYABLE_TYPE_CHANNEL)
|
|
2304
|
-
const channelPayload = item.payload
|
|
2305
|
-
const pbChannelPayload = channelPayloadToPb(grpcPuppet, channelPayload)
|
|
2306
|
-
sayable.setChannel(pbChannelPayload)
|
|
2307
|
-
break
|
|
2308
|
-
}
|
|
2309
|
-
default:
|
|
2310
|
-
throw new Error(`postPublish unsupported type ${item.type}`)
|
|
2311
|
-
}
|
|
2312
|
-
post.addSayableList(sayable)
|
|
2313
|
-
}
|
|
2314
|
-
if (payload.rootId) { post.setRootId(payload.rootId) }
|
|
2315
|
-
if (payload.parentId) { post.setParentId(payload.parentId) }
|
|
2316
|
-
if (payload.location) {
|
|
2317
|
-
const location = new grpcPuppet.LocationPayload()
|
|
2318
|
-
location.setAccuracy(payload.location.accuracy)
|
|
2319
|
-
location.setAddress(payload.location.address)
|
|
2320
|
-
location.setName(payload.location.name)
|
|
2321
|
-
location.setLatitude(payload.location.latitude)
|
|
2322
|
-
location.setLongitude(payload.location.longitude)
|
|
2323
|
-
post.setLocation(location)
|
|
2324
|
-
}
|
|
2325
|
-
post.setVisibleListList(payload.visibleList || [])
|
|
2245
|
+
const post = await postPayloadToPb(grpcPuppet, payload, this.serializeFileBox.bind(this))
|
|
2326
2246
|
request.setPost(post)
|
|
2327
2247
|
|
|
2328
2248
|
const result = await util.promisify(
|
|
@@ -2520,43 +2440,6 @@ class PuppetService extends PUPPET.Puppet {
|
|
|
2520
2440
|
return contactIdsList
|
|
2521
2441
|
}
|
|
2522
2442
|
|
|
2523
|
-
/**
|
|
2524
|
-
* @deprecated Will be removed in v2.0
|
|
2525
|
-
*/
|
|
2526
|
-
private async messageSendFileStream (
|
|
2527
|
-
conversationId : string,
|
|
2528
|
-
file : FileBoxInterface,
|
|
2529
|
-
): Promise<void | string> {
|
|
2530
|
-
const request = await packConversationIdFileBoxToPb(grpcPuppet.MessageSendFileStreamRequest)(conversationId, file)
|
|
2531
|
-
|
|
2532
|
-
const response = await new Promise<grpcPuppet.MessageSendFileStreamResponse>((resolve, reject) => {
|
|
2533
|
-
const stream = this.grpcManager.client.messageSendFileStream((err, response) => {
|
|
2534
|
-
if (err) {
|
|
2535
|
-
reject(err)
|
|
2536
|
-
} else {
|
|
2537
|
-
resolve(response)
|
|
2538
|
-
}
|
|
2539
|
-
})
|
|
2540
|
-
request.pipe(stream as unknown as Writable) // Huan(202203): FIXME: as unknown as
|
|
2541
|
-
})
|
|
2542
|
-
|
|
2543
|
-
const messageId = response.getId()
|
|
2544
|
-
|
|
2545
|
-
if (messageId) {
|
|
2546
|
-
return messageId
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
{
|
|
2550
|
-
/**
|
|
2551
|
-
* Huan(202110): Deprecated: will be removed after Dec 31, 2022
|
|
2552
|
-
*/
|
|
2553
|
-
const messageIdWrapper = response.getIdStringValueDeprecated()
|
|
2554
|
-
if (messageIdWrapper) {
|
|
2555
|
-
return messageIdWrapper.getValue()
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
|
|
2560
2443
|
healthCheckInterval?: NodeJS.Timer
|
|
2561
2444
|
startHealthCheck () {
|
|
2562
2445
|
this.healthCheckInterval = setInterval(() => {
|
package/src/package-json.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { PackageJson } from 'type-fest'
|
|
5
5
|
export const packageJson: PackageJson = {
|
|
6
6
|
"name": "@juzi/wechaty-puppet-service",
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.45",
|
|
8
8
|
"description": "Puppet Service for Wechaty",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
@@ -55,7 +55,7 @@ export const packageJson: PackageJson = {
|
|
|
55
55
|
"@chatie/eslint-config": "^1.0.4",
|
|
56
56
|
"@chatie/semver": "^0.4.7",
|
|
57
57
|
"@chatie/tsconfig": "^4.6.3",
|
|
58
|
-
"@juzi/wechaty-puppet": "^1.0.
|
|
58
|
+
"@juzi/wechaty-puppet": "^1.0.50",
|
|
59
59
|
"@juzi/wechaty-puppet-mock": "^1.0.1",
|
|
60
60
|
"@types/google-protobuf": "^3.15.5",
|
|
61
61
|
"@types/lru-cache": "^7.5.0",
|
|
@@ -63,6 +63,7 @@ export const packageJson: PackageJson = {
|
|
|
63
63
|
"@types/temp": "^0.9.1",
|
|
64
64
|
"@types/uuid": "^8.3.4",
|
|
65
65
|
"@types/ws": "^8.5.3",
|
|
66
|
+
"esquery": "1.4.0",
|
|
66
67
|
"get-port": "^6.1.2",
|
|
67
68
|
"temp": "^0.9.4",
|
|
68
69
|
"typed-emitter": "^1.5.0-from-event",
|
|
@@ -73,7 +74,7 @@ export const packageJson: PackageJson = {
|
|
|
73
74
|
"@juzi/wechaty-puppet": "^1.0.46"
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
|
-
"@juzi/wechaty-grpc": "^1.0.
|
|
77
|
+
"@juzi/wechaty-grpc": "^1.0.45",
|
|
77
78
|
"@juzi/wechaty-redux": "^1.0.1",
|
|
78
79
|
"clone-class": "^1.1.1",
|
|
79
80
|
"ducks": "^1.0.2",
|
|
@@ -34,11 +34,6 @@ import type {
|
|
|
34
34
|
import * as PUPPET from '@juzi/wechaty-puppet'
|
|
35
35
|
import { timeoutPromise } from 'gerror'
|
|
36
36
|
|
|
37
|
-
import {
|
|
38
|
-
packFileBoxToPb,
|
|
39
|
-
unpackConversationIdFileBoxArgsFromPb,
|
|
40
|
-
} from '../deprecated/mod.js'
|
|
41
|
-
|
|
42
37
|
import {
|
|
43
38
|
timestampFromMilliseconds,
|
|
44
39
|
} from '../pure-functions/timestamp.js'
|
|
@@ -48,7 +43,7 @@ import {
|
|
|
48
43
|
import { log } from '../config.js'
|
|
49
44
|
import { grpcError } from './grpc-error.js'
|
|
50
45
|
import { EventStreamManager } from './event-stream-manager.js'
|
|
51
|
-
import { channelPayloadToPb,
|
|
46
|
+
import { channelPayloadToPb, postPbToPayload, urlLinkPayloadToPb } from '../utils/pb-payload-helper.js'
|
|
52
47
|
|
|
53
48
|
function puppetImplementation (
|
|
54
49
|
puppet : PUPPET.impls.PuppetInterface,
|
|
@@ -630,27 +625,6 @@ function puppetImplementation (
|
|
|
630
625
|
}
|
|
631
626
|
},
|
|
632
627
|
|
|
633
|
-
/**
|
|
634
|
-
* @deprecated will be removed after Dec 31, 2022
|
|
635
|
-
*/
|
|
636
|
-
messageFileStream: async (call) => {
|
|
637
|
-
log.verbose('PuppetServiceImpl', 'messageFileStream()')
|
|
638
|
-
|
|
639
|
-
try {
|
|
640
|
-
const id = call.request.getId()
|
|
641
|
-
|
|
642
|
-
const fileBox = await puppet.messageFile(id)
|
|
643
|
-
const response = await packFileBoxToPb(grpcPuppet.MessageFileStreamResponse)(fileBox)
|
|
644
|
-
|
|
645
|
-
response.on('error', e => call.destroy(e as Error))
|
|
646
|
-
response.pipe(call as unknown as Writable) // Huan(202203): FIXME: as unknown as
|
|
647
|
-
|
|
648
|
-
} catch (e) {
|
|
649
|
-
log.error('PuppetServiceImpl', 'grpcError() messageFileStream() rejection: %s', e && (e as Error).message)
|
|
650
|
-
call.destroy(e as Error)
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
|
-
|
|
654
628
|
messageForward: async (call, callback) => {
|
|
655
629
|
log.verbose('PuppetServiceImpl', 'messageForward()')
|
|
656
630
|
|
|
@@ -700,28 +674,6 @@ function puppetImplementation (
|
|
|
700
674
|
}
|
|
701
675
|
},
|
|
702
676
|
|
|
703
|
-
/**
|
|
704
|
-
* @deprecated will be removed after Dec 31, 2022
|
|
705
|
-
*/
|
|
706
|
-
messageImageStream: async (call) => {
|
|
707
|
-
log.verbose('PuppetServiceImpl', 'messageImageStream()')
|
|
708
|
-
|
|
709
|
-
try {
|
|
710
|
-
const id = call.request.getId()
|
|
711
|
-
const type = call.request.getType()
|
|
712
|
-
|
|
713
|
-
const fileBox = await puppet.messageImage(id, type) // as number as PUPPET.types.Image
|
|
714
|
-
const response = await packFileBoxToPb(grpcPuppet.MessageImageStreamResponse)(fileBox)
|
|
715
|
-
|
|
716
|
-
response.on('error', e => call.destroy(e as Error))
|
|
717
|
-
response.pipe(call as unknown as Writable) // Huan(202203) FIXME: as unknown as
|
|
718
|
-
|
|
719
|
-
} catch (e) {
|
|
720
|
-
log.error('PuppetServiceImpl', 'grpcError() messageImageStream() rejection: %s', (e as Error).message)
|
|
721
|
-
call.destroy(e as Error)
|
|
722
|
-
}
|
|
723
|
-
},
|
|
724
|
-
|
|
725
677
|
messageLocation: async (call, callback) => {
|
|
726
678
|
log.verbose('PuppetServiceImpl', 'messageLocation()')
|
|
727
679
|
|
|
@@ -942,40 +894,6 @@ function puppetImplementation (
|
|
|
942
894
|
}
|
|
943
895
|
},
|
|
944
896
|
|
|
945
|
-
/**
|
|
946
|
-
* @deprecated will be removed after Dec 31, 2022
|
|
947
|
-
*/
|
|
948
|
-
messageSendFileStream: async (call, callback) => {
|
|
949
|
-
log.verbose('PuppetServiceImpl', 'messageSendFileStream()')
|
|
950
|
-
|
|
951
|
-
try {
|
|
952
|
-
const requestArgs = await unpackConversationIdFileBoxArgsFromPb(call)
|
|
953
|
-
const conversationId = requestArgs.conversationId
|
|
954
|
-
const fileBox = requestArgs.fileBox
|
|
955
|
-
|
|
956
|
-
const messageId = await puppet.messageSendFile(conversationId, fileBox)
|
|
957
|
-
|
|
958
|
-
const response = new grpcPuppet.MessageSendFileStreamResponse()
|
|
959
|
-
|
|
960
|
-
if (messageId) {
|
|
961
|
-
response.setId(messageId)
|
|
962
|
-
{
|
|
963
|
-
/**
|
|
964
|
-
* Huan(202110): Deprecated: will be removed after Dec 31, 2022
|
|
965
|
-
*/
|
|
966
|
-
const idWrapper = new StringValue()
|
|
967
|
-
idWrapper.setValue(messageId)
|
|
968
|
-
response.setIdStringValueDeprecated(idWrapper)
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
return callback(null, response)
|
|
973
|
-
|
|
974
|
-
} catch (e) {
|
|
975
|
-
return grpcError('messageSendFileStream', e, callback)
|
|
976
|
-
}
|
|
977
|
-
},
|
|
978
|
-
|
|
979
897
|
messageSendLocation: async (call, callback) => {
|
|
980
898
|
log.verbose('PuppetServiceImpl', 'messageSendLocation()')
|
|
981
899
|
|
|
@@ -1182,6 +1100,54 @@ function puppetImplementation (
|
|
|
1182
1100
|
}
|
|
1183
1101
|
},
|
|
1184
1102
|
|
|
1103
|
+
getMessageBroadcastTarget: async (call, callback) => {
|
|
1104
|
+
log.verbose('PuppetServiceImpl', 'getMessageBroadcastTarget()')
|
|
1105
|
+
|
|
1106
|
+
void call
|
|
1107
|
+
try {
|
|
1108
|
+
const payload = await puppet.getMessageBroadcastTarget()
|
|
1109
|
+
|
|
1110
|
+
const response = new grpcPuppet.GetMessageBroadcastTargetResponse()
|
|
1111
|
+
response.setContactIdsList(payload.contactIds || [])
|
|
1112
|
+
response.setRoomIdsList(payload.roomIds || [])
|
|
1113
|
+
|
|
1114
|
+
return callback(null, response)
|
|
1115
|
+
} catch (e) {
|
|
1116
|
+
return grpcError('getMessageBroadcastTarget', e, callback)
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
|
|
1120
|
+
createMessageBroadcast: async (call, callback) => {
|
|
1121
|
+
log.verbose('PuppetServiceImpl', 'createMessageBroadcast()')
|
|
1122
|
+
|
|
1123
|
+
try {
|
|
1124
|
+
const targets = call.request.getTargetIdsList()
|
|
1125
|
+
const type = call.request.getType()
|
|
1126
|
+
const post = call.request.getContent()
|
|
1127
|
+
|
|
1128
|
+
if (!post) {
|
|
1129
|
+
throw new Error('no post found')
|
|
1130
|
+
}
|
|
1131
|
+
if (post.getType() !== grpcPuppet.PostType.POST_TYPE_BROADCAST) {
|
|
1132
|
+
throw new Error('cannot create broadcast with non-broadcast post')
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
const payload = postPbToPayload(post, FileBoxUuid)
|
|
1136
|
+
|
|
1137
|
+
const id = await puppet.createMessageBroadcast(targets, type, payload)
|
|
1138
|
+
|
|
1139
|
+
const response = new grpcPuppet.CreateMessageBroadcastResponse()
|
|
1140
|
+
if (id) {
|
|
1141
|
+
response.setId(id)
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
return callback(null, response)
|
|
1145
|
+
|
|
1146
|
+
} catch (e) {
|
|
1147
|
+
return grpcError('createMessageBroadcast', e, callback)
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
|
|
1185
1151
|
roomAdd: async (call, callback) => {
|
|
1186
1152
|
log.verbose('PuppetServiceImpl', 'roomAdd()')
|
|
1187
1153
|
|
|
@@ -1846,67 +1812,7 @@ function puppetImplementation (
|
|
|
1846
1812
|
if (type !== grpcPuppet.PostType.POST_TYPE_MOMENT) {
|
|
1847
1813
|
throw new Error('cannot publish non-moment post')
|
|
1848
1814
|
}
|
|
1849
|
-
const payload
|
|
1850
|
-
type: PUPPET.types.Post.Moment,
|
|
1851
|
-
sayableList: [],
|
|
1852
|
-
rootId: post.getRootId(),
|
|
1853
|
-
parentId: post.getParentId(),
|
|
1854
|
-
visibleList: post.getVisibleListList(),
|
|
1855
|
-
}
|
|
1856
|
-
const sayableList = post.getSayableListList()
|
|
1857
|
-
for (const sayable of sayableList) {
|
|
1858
|
-
let sayablePayload: PUPPET.payloads.Sayable | undefined
|
|
1859
|
-
switch (sayable.getType()) {
|
|
1860
|
-
case grpcPuppet.SayableType.SAYABLE_TYPE_TEXT:
|
|
1861
|
-
sayablePayload = PUPPET.payloads.sayable.text(sayable.getText() || '', sayable.getMentionIdListList())
|
|
1862
|
-
break
|
|
1863
|
-
case grpcPuppet.SayableType.SAYABLE_TYPE_FILE: {
|
|
1864
|
-
const fileJsonStr = sayable.getFileBox()
|
|
1865
|
-
if (!fileJsonStr) {
|
|
1866
|
-
break
|
|
1867
|
-
}
|
|
1868
|
-
const file = FileBoxUuid.fromJSON(fileJsonStr)
|
|
1869
|
-
sayablePayload = PUPPET.payloads.sayable.attachment(file)
|
|
1870
|
-
break
|
|
1871
|
-
}
|
|
1872
|
-
case grpcPuppet.SayableType.SAYABLE_TYPE_URL: {
|
|
1873
|
-
const urlLinkPayloadPb = sayable.getUrlLink()
|
|
1874
|
-
if (!urlLinkPayloadPb) {
|
|
1875
|
-
break
|
|
1876
|
-
}
|
|
1877
|
-
const urlLinkPayload = urlLinkPbToPayload(urlLinkPayloadPb)
|
|
1878
|
-
sayablePayload = PUPPET.payloads.sayable.url(urlLinkPayload)
|
|
1879
|
-
break
|
|
1880
|
-
}
|
|
1881
|
-
case grpcPuppet.SayableType.SAYABLE_TYPE_CHANNEL: {
|
|
1882
|
-
const channelPayloadPb = sayable.getChannel()
|
|
1883
|
-
if (!channelPayloadPb) {
|
|
1884
|
-
break
|
|
1885
|
-
}
|
|
1886
|
-
const channelPayload = channelPbToPayload(channelPayloadPb!)
|
|
1887
|
-
sayablePayload = PUPPET.payloads.sayable.channel(channelPayload)
|
|
1888
|
-
break
|
|
1889
|
-
}
|
|
1890
|
-
default:
|
|
1891
|
-
throw new Error(`unsupported postSayableType type ${sayable.getType()}`)
|
|
1892
|
-
}
|
|
1893
|
-
if (sayablePayload) {
|
|
1894
|
-
payload.sayableList.push(sayablePayload)
|
|
1895
|
-
} else {
|
|
1896
|
-
throw new Error(`unable to fetch sayable from ${JSON.stringify(sayable.toObject())}`)
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
const location = post.getLocation()
|
|
1901
|
-
if (location) {
|
|
1902
|
-
payload.location = {
|
|
1903
|
-
name: location.getName() || '',
|
|
1904
|
-
accuracy: location.getAccuracy() || 15,
|
|
1905
|
-
address: location.getAddress() || '',
|
|
1906
|
-
latitude: location.getLatitude(),
|
|
1907
|
-
longitude: location.getLatitude(),
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1815
|
+
const payload = postPbToPayload(post, FileBoxUuid)
|
|
1910
1816
|
|
|
1911
1817
|
const momentId = await puppet.postPublish(payload)
|
|
1912
1818
|
const response = new grpcPuppet.MomentPublishResponse()
|