@juzi/wechaty 1.0.16 → 1.0.19
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/mods/impls.d.ts +3 -3
- package/dist/cjs/src/mods/impls.d.ts.map +1 -1
- package/dist/cjs/src/mods/impls.js +2 -1
- package/dist/cjs/src/mods/impls.js.map +1 -1
- package/dist/cjs/src/mods/users.d.ts +1 -1
- package/dist/cjs/src/mods/users.d.ts.map +1 -1
- package/dist/cjs/src/package-json.js +4 -4
- package/dist/cjs/src/package-json.js.map +1 -1
- package/dist/cjs/src/pure-functions/update.d.ts +9 -0
- package/dist/cjs/src/pure-functions/update.d.ts.map +1 -0
- package/dist/cjs/src/pure-functions/update.js +73 -0
- package/dist/cjs/src/pure-functions/update.js.map +1 -0
- package/dist/cjs/src/schemas/contact-events.d.ts +4 -1
- package/dist/cjs/src/schemas/contact-events.d.ts.map +1 -1
- package/dist/cjs/src/schemas/contact-events.js.map +1 -1
- package/dist/cjs/src/schemas/room-events.d.ts +5 -1
- package/dist/cjs/src/schemas/room-events.d.ts.map +1 -1
- package/dist/cjs/src/schemas/room-events.js +1 -0
- package/dist/cjs/src/schemas/room-events.js.map +1 -1
- package/dist/cjs/src/schemas/update.d.ts +12 -0
- package/dist/cjs/src/schemas/update.d.ts.map +1 -0
- package/dist/cjs/src/schemas/update.js +3 -0
- package/dist/cjs/src/schemas/update.js.map +1 -0
- package/dist/cjs/src/schemas/wechaty-events.d.ts +5 -1
- package/dist/cjs/src/schemas/wechaty-events.d.ts.map +1 -1
- package/dist/cjs/src/schemas/wechaty-events.js +1 -0
- package/dist/cjs/src/schemas/wechaty-events.js.map +1 -1
- package/dist/cjs/src/user-modules/contact.d.ts +8 -0
- package/dist/cjs/src/user-modules/contact.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/contact.js +18 -4
- package/dist/cjs/src/user-modules/contact.js.map +1 -1
- package/dist/cjs/src/user-modules/mod.d.ts +4 -3
- package/dist/cjs/src/user-modules/mod.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/mod.js +3 -1
- package/dist/cjs/src/user-modules/mod.js.map +1 -1
- package/dist/cjs/src/user-modules/tag-group.d.ts +60 -0
- package/dist/cjs/src/user-modules/tag-group.d.ts.map +1 -0
- package/dist/cjs/src/user-modules/tag-group.js +71 -0
- package/dist/cjs/src/user-modules/tag-group.js.map +1 -0
- package/dist/cjs/src/user-modules/tag.d.ts +37 -64
- package/dist/cjs/src/user-modules/tag.d.ts.map +1 -1
- package/dist/cjs/src/user-modules/tag.js +52 -127
- package/dist/cjs/src/user-modules/tag.js.map +1 -1
- package/dist/cjs/src/wechaty/wechaty-base.d.ts +22 -12
- package/dist/cjs/src/wechaty/wechaty-base.d.ts.map +1 -1
- package/dist/cjs/src/wechaty/wechaty-impl.spec.js +5 -3
- package/dist/cjs/src/wechaty/wechaty-impl.spec.js.map +1 -1
- package/dist/cjs/src/wechaty-mixins/gerror-mixin.d.ts +1 -1
- package/dist/cjs/src/wechaty-mixins/io-mixin.d.ts +2 -2
- package/dist/cjs/src/wechaty-mixins/login-mixin.d.ts +11 -5
- package/dist/cjs/src/wechaty-mixins/login-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/misc-mixin.d.ts +14 -14
- package/dist/cjs/src/wechaty-mixins/misc-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/plugin-mixin.d.ts +14 -6
- package/dist/cjs/src/wechaty-mixins/plugin-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts +10 -24
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.js +23 -0
- package/dist/cjs/src/wechaty-mixins/puppet-mixin.js.map +1 -1
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +5 -3
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.d.ts.map +1 -1
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.js +3 -0
- package/dist/cjs/src/wechaty-mixins/wechatify-user-module-mixin.js.map +1 -1
- package/dist/esm/src/mods/impls.d.ts +3 -3
- package/dist/esm/src/mods/impls.d.ts.map +1 -1
- package/dist/esm/src/mods/impls.js +1 -1
- package/dist/esm/src/mods/impls.js.map +1 -1
- package/dist/esm/src/mods/users.d.ts +1 -1
- package/dist/esm/src/mods/users.d.ts.map +1 -1
- package/dist/esm/src/package-json.js +4 -4
- package/dist/esm/src/package-json.js.map +1 -1
- package/dist/esm/src/pure-functions/update.d.ts +9 -0
- package/dist/esm/src/pure-functions/update.d.ts.map +1 -0
- package/dist/esm/src/pure-functions/update.js +69 -0
- package/dist/esm/src/pure-functions/update.js.map +1 -0
- package/dist/esm/src/schemas/contact-events.d.ts +4 -1
- package/dist/esm/src/schemas/contact-events.d.ts.map +1 -1
- package/dist/esm/src/schemas/contact-events.js.map +1 -1
- package/dist/esm/src/schemas/room-events.d.ts +5 -1
- package/dist/esm/src/schemas/room-events.d.ts.map +1 -1
- package/dist/esm/src/schemas/room-events.js +1 -0
- package/dist/esm/src/schemas/room-events.js.map +1 -1
- package/dist/esm/src/schemas/update.d.ts +12 -0
- package/dist/esm/src/schemas/update.d.ts.map +1 -0
- package/dist/esm/src/schemas/update.js +2 -0
- package/dist/esm/src/schemas/update.js.map +1 -0
- package/dist/esm/src/schemas/wechaty-events.d.ts +5 -1
- package/dist/esm/src/schemas/wechaty-events.d.ts.map +1 -1
- package/dist/esm/src/schemas/wechaty-events.js +1 -0
- package/dist/esm/src/schemas/wechaty-events.js.map +1 -1
- package/dist/esm/src/user-modules/contact.d.ts +8 -0
- package/dist/esm/src/user-modules/contact.d.ts.map +1 -1
- package/dist/esm/src/user-modules/contact.js +18 -4
- package/dist/esm/src/user-modules/contact.js.map +1 -1
- package/dist/esm/src/user-modules/mod.d.ts +4 -3
- package/dist/esm/src/user-modules/mod.d.ts.map +1 -1
- package/dist/esm/src/user-modules/mod.js +2 -1
- package/dist/esm/src/user-modules/mod.js.map +1 -1
- package/dist/esm/src/user-modules/tag-group.d.ts +60 -0
- package/dist/esm/src/user-modules/tag-group.d.ts.map +1 -0
- package/dist/esm/src/user-modules/tag-group.js +68 -0
- package/dist/esm/src/user-modules/tag-group.js.map +1 -0
- package/dist/esm/src/user-modules/tag.d.ts +37 -64
- package/dist/esm/src/user-modules/tag.d.ts.map +1 -1
- package/dist/esm/src/user-modules/tag.js +52 -127
- package/dist/esm/src/user-modules/tag.js.map +1 -1
- package/dist/esm/src/wechaty/wechaty-base.d.ts +22 -12
- package/dist/esm/src/wechaty/wechaty-base.d.ts.map +1 -1
- package/dist/esm/src/wechaty/wechaty-impl.spec.js +5 -3
- package/dist/esm/src/wechaty/wechaty-impl.spec.js.map +1 -1
- package/dist/esm/src/wechaty-mixins/gerror-mixin.d.ts +1 -1
- package/dist/esm/src/wechaty-mixins/io-mixin.d.ts +2 -2
- package/dist/esm/src/wechaty-mixins/login-mixin.d.ts +11 -5
- package/dist/esm/src/wechaty-mixins/login-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/misc-mixin.d.ts +14 -14
- package/dist/esm/src/wechaty-mixins/misc-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/plugin-mixin.d.ts +14 -6
- package/dist/esm/src/wechaty-mixins/plugin-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts +10 -24
- package/dist/esm/src/wechaty-mixins/puppet-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/puppet-mixin.js +23 -0
- package/dist/esm/src/wechaty-mixins/puppet-mixin.js.map +1 -1
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.d.ts +5 -3
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.d.ts.map +1 -1
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.js +4 -1
- package/dist/esm/src/wechaty-mixins/wechatify-user-module-mixin.js.map +1 -1
- package/package.json +3 -3
- package/src/mods/impls.ts +3 -0
- package/src/mods/users.ts +1 -0
- package/src/package-json.ts +4 -4
- package/src/pure-functions/update.ts +68 -0
- package/src/schemas/contact-events.ts +4 -0
- package/src/schemas/room-events.ts +5 -0
- package/src/schemas/update.ts +14 -0
- package/src/schemas/wechaty-events.ts +5 -1
- package/src/user-modules/contact.ts +26 -4
- package/src/user-modules/mod.ts +8 -0
- package/src/user-modules/tag-group.ts +115 -0
- package/src/user-modules/tag.ts +61 -124
- package/src/wechaty/wechaty-impl.spec.ts +3 -0
- package/src/wechaty-mixins/puppet-mixin.ts +24 -0
- package/src/wechaty-mixins/wechatify-user-module-mixin.ts +6 -0
package/src/user-modules/tag.ts
CHANGED
|
@@ -17,169 +17,106 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
-
import
|
|
21
|
-
log,
|
|
22
|
-
} from '@juzi/wechaty-puppet'
|
|
23
|
-
|
|
24
|
-
import type { Constructor } from 'clone-class'
|
|
20
|
+
import type * as PUPPET from '@juzi/wechaty-puppet'
|
|
25
21
|
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
22
|
+
import type { Constructor } from 'clone-class'
|
|
23
|
+
import { log } from '../config.js'
|
|
28
24
|
|
|
29
|
-
import {
|
|
30
|
-
poolifyMixin,
|
|
31
|
-
} from '../user-mixins/poolify.js'
|
|
32
25
|
import { validationMixin } from '../user-mixins/validation.js'
|
|
33
26
|
import {
|
|
34
27
|
wechatifyMixinBase,
|
|
35
28
|
} from '../user-mixins/wechatify.js'
|
|
29
|
+
import type { ContactInterface } from './contact.js'
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
wechatifyMixinBase(),
|
|
39
|
-
)<TagInterface>()
|
|
31
|
+
class TagMixin extends wechatifyMixinBase() {
|
|
40
32
|
|
|
41
|
-
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* Create
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
static create (payload: PUPPET.payloads.Tag): TagInterface {
|
|
39
|
+
log.verbose('Tag', 'create()')
|
|
40
|
+
|
|
41
|
+
return new this(payload)
|
|
42
|
+
}
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* @hideconstructor
|
|
45
46
|
*/
|
|
46
47
|
constructor (
|
|
47
|
-
public readonly
|
|
48
|
+
public readonly payload: PUPPET.payloads.Tag,
|
|
48
49
|
) {
|
|
49
50
|
super()
|
|
50
|
-
log.silly('Tag',
|
|
51
|
+
log.silly('Tag', 'constructor()')
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*
|
|
56
|
-
* > Tips:
|
|
57
|
-
* This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/Chatie/wechaty/wiki/Puppet#3-puppet-compatible-table)
|
|
58
|
-
*
|
|
59
|
-
* @static
|
|
60
|
-
* @param {string} [tag] the tag name which want to create
|
|
61
|
-
* @returns {Promise<TagImpl>}
|
|
62
|
-
* @example
|
|
63
|
-
* const bot = new Wechaty()
|
|
64
|
-
* await bot.Tag.get('TagName')
|
|
65
|
-
*/
|
|
66
|
-
static async get (
|
|
67
|
-
tag: string,
|
|
68
|
-
): Promise<TagInterface> {
|
|
69
|
-
log.verbose('Tag', 'get(%s)', tag)
|
|
70
|
-
return this.load(tag)
|
|
54
|
+
id (): string {
|
|
55
|
+
return this.payload.id
|
|
71
56
|
}
|
|
72
57
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* If you want to delete a tag, please make sure there's no more Contact/Favorite(s) are using this tag.
|
|
77
|
-
* If this tag is be used by any Contact/Favorite, then it can not be deleted.
|
|
78
|
-
* (This is for protecting the tag being deleted by mistake)
|
|
79
|
-
*
|
|
80
|
-
* @static
|
|
81
|
-
* @returns {Promise<TagInterface[]>}
|
|
82
|
-
* @example
|
|
83
|
-
* const tag = wechaty.Tag.get('tag')
|
|
84
|
-
* await wechaty.Tag.delete(tag)
|
|
85
|
-
*/
|
|
58
|
+
type (): PUPPET.types.Tag {
|
|
59
|
+
return this.payload.type
|
|
60
|
+
}
|
|
86
61
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
static async delete (
|
|
91
|
-
tag: TagInterface,
|
|
92
|
-
target?: typeof ContactImpl | typeof FavoriteImpl,
|
|
93
|
-
): Promise<void> {
|
|
94
|
-
log.verbose('Tag', 'static delete(%s)', tag)
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Huan(202110) TODO: refactory this design:
|
|
98
|
-
* 1. we should not pass `typeof ContactImpl` as argument
|
|
99
|
-
* 2. find a better way to manage tag.
|
|
100
|
-
*/
|
|
62
|
+
groupId (): string {
|
|
63
|
+
return this.payload.groupId || ''
|
|
64
|
+
}
|
|
101
65
|
|
|
102
|
-
|
|
66
|
+
name (): string {
|
|
67
|
+
return this.payload.name
|
|
68
|
+
}
|
|
103
69
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*/
|
|
70
|
+
static async list (): Promise<TagInterface[]> {
|
|
71
|
+
log.verbose('Tag', 'list()')
|
|
107
72
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// } else if (!target || target === Favorite || target === this.wechaty.Favorite) {
|
|
112
|
-
// await this.wechaty.puppet.tagFavoriteDelete(tag.id)
|
|
113
|
-
}
|
|
73
|
+
try {
|
|
74
|
+
const payloads = await this.wechaty.puppet.tagTagList()
|
|
75
|
+
return payloads.map(payload => new this(payload))
|
|
114
76
|
} catch (e) {
|
|
115
77
|
this.wechaty.emitError(e)
|
|
116
|
-
log.error('Tag', '
|
|
78
|
+
log.error('Tag', 'list() exception: %s', (e as Error).message)
|
|
79
|
+
return []
|
|
117
80
|
}
|
|
118
81
|
}
|
|
119
82
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
* 1. we should not pass `typeof ContactImpl` as argument
|
|
139
|
-
* 2. use instanceof to check the type of `to`
|
|
140
|
-
*/
|
|
83
|
+
async contactList (): Promise<ContactInterface[]> {
|
|
84
|
+
log.verbose('Tag', 'contactList() for tag id: %s', this.id())
|
|
85
|
+
|
|
86
|
+
const contactIds = await this.wechaty.puppet.tagTagContactList(this.groupId(), this.id())
|
|
87
|
+
const contactPromises = contactIds.map(id => this.wechaty.Contact.find({ id })) as Promise<ContactInterface>[]
|
|
88
|
+
return Promise.all(contactPromises)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async tag (contact: ContactInterface): Promise<void> {
|
|
92
|
+
log.verbose('Tag', 'tag(%s) for tag id: %s', contact, this.id())
|
|
93
|
+
|
|
94
|
+
const contactId = contact.id
|
|
95
|
+
await this.wechaty.puppet.tagContactTagAdd(this.groupId(), this.id(), contactId)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static async createTag (tagGroupId: string | undefined, name: string): Promise<TagInterface | void> {
|
|
99
|
+
log.verbose('Tag', 'createTag(%s, %s)', tagGroupId, name)
|
|
100
|
+
|
|
141
101
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// TODO: await this.wechaty.puppet.tagAddFavorite(this.tag, to.id)
|
|
102
|
+
const payload = await this.wechaty.puppet.tagTagAdd(tagGroupId, name)
|
|
103
|
+
if (payload) {
|
|
104
|
+
return new this(payload)
|
|
146
105
|
}
|
|
147
106
|
} catch (e) {
|
|
148
107
|
this.wechaty.emitError(e)
|
|
149
|
-
log.error('
|
|
150
|
-
throw new Error(`add error : ${(e as Error)}`)
|
|
108
|
+
log.error('Contact', 'createTag() exception: %s', (e as Error).message)
|
|
151
109
|
}
|
|
152
110
|
}
|
|
153
111
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
*
|
|
157
|
-
* > Tips:
|
|
158
|
-
* This function is depending on the Puppet Implementation, see [puppet-compatible-table](https://github.com/Chatie/wechaty/wiki/Puppet#3-puppet-compatible-table)
|
|
159
|
-
*
|
|
160
|
-
* @returns {Promise<void>}
|
|
161
|
-
* @example
|
|
162
|
-
* await tag.remove(contact)
|
|
163
|
-
*/
|
|
164
|
-
async remove (from: ContactInterface | FavoriteInterface): Promise<void> {
|
|
165
|
-
log.verbose('Tag', 'remove(%s) for %s', from, this.id)
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Huan(202110): TODO: refactory this design:
|
|
169
|
-
* 1. we should not pass `typeof ContactImpl` as argument
|
|
170
|
-
* 2. use instanceof to check the type of `to`
|
|
171
|
-
*/
|
|
112
|
+
static async deleteTag (tag: TagInterface): Promise<void> {
|
|
113
|
+
log.verbose('Tag', 'deleteTag(%s, %s)', tag)
|
|
172
114
|
|
|
173
115
|
try {
|
|
174
|
-
|
|
175
|
-
await this.wechaty.puppet.tagContactRemove(this.id, from.id)
|
|
176
|
-
} else if (from instanceof FavoriteImpl) {
|
|
177
|
-
// TODO await this.wechaty.puppet.tagRemoveFavorite(this.tag, from.id)
|
|
178
|
-
}
|
|
116
|
+
await this.wechaty.puppet.tagTagDelete(tag.groupId(), tag.id())
|
|
179
117
|
} catch (e) {
|
|
180
118
|
this.wechaty.emitError(e)
|
|
181
|
-
log.error('
|
|
182
|
-
throw new Error(`remove error : ${e}`)
|
|
119
|
+
log.error('Contact', 'deleteTag() exception: %s', (e as Error).message)
|
|
183
120
|
}
|
|
184
121
|
}
|
|
185
122
|
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
RoomConstructor,
|
|
18
18
|
DelayConstructor,
|
|
19
19
|
TagConstructor,
|
|
20
|
+
TagGroupConstructor,
|
|
20
21
|
UrlLinkConstructor,
|
|
21
22
|
MessageInterface,
|
|
22
23
|
ChannelConstructor,
|
|
@@ -45,6 +46,7 @@ test('Wechaty interface', async t => {
|
|
|
45
46
|
Room : RoomConstructor
|
|
46
47
|
RoomInvitation : RoomInvitationConstructor
|
|
47
48
|
Tag : TagConstructor
|
|
49
|
+
TagGroup : TagGroupConstructor
|
|
48
50
|
UrlLink : UrlLinkConstructor
|
|
49
51
|
Channel : ChannelConstructor
|
|
50
52
|
|
|
@@ -63,6 +65,7 @@ test('Wechaty interface', async t => {
|
|
|
63
65
|
= this.Room
|
|
64
66
|
= this.RoomInvitation
|
|
65
67
|
= this.Tag
|
|
68
|
+
= this.TagGroup
|
|
66
69
|
= this.UrlLink
|
|
67
70
|
= this.Channel
|
|
68
71
|
= {} as any
|
|
@@ -25,6 +25,8 @@ import type {
|
|
|
25
25
|
|
|
26
26
|
import type { GErrorMixin } from './gerror-mixin.js'
|
|
27
27
|
import type { IoMixin } from './io-mixin.js'
|
|
28
|
+
import type { InfoUpdateInterface } from '../schemas/update.js'
|
|
29
|
+
import { diffPayload } from '../pure-functions/update.js'
|
|
28
30
|
|
|
29
31
|
const PUPPET_MEMORY_NAME = 'puppet'
|
|
30
32
|
|
|
@@ -438,12 +440,34 @@ const puppetMixin = <MixinBase extends WechatifyUserModuleMixin & GErrorMixin &
|
|
|
438
440
|
switch (payloadType) {
|
|
439
441
|
case PUPPET.types.Payload.Contact: {
|
|
440
442
|
const contact = await this.Contact.find({ id: payloadId }) as unknown as undefined | ContactImpl
|
|
443
|
+
const oldPayload = JSON.parse(JSON.stringify(contact?.payload || {}))
|
|
441
444
|
await contact?.ready(true)
|
|
445
|
+
const newPayload = JSON.parse(JSON.stringify(contact?.payload || {}))
|
|
446
|
+
const updateEvent: InfoUpdateInterface = {
|
|
447
|
+
type: payloadType,
|
|
448
|
+
id: payloadId,
|
|
449
|
+
updates: diffPayload(oldPayload, newPayload),
|
|
450
|
+
}
|
|
451
|
+
if (updateEvent.updates.length > 0) {
|
|
452
|
+
this.emit('update', updateEvent)
|
|
453
|
+
contact?.emit('update', updateEvent)
|
|
454
|
+
}
|
|
442
455
|
break
|
|
443
456
|
}
|
|
444
457
|
case PUPPET.types.Payload.Room: {
|
|
445
458
|
const room = await this.Room.find({ id: payloadId }) as unknown as undefined | RoomImpl
|
|
459
|
+
const oldPayload = JSON.parse(JSON.stringify(room?.payload || {}))
|
|
446
460
|
await room?.ready(true)
|
|
461
|
+
const newPayload = JSON.parse(JSON.stringify(room?.payload || {}))
|
|
462
|
+
const updateEvent: InfoUpdateInterface = {
|
|
463
|
+
type: payloadType,
|
|
464
|
+
id: payloadId,
|
|
465
|
+
updates: diffPayload(oldPayload, newPayload),
|
|
466
|
+
}
|
|
467
|
+
if (updateEvent.updates.length > 0) {
|
|
468
|
+
this.emit('update', updateEvent)
|
|
469
|
+
room?.emit('update', updateEvent)
|
|
470
|
+
}
|
|
447
471
|
break
|
|
448
472
|
}
|
|
449
473
|
case PUPPET.types.Payload.RoomMember: {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
RoomImpl,
|
|
14
14
|
RoomInvitationImpl,
|
|
15
15
|
TagImpl,
|
|
16
|
+
TagGroupImpl,
|
|
16
17
|
UrlLinkImpl,
|
|
17
18
|
ChannelImpl,
|
|
18
19
|
|
|
@@ -28,6 +29,7 @@ import {
|
|
|
28
29
|
RoomConstructor,
|
|
29
30
|
RoomInvitationConstructor,
|
|
30
31
|
TagConstructor,
|
|
32
|
+
TagGroupConstructor,
|
|
31
33
|
UrlLinkConstructor,
|
|
32
34
|
ChannelConstructor,
|
|
33
35
|
|
|
@@ -60,6 +62,7 @@ const wechatifyUserModuleMixin = <MixinBase extends typeof WechatySkeleton> (mix
|
|
|
60
62
|
__wechatifiedRoom? : RoomConstructor
|
|
61
63
|
__wechatifiedRoomInvitation? : RoomInvitationConstructor
|
|
62
64
|
__wechatifiedTag? : TagConstructor
|
|
65
|
+
__wechatifiedTagGroup? : TagGroupConstructor
|
|
63
66
|
__wechatifiedUrlLink? : UrlLinkConstructor
|
|
64
67
|
__wechatifiedChannel? : ChannelConstructor
|
|
65
68
|
|
|
@@ -75,6 +78,7 @@ const wechatifyUserModuleMixin = <MixinBase extends typeof WechatySkeleton> (mix
|
|
|
75
78
|
get Room () : RoomConstructor { return guardWechatify(this.__wechatifiedRoom) }
|
|
76
79
|
get RoomInvitation () : RoomInvitationConstructor { return guardWechatify(this.__wechatifiedRoomInvitation) }
|
|
77
80
|
get Tag () : TagConstructor { return guardWechatify(this.__wechatifiedTag) }
|
|
81
|
+
get TagGroup () : TagGroupConstructor { return guardWechatify(this.__wechatifiedTagGroup) }
|
|
78
82
|
get UrlLink () : UrlLinkConstructor { return guardWechatify(this.__wechatifiedUrlLink) }
|
|
79
83
|
get Channel () : ChannelConstructor { return guardWechatify(this.__wechatifiedChannel) }
|
|
80
84
|
|
|
@@ -110,6 +114,7 @@ const wechatifyUserModuleMixin = <MixinBase extends typeof WechatySkeleton> (mix
|
|
|
110
114
|
this.__wechatifiedRoom = wechatifyUserModule(RoomImpl)(this as any)
|
|
111
115
|
this.__wechatifiedRoomInvitation = wechatifyUserModule(RoomInvitationImpl)(this as any)
|
|
112
116
|
this.__wechatifiedTag = wechatifyUserModule(TagImpl)(this as any)
|
|
117
|
+
this.__wechatifiedTagGroup = wechatifyUserModule(TagGroupImpl)(this as any)
|
|
113
118
|
this.__wechatifiedUrlLink = wechatifyUserModule(UrlLinkImpl)(this as any)
|
|
114
119
|
this.__wechatifiedChannel = wechatifyUserModule(ChannelImpl)(this as any)
|
|
115
120
|
|
|
@@ -145,6 +150,7 @@ type ProtectedPropertyWechatifyUserModuleMixin =
|
|
|
145
150
|
| '__wechatifiedRoom'
|
|
146
151
|
| '__wechatifiedRoomInvitation'
|
|
147
152
|
| '__wechatifiedTag'
|
|
153
|
+
| '__wechatifiedTagGroup'
|
|
148
154
|
| '__wechatifiedUrlLink'
|
|
149
155
|
| '__wechatifiedChannel'
|
|
150
156
|
|