From 2132bc653b0d627355004458c9e56e175365790e Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 26 Jun 2020 00:13:18 +0300 Subject: [PATCH] Handle WhatsApp chat create events --- user.go | 2 +- whatsapp-ext/chat.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/user.go b/user.go index fcf28b4..07f37f6 100644 --- a/user.go +++ b/user.go @@ -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 { diff --git a/whatsapp-ext/chat.go b/whatsapp-ext/chat.go index 60faa22..f444906 100644 --- a/whatsapp-ext/chat.go +++ b/whatsapp-ext/chat.go @@ -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