forked from MirrorHub/mautrix-whatsapp
historysync: only save when backfill is enabled
This commit is contained in:
parent
c664e5f107
commit
78c6d57299
2 changed files with 30 additions and 24 deletions
|
@ -43,8 +43,11 @@ type wrappedInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) handleHistorySyncsLoop() {
|
func (user *User) handleHistorySyncsLoop() {
|
||||||
|
if !user.bridge.Config.Bridge.HistorySync.Backfill {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
reCheckQueue := make(chan bool, 1)
|
reCheckQueue := make(chan bool, 1)
|
||||||
if user.bridge.Config.Bridge.HistorySync.Backfill {
|
|
||||||
// Start the backfill queue.
|
// Start the backfill queue.
|
||||||
user.BackfillQueue = &BackfillQueue{
|
user.BackfillQueue = &BackfillQueue{
|
||||||
BackfillQuery: user.bridge.DB.BackfillQuery,
|
BackfillQuery: user.bridge.DB.BackfillQuery,
|
||||||
|
@ -65,7 +68,6 @@ func (user *User) handleHistorySyncsLoop() {
|
||||||
// to be more or less aggressive with backfilling at this stage.
|
// to be more or less aggressive with backfilling at this stage.
|
||||||
go user.handleBackfillRequestsLoop(user.BackfillQueue.DeferredBackfillRequests)
|
go user.handleBackfillRequestsLoop(user.BackfillQueue.DeferredBackfillRequests)
|
||||||
go user.BackfillQueue.RunLoops(user)
|
go user.BackfillQueue.RunLoops(user)
|
||||||
}
|
|
||||||
|
|
||||||
// Always save the history syncs for the user. If they want to enable
|
// Always save the history syncs for the user. If they want to enable
|
||||||
// backfilling in the future, we will have it in the database.
|
// backfilling in the future, we will have it in the database.
|
||||||
|
|
4
user.go
4
user.go
|
@ -188,7 +188,9 @@ func (bridge *Bridge) NewUser(dbUser *database.User) *User {
|
||||||
user.RelayWhitelisted = user.bridge.Config.Bridge.Permissions.IsRelayWhitelisted(user.MXID)
|
user.RelayWhitelisted = user.bridge.Config.Bridge.Permissions.IsRelayWhitelisted(user.MXID)
|
||||||
user.Whitelisted = user.bridge.Config.Bridge.Permissions.IsWhitelisted(user.MXID)
|
user.Whitelisted = user.bridge.Config.Bridge.Permissions.IsWhitelisted(user.MXID)
|
||||||
user.Admin = user.bridge.Config.Bridge.Permissions.IsAdmin(user.MXID)
|
user.Admin = user.bridge.Config.Bridge.Permissions.IsAdmin(user.MXID)
|
||||||
|
if user.bridge.Config.Bridge.HistorySync.Backfill {
|
||||||
go user.handleHistorySyncsLoop()
|
go user.handleHistorySyncsLoop()
|
||||||
|
}
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +694,9 @@ func (user *User) HandleEvent(event interface{}) {
|
||||||
portal := user.GetPortalByMessageSource(v.Info.MessageSource)
|
portal := user.GetPortalByMessageSource(v.Info.MessageSource)
|
||||||
portal.messages <- PortalMessage{undecryptable: v, source: user}
|
portal.messages <- PortalMessage{undecryptable: v, source: user}
|
||||||
case *events.HistorySync:
|
case *events.HistorySync:
|
||||||
|
if user.bridge.Config.Bridge.HistorySync.Backfill {
|
||||||
user.historySyncs <- v
|
user.historySyncs <- v
|
||||||
|
}
|
||||||
case *events.Mute:
|
case *events.Mute:
|
||||||
portal := user.GetPortalByJID(v.JID)
|
portal := user.GetPortalByJID(v.JID)
|
||||||
if portal != nil {
|
if portal != nil {
|
||||||
|
|
Loading…
Reference in a new issue