-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
bugSomething isn't workingSomething isn't working
Description
I think the Event Handler Class will be instantiated from time to time when there's a new event, and will not keep/reuse the class instance for the next one.
So the isDuplicatedMessage will always forget the hash it calculated last time.
friday/src/core/sync-community-rooms/events/handlers/puppet-message-received.handler.ts
Lines 103 to 130 in 8338c8e
| /** | |
| * TODO: make sure it works as expected | |
| * Huan(20220228) | |
| */ | |
| private async isDuplicatedMessage (message: WECHATY.Message): Promise<boolean> { | |
| this.log.verbose('PuppetMessageReceivedHandler', 'isDuplicatedMessage(%s)', message.id) | |
| const sayable = await WECHATY.helpers.messageToSayable(message) | |
| if (typeof sayable === 'undefined') { | |
| return false | |
| } | |
| const payload = await WECHATY.helpers.sayableToPayload(sayable) | |
| if (typeof payload === 'undefined') { | |
| return false | |
| } | |
| const hash = crypto.createHash('sha256').update( | |
| JSON.stringify(payload), | |
| ).digest('hex') | |
| if (this.lastMessageHash === hash) { | |
| return true | |
| } | |
| this.lastMessageHash = hash | |
| return false | |
| } |
Should move to Saga.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working