forked from MirrorHub/mautrix-whatsapp
Handle WhatsApp chat create events
This commit is contained in:
parent
8cfb04a5ed
commit
2132bc653b
2 changed files with 3 additions and 2 deletions
2
user.go
2
user.go
|
@ -861,7 +861,7 @@ func (user *User) HandleChatUpdate(cmd whatsappExt.ChatUpdate) {
|
||||||
|
|
||||||
portal := user.GetPortalByJID(cmd.JID)
|
portal := user.GetPortalByJID(cmd.JID)
|
||||||
if len(portal.MXID) == 0 {
|
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() {
|
go func() {
|
||||||
err := portal.CreateMatrixRoom(user)
|
err := portal.CreateMatrixRoom(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -46,6 +46,7 @@ const (
|
||||||
ChatActionPromote ChatActionType = "promote"
|
ChatActionPromote ChatActionType = "promote"
|
||||||
ChatActionDemote ChatActionType = "demote"
|
ChatActionDemote ChatActionType = "demote"
|
||||||
ChatActionIntroduce ChatActionType = "introduce"
|
ChatActionIntroduce ChatActionType = "introduce"
|
||||||
|
ChatActionCreate ChatActionType = "create"
|
||||||
ChatActionRemove ChatActionType = "remove"
|
ChatActionRemove ChatActionType = "remove"
|
||||||
ChatActionAdd ChatActionType = "add"
|
ChatActionAdd ChatActionType = "add"
|
||||||
)
|
)
|
||||||
|
@ -109,7 +110,7 @@ func (cud *ChatUpdateData) UnmarshalJSON(data []byte) error {
|
||||||
|
|
||||||
var unmarshalTo interface{}
|
var unmarshalTo interface{}
|
||||||
switch cud.Action {
|
switch cud.Action {
|
||||||
case ChatActionIntroduce:
|
case ChatActionIntroduce, ChatActionCreate:
|
||||||
err = json.Unmarshal(arr[2], &cud.NameChange)
|
err = json.Unmarshal(arr[2], &cud.NameChange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue