Don't create portals for stub messages
This commit is contained in:
parent
93953ec48f
commit
24d172fd55
1 changed files with 14 additions and 1 deletions
15
portal.go
15
portal.go
|
@ -196,7 +196,10 @@ func (portal *Portal) handleMessageLoop() {
|
|||
for msg := range portal.messages {
|
||||
if len(portal.MXID) == 0 {
|
||||
if msg.timestamp+MaxMessageAgeToCreatePortal < uint64(time.Now().Unix()) {
|
||||
portal.log.Debugln("Not creating portal room for incoming message as the message is too old.")
|
||||
portal.log.Debugln("Not creating portal room for incoming message: message is too old")
|
||||
continue
|
||||
} else if !portal.shouldCreateRoom(msg) {
|
||||
portal.log.Debugln("Not creating portal room for incoming message: message is not a chat message")
|
||||
continue
|
||||
}
|
||||
portal.log.Debugln("Creating Matrix room from incoming message")
|
||||
|
@ -212,6 +215,16 @@ func (portal *Portal) handleMessageLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
func (portal *Portal) shouldCreateRoom(msg PortalMessage) bool {
|
||||
stubMsg, ok := msg.data.(whatsapp.StubMessage)
|
||||
if ok {
|
||||
// This could be more specific: if someone else was added, we might not care,
|
||||
// but if the local user was added, we definitely care.
|
||||
return stubMsg.Type == waProto.WebMessageInfo_GROUP_PARTICIPANT_ADD || stubMsg.Type == waProto.WebMessageInfo_GROUP_PARTICIPANT_INVITE
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (portal *Portal) handleMessage(msg PortalMessage, isBackfill bool) {
|
||||
if len(portal.MXID) == 0 {
|
||||
portal.log.Warnln("handleMessage called even though portal.MXID is empty")
|
||||
|
|
Loading…
Reference in a new issue