Handle WhatsApp chat create events

This commit is contained in:
Tulir Asokan 2020-06-26 00:13:18 +03:00
parent 8cfb04a5ed
commit 2132bc653b
2 changed files with 3 additions and 2 deletions

View file

@ -861,7 +861,7 @@ func (user *User) HandleChatUpdate(cmd whatsappExt.ChatUpdate) {
portal := user.GetPortalByJID(cmd.JID)
if len(portal.MXID) == 0 {
if cmd.Data.Action == whatsappExt.ChatActionIntroduce && cmd.Data.SenderJID != "unknown" {
if cmd.Data.Action == whatsappExt.ChatActionIntroduce || cmd.Data.Action == whatsappExt.ChatActionCreate {
go func() {
err := portal.CreateMatrixRoom(user)
if err != nil {

View file

@ -46,6 +46,7 @@ const (
ChatActionPromote ChatActionType = "promote"
ChatActionDemote ChatActionType = "demote"
ChatActionIntroduce ChatActionType = "introduce"
ChatActionCreate ChatActionType = "create"
ChatActionRemove ChatActionType = "remove"
ChatActionAdd ChatActionType = "add"
)
@ -109,7 +110,7 @@ func (cud *ChatUpdateData) UnmarshalJSON(data []byte) error {
var unmarshalTo interface{}
switch cud.Action {
case ChatActionIntroduce:
case ChatActionIntroduce, ChatActionCreate:
err = json.Unmarshal(arr[2], &cud.NameChange)
if err != nil {
return err