swiftui-shapes icon indicating copy to clipboard operation
swiftui-shapes copied to clipboard

TalkerId is not existed for some room messages

Open padlocal opened this issue 3 years ago • 0 comments

Background

talkerId is required for all Wechaty messages by desigin, or exceptions will be raised when call message.ready():

https://github.com/wechaty/wechaty/blob/435cefd90baf7f2a0c801010132e74f9e0575fc2/src/user-modules/message.ts#L270-L279

Problem

BUT, there are some exceptions that we cannot parse talkerId from message payload. AND these messages SHOULD not have any specified talkers logically, such as notification messages sent by the system.

One example: when you are creating a room with members that have deleted you unilaterally, then you will get a system message as warning:

IMG_0D2D5F897C74-1

{
    "atList": [],
    "binarypayload": "",
    "content": "已向PadLocal发送群聊邀请,为了减少打扰,需对方同意邀请后才会进入群聊",
    "createtime": 1654422381,
    "fromusername": "xxx@chatroom",
    "id": "xxx",
    "pushcontent": "",
    "tousername": "xxx",
    "type": 10000
}

Suggest

I have following suggestions, #1 is preferred.

  1. I think we can accept talkerId is optional for room messages, so that Wechaty users can recevie these kind of message.
  2. Set the talker to puppet.currentUserId, treating these messages are sent by self.
  3. Add add a special symbol for talkerId to represent the system. This may need a lot of working and introduce new concept which is bad.

padlocal avatar Jun 05 '22 10:06 padlocal