Don't fail if parent portal doesn't exist yet

This commit is contained in:
Tulir Asokan
2022-05-29 11:32:19 +03:00
parent 49b5f77a03
commit 0366578ab4

View File

@@ -1428,6 +1428,9 @@ func (portal *Portal) addToSpace(mxid id.RoomID) bool {
return false
}
portal.removeFromSpace()
if mxid == "" {
return true
}
_, err := portal.MainIntent().SendStateEvent(portal.MXID, event.StateSpaceParent, mxid.String(), &event.SpaceParentEventContent{
Via: []string{portal.bridge.AS.HomeserverDomain},
@@ -1455,7 +1458,7 @@ func (portal *Portal) UpdateParent(parentID string) bool {
}
portal.ParentID = parentID
if portal.ParentID != "" {
portal.Parent = portal.bridge.GetExistingPortalByID(database.NewPortalKey(parentID, ""))
portal.Parent = portal.bridge.GetPortalByID(database.NewPortalKey(parentID, ""), discordgo.ChannelTypeGuildCategory)
} else {
portal.Parent = nil
}