Эх сурвалжийг харах

Portal.CreateMatrixRoom: ensure the user exists

In the log some message show up with `/_matrix/client/r0/createRoom
code=403 wrapped=M_FORBIDDEN: Application service has not registered this
user`. This is caused by the handling of text messages coming from unknown
users:

    mautrix-whatsapp/vendor/github.com/Rhymen/go-whatsapp/handler.go:106
    mautrix-whatsapp/user.go:250
    mautrix-whatsapp/portal.go:551

Hence, before creating a Matrix room, we must ensure the user for this
room exists.
Jörg Sommer 6 жил өмнө
parent
commit
0d49bd8d08
1 өөрчлөгдсөн 6 нэмэгдсэн , 1 устгасан
  1. 6 1
      portal.go

+ 6 - 1
portal.go

@@ -455,6 +455,11 @@ func (portal *Portal) CreateMatrixRoom(invite []string) error {
 		return nil
 	}
 
+	intent := portal.MainIntent()
+	if err := intent.EnsureRegistered(); err != nil {
+		return err
+	}
+
 	name := portal.Name
 	topic := portal.Topic
 	isPrivateChat := false
@@ -464,7 +469,7 @@ func (portal *Portal) CreateMatrixRoom(invite []string) error {
 		isPrivateChat = true
 	}
 
-	resp, err := portal.MainIntent().CreateRoom(&gomatrix.ReqCreateRoom{
+	resp, err := intent.CreateRoom(&gomatrix.ReqCreateRoom{
 		Visibility: "private",
 		Name:       name,
 		Topic:      topic,