Enable history archive support for all non-admin communities
Previously, we've turned archive support off by default, this means, community member nodes won't try to download torrent data when they receive a magnetlink. This commit ensures that communities joined in the future will have this setting on, and also all existing communities that the node isn't admin of will have this feature enabled.
This commit is contained in:
parent
b0af0507b6
commit
631907839a
|
@ -1273,19 +1273,36 @@ func (m *Messenger) Init() error {
|
|||
logger.Warn("failed to check if community settings exist", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
if exists {
|
||||
|
||||
if !exists {
|
||||
communitySettings := communities.CommunitySettings{
|
||||
CommunityID: org.IDString(),
|
||||
HistoryArchiveSupportEnabled: true,
|
||||
}
|
||||
|
||||
err = m.communitiesManager.SaveCommunitySettings(communitySettings)
|
||||
if err != nil {
|
||||
logger.Warn("failed to save community settings", zap.Error(err))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
communitySettings := communities.CommunitySettings{
|
||||
CommunityID: org.IDString(),
|
||||
HistoryArchiveSupportEnabled: false,
|
||||
}
|
||||
err = m.communitiesManager.SaveCommunitySettings(communitySettings)
|
||||
// In case we do have settings, but the history archive support is disabled
|
||||
// for this community, we enable it, as this should be the default for all
|
||||
// non-admin communities
|
||||
communitySettings, err := m.communitiesManager.GetCommunitySettingsByID(org.ID())
|
||||
if err != nil {
|
||||
logger.Warn("failed to save community settings", zap.Error(err))
|
||||
logger.Warn("failed to fetch community settings", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
if !org.IsAdmin() && !communitySettings.HistoryArchiveSupportEnabled {
|
||||
communitySettings.HistoryArchiveSupportEnabled = true
|
||||
err = m.communitiesManager.UpdateCommunitySettings(*communitySettings)
|
||||
if err != nil {
|
||||
logger.Warn("failed to update community settings", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init filters for the communities we are an admin of
|
||||
|
|
|
@ -200,7 +200,7 @@ func (m *Messenger) JoinCommunity(ctx context.Context, communityID types.HexByte
|
|||
|
||||
communitySettings := communities.CommunitySettings{
|
||||
CommunityID: communityID.String(),
|
||||
HistoryArchiveSupportEnabled: false,
|
||||
HistoryArchiveSupportEnabled: true,
|
||||
}
|
||||
|
||||
err = m.communitiesManager.SaveCommunitySettings(communitySettings)
|
||||
|
|
Loading…
Reference in New Issue