Kaynağa Gözat

Fix channel names getting corrupted on own message

Tulir Asokan 3 yıl önce
ebeveyn
işleme
8c66a064e1
4 değiştirilmiş dosya ile 7 ekleme ve 7 silme
  1. 3 3
      database/portalquery.go
  2. 2 2
      portal.go
  3. 1 1
      puppet.go
  4. 1 1
      user.go

+ 3 - 3
database/portalquery.go

@@ -36,11 +36,11 @@ func (pq *PortalQuery) GetByMXID(mxid id.RoomID) *Portal {
 	return pq.get(portalSelect+" WHERE mxid=$1", mxid)
 }
 
-func (pq *PortalQuery) GetAllByID(id string) []*Portal {
-	return pq.getAll(portalSelect+" WHERE receiver=$1", id)
+func (pq *PortalQuery) FindPrivateChatsWith(id string) []*Portal {
+	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;"
 
 	return pq.getAll(query, receiver, discordgo.ChannelTypeDM)

+ 2 - 2
portal.go

@@ -118,8 +118,8 @@ func (br *DiscordBridge) GetAllPortals() []*Portal {
 	return br.dbPortalsToPortals(br.DB.Portal.GetAll())
 }
 
-func (br *DiscordBridge) GetAllPortalsByID(id string) []*Portal {
-	return br.dbPortalsToPortals(br.DB.Portal.GetAllByID(id))
+func (br *DiscordBridge) GetDMPortalsWith(otherUserID string) []*Portal {
+	return br.dbPortalsToPortals(br.DB.Portal.FindPrivateChatsWith(otherUserID))
 }
 
 func (br *DiscordBridge) dbPortalsToPortals(dbPortals []*database.Portal) []*Portal {

+ 1 - 1
puppet.go

@@ -171,7 +171,7 @@ func (puppet *Puppet) CustomIntent() *appservice.IntentAPI {
 }
 
 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.
 		portal.roomCreateLock.Lock()
 		meta(portal)

+ 1 - 1
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 {
 	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 {
 		if portal.MXID != "" {
 			puppetMXID := user.bridge.FormatPuppetMXID(portal.Key.Receiver)