Fix channel names getting corrupted on own message
This commit is contained in:
@@ -36,11 +36,11 @@ func (pq *PortalQuery) GetByMXID(mxid id.RoomID) *Portal {
|
|||||||
return pq.get(portalSelect+" WHERE mxid=$1", mxid)
|
return pq.get(portalSelect+" WHERE mxid=$1", mxid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pq *PortalQuery) GetAllByID(id string) []*Portal {
|
func (pq *PortalQuery) FindPrivateChatsWith(id string) []*Portal {
|
||||||
return pq.getAll(portalSelect+" WHERE receiver=$1", id)
|
return pq.getAll(portalSelect+" WHERE dmuser=$1 AND type=$2", id, discordgo.ChannelTypeDM)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pq *PortalQuery) FindPrivateChats(receiver string) []*Portal {
|
func (pq *PortalQuery) FindPrivateChatsOf(receiver string) []*Portal {
|
||||||
query := portalSelect + " portal WHERE receiver=$1 AND type=$2;"
|
query := portalSelect + " portal WHERE receiver=$1 AND type=$2;"
|
||||||
|
|
||||||
return pq.getAll(query, receiver, discordgo.ChannelTypeDM)
|
return pq.getAll(query, receiver, discordgo.ChannelTypeDM)
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ func (br *DiscordBridge) GetAllPortals() []*Portal {
|
|||||||
return br.dbPortalsToPortals(br.DB.Portal.GetAll())
|
return br.dbPortalsToPortals(br.DB.Portal.GetAll())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (br *DiscordBridge) GetAllPortalsByID(id string) []*Portal {
|
func (br *DiscordBridge) GetDMPortalsWith(otherUserID string) []*Portal {
|
||||||
return br.dbPortalsToPortals(br.DB.Portal.GetAllByID(id))
|
return br.dbPortalsToPortals(br.DB.Portal.FindPrivateChatsWith(otherUserID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (br *DiscordBridge) dbPortalsToPortals(dbPortals []*database.Portal) []*Portal {
|
func (br *DiscordBridge) dbPortalsToPortals(dbPortals []*database.Portal) []*Portal {
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ func (puppet *Puppet) CustomIntent() *appservice.IntentAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (puppet *Puppet) updatePortalMeta(meta func(portal *Portal)) {
|
func (puppet *Puppet) updatePortalMeta(meta func(portal *Portal)) {
|
||||||
for _, portal := range puppet.bridge.GetAllPortalsByID(puppet.ID) {
|
for _, portal := range puppet.bridge.GetDMPortalsWith(puppet.ID) {
|
||||||
// Get room create lock to prevent races between receiving contact info and room creation.
|
// Get room create lock to prevent races between receiving contact info and room creation.
|
||||||
portal.roomCreateLock.Lock()
|
portal.roomCreateLock.Lock()
|
||||||
meta(portal)
|
meta(portal)
|
||||||
|
|||||||
2
user.go
2
user.go
@@ -682,7 +682,7 @@ func (user *User) ensureInvited(intent *appservice.IntentAPI, roomID id.RoomID,
|
|||||||
func (user *User) getDirectChats() map[id.UserID][]id.RoomID {
|
func (user *User) getDirectChats() map[id.UserID][]id.RoomID {
|
||||||
chats := map[id.UserID][]id.RoomID{}
|
chats := map[id.UserID][]id.RoomID{}
|
||||||
|
|
||||||
privateChats := user.bridge.DB.Portal.FindPrivateChats(user.ID)
|
privateChats := user.bridge.DB.Portal.FindPrivateChatsOf(user.ID)
|
||||||
for _, portal := range privateChats {
|
for _, portal := range privateChats {
|
||||||
if portal.MXID != "" {
|
if portal.MXID != "" {
|
||||||
puppetMXID := user.bridge.FormatPuppetMXID(portal.Key.Receiver)
|
puppetMXID := user.bridge.FormatPuppetMXID(portal.Key.Receiver)
|
||||||
|
|||||||
Reference in New Issue
Block a user