This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.
nix-packages/matrix/mautrix-discord/no-category-spaces.patch

101 lines
4.2 KiB
Diff
Raw Normal View History

2022-11-24 13:28:23 +00:00
diff --git a/database/portal.go b/database/portal.go
2023-03-02 09:15:44 +00:00
index ba6bccd..2feebba 100644
2022-11-24 13:28:23 +00:00
--- a/database/portal.go
+++ b/database/portal.go
2023-03-02 09:15:44 +00:00
@@ -159,13 +159,13 @@ func (p *Portal) Scan(row dbutil.Scannable) *Portal {
2022-11-24 13:28:23 +00:00
func (p *Portal) Insert() {
query := `
- INSERT INTO portal (dcid, receiver, type, other_user_id, dc_guild_id, dc_parent_id, mxid,
+ INSERT INTO portal (dcid, receiver, type, other_user_id, dc_guild_id, mxid,
plain_name, name, name_set, topic, topic_set, avatar, avatar_url, avatar_set,
2023-03-02 09:15:44 +00:00
encrypted, in_space, first_event_id, relay_webhook_id, relay_webhook_secret)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)
2022-11-24 13:28:23 +00:00
`
_, err := p.db.Exec(query, p.Key.ChannelID, p.Key.Receiver, p.Type,
- strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(p.ParentID), strPtr(string(p.MXID)),
+ strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(string(p.MXID)),
p.PlainName, p.Name, p.NameSet, p.Topic, p.TopicSet, p.Avatar, p.AvatarURL.String(), p.AvatarSet,
2023-03-02 09:15:44 +00:00
p.Encrypted, p.InSpace, p.FirstEventID.String(), strPtr(p.RelayWebhookID), strPtr(p.RelayWebhookSecret))
2022-11-24 13:28:23 +00:00
2023-03-02 09:15:44 +00:00
@@ -178,13 +178,13 @@ func (p *Portal) Insert() {
2022-11-24 13:28:23 +00:00
func (p *Portal) Update() {
query := `
UPDATE portal
- SET type=$1, other_user_id=$2, dc_guild_id=$3, dc_parent_id=$4, mxid=$5,
- plain_name=$6, name=$7, name_set=$8, topic=$9, topic_set=$10, avatar=$11, avatar_url=$12, avatar_set=$13,
2023-03-02 09:15:44 +00:00
- encrypted=$14, in_space=$15, first_event_id=$16, relay_webhook_id=$17, relay_webhook_secret=$18
- WHERE dcid=$19 AND receiver=$20
+ SET type=$1, other_user_id=$2, dc_guild_id=$3, mxid=$6,
+ plain_name=$7, name=$8, name_set=$9, topic=$10, topic_set=$11, avatar=$12, avatar_url=$13, avatar_set=$14,
+ encrypted=$15, in_space=$16, first_event_id=$17, relay_webhook_id=$18, relay_webhook_secret=$19
+ WHERE dcid=$20 AND receiver=$21
2022-11-24 13:28:23 +00:00
`
_, err := p.db.Exec(query,
- p.Type, strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(p.ParentID), strPtr(string(p.MXID)),
+ p.Type, strPtr(p.OtherUserID), strPtr(p.GuildID), strPtr(string(p.MXID)),
p.PlainName, p.Name, p.NameSet, p.Topic, p.TopicSet, p.Avatar, p.AvatarURL.String(), p.AvatarSet,
2023-03-02 09:15:44 +00:00
p.Encrypted, p.InSpace, p.FirstEventID.String(), strPtr(p.RelayWebhookID), strPtr(p.RelayWebhookSecret),
2022-11-24 13:28:23 +00:00
p.Key.ChannelID, p.Key.Receiver)
2022-11-19 09:38:22 +00:00
diff --git a/portal.go b/portal.go
2023-03-02 09:15:44 +00:00
index bcdbb37..c4b3ecd 100644
2022-11-19 09:38:22 +00:00
--- a/portal.go
+++ b/portal.go
2023-03-02 09:15:44 +00:00
@@ -119,14 +119,6 @@ func (br *DiscordBridge) loadPortal(dbPortal *database.Portal, key *database.Por
2022-11-24 12:37:28 +00:00
if portal.GuildID != "" {
portal.Guild = portal.bridge.GetGuildByID(portal.GuildID, true)
}
- if portal.ParentID != "" {
- parentKey := database.NewPortalKey(portal.ParentID, "")
- var ok bool
- portal.Parent, ok = br.portalsByID[parentKey]
- if !ok {
- portal.Parent = br.loadPortal(br.DB.Portal.GetByID(parentKey), nil, -1)
- }
- }
2023-03-02 09:15:44 +00:00
2022-11-24 12:37:28 +00:00
return portal
}
2023-03-02 09:15:44 +00:00
@@ -384,7 +376,7 @@ func (portal *Portal) CreateMatrixRoom(user *User, channel *discordgo.Channel) e
2022-11-19 09:38:22 +00:00
creationContent := make(map[string]interface{})
if portal.Type == discordgo.ChannelTypeGuildCategory {
- creationContent["type"] = event.RoomTypeSpace
+ return nil
}
if !portal.bridge.Config.Bridge.FederateRooms {
creationContent["m.federate"] = false
2023-03-02 09:15:44 +00:00
@@ -1861,18 +1853,12 @@ func (portal *Portal) UpdateParent(parentID string) bool {
2022-11-19 09:38:22 +00:00
}
portal.log.Debugfln("Updating parent ID %q -> %q", portal.ParentID, parentID)
portal.ParentID = parentID
- if portal.ParentID != "" {
- portal.Parent = portal.bridge.GetPortalByID(database.NewPortalKey(parentID, ""), discordgo.ChannelTypeGuildCategory)
- } else {
- portal.Parent = nil
- }
2023-03-02 09:15:44 +00:00
+ portal.Parent = nil
2022-11-19 09:38:22 +00:00
return true
}
func (portal *Portal) ExpectedSpaceID() id.RoomID {
- if portal.Parent != nil {
- return portal.Parent.MXID
- } else if portal.Guild != nil {
+ if portal.Guild != nil {
return portal.Guild.MXID
}
return ""
2023-03-02 09:15:44 +00:00
@@ -1882,9 +1868,7 @@ func (portal *Portal) updateSpace() bool {
if portal.MXID == "" {
return false
}
- if portal.Parent != nil {
- return portal.addToSpace(portal.Parent.MXID)
- } else if portal.Guild != nil {
+ if portal.Guild != nil {
return portal.addToSpace(portal.Guild.MXID)
}
return false