浏览代码

Reduce unnecessary invite calls during history sync

Tulir Asokan 3 年之前
父节点
当前提交
1f6cedf948
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      historysync.go

+ 3 - 2
historysync.go

@@ -275,8 +275,9 @@ func (user *User) backfillInChunks(req *database.Backfill, conv *database.Histor
 
 
 func (user *User) shouldCreatePortalForHistorySync(conv *database.HistorySyncConversation, portal *Portal) bool {
 func (user *User) shouldCreatePortalForHistorySync(conv *database.HistorySyncConversation, portal *Portal) bool {
 	if len(portal.MXID) > 0 {
 	if len(portal.MXID) > 0 {
-		user.log.Debugfln("Portal for %s already exists, ensuring user is invited", portal.Key.JID)
-		portal.ensureUserInvited(user)
+		if !user.bridge.AS.StateStore.IsInRoom(portal.MXID, user.MXID) {
+			portal.ensureUserInvited(user)
+		}
 		// Portal exists, let backfill continue
 		// Portal exists, let backfill continue
 		return true
 		return true
 	} else if !user.bridge.Config.Bridge.HistorySync.CreatePortals {
 	} else if !user.bridge.Config.Bridge.HistorySync.CreatePortals {