Add config option for max age of chats to sync

This commit is contained in:
Tulir Asokan
2019-05-23 20:25:46 +03:00
parent 239de25bf0
commit 0408db5c07
3 changed files with 15 additions and 4 deletions

View File

@ -312,7 +312,11 @@ func (user *User) syncPortals() {
if limit < 0 {
limit = len(chats)
}
now := uint64(time.Now().Unix())
for i, chat := range chats {
if chat.LastMessageTime + user.bridge.Config.Bridge.SyncChatMaxAge < now {
break
}
create := (chat.LastMessageTime >= user.LastConnection && user.LastConnection > 0) || i < limit
if len(chat.Portal.MXID) > 0 || create {
chat.Portal.Sync(user, chat.Contact)