Ensure Settings Updates are Applied to Experiments
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2023-03-13 12:46:15 -07:00
parent fcb07042d7
commit 264b8b9363
5 changed files with 10 additions and 7 deletions

View File

@ -351,6 +351,8 @@ func (app *application) registerHooks(profile peer.CwtchPeer) {
profile.RegisterHook(extensions.ProfileValueExtension{})
profile.RegisterHook(filesharing.Functionality{})
profile.RegisterHook(new(filesharing.ImagePreviewsFunctionality))
// Ensure that Profiles have the Most Up to Date Settings...
profile.NotifySettingsUpdate(app.settings.ReadGlobalSettings())
}
// installProfile takes a profile and if it isn't loaded in the app, installs it and returns true

View File

@ -68,7 +68,7 @@ func (f Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) {
fileSizeLimit, err := strconv.ParseUint(fileSizeLimitValue, 10, bits.UintSize)
if err == nil {
if manifest.FileSizeInBytes >= fileSizeLimit {
log.Errorf("could not download file, size %v greater than limit %v", manifest.FileSizeInBytes, fileSizeLimitValue)
log.Debugf("could not download file, size %v greater than limit %v", manifest.FileSizeInBytes, fileSizeLimitValue)
} else {
manifest.Title = manifest.FileName
manifest.FileName = downloadFilePath
@ -349,10 +349,10 @@ func (f *Functionality) ReShareFiles(profile peer.CwtchPeer) error {
if err == nil && sharedFile.Active {
err := f.RestartFileShare(profile, filekey)
if err != nil {
log.Errorf("could not reshare file: %v", err)
log.Debugf("could not reshare file: %v", err)
}
} else {
log.Errorf("could not get fileshare info %v", err)
log.Debugf("could not get fileshare info %v", err)
}
}
}

View File

@ -103,13 +103,13 @@ func (i *ImagePreviewsFunctionality) handleImagePreviews(profile peer.CwtchPeer,
// Short-circuit failures
// Don't autodownload images if the download path does not exist.
if i.downloadFolder == "" {
log.Debugf("download folder %v is not set", i.downloadFolder)
log.Errorf("download folder %v is not set", i.downloadFolder)
return
}
// Don't autodownload images if the download path does not exist.
if _, err := os.Stat(i.downloadFolder); os.IsNotExist(err) {
log.Debugf("download folder %v does not exist", i.downloadFolder)
log.Errorf("download folder %v does not exist", i.downloadFolder)
return
}
@ -127,7 +127,7 @@ func (i *ImagePreviewsFunctionality) handleImagePreviews(profile peer.CwtchPeer,
if fm.ShouldAutoDL() {
basepath := i.downloadFolder
fp, mp := GenerateDownloadPath(basepath, fm.Name, false)
log.Debugf("autodownloading file!")
log.Debugf("autodownloading file! %v %v %v", basepath, fp, i.downloadFolder)
ev.Data["Auto"] = constants.True
mID, _ := strconv.Atoi(ev.Data["Index"])
profile.UpdateMessageAttribute(conversationID, 0, mID, constants.AttrDownloaded, constants.True)

View File

@ -193,6 +193,7 @@ func (cp *cwtchPeer) UpdateExperiments(enabled bool, experiments map[string]bool
// NotifySettingsUpdate notifies a Cwtch profile of a change in the nature of global experiments. The Cwtch Profile uses
// this information to update registered extensions.
func (cp *cwtchPeer) NotifySettingsUpdate(settings settings.GlobalSettings) {
log.Debugf("Cwtch Profile Settings Update: %v", settings)
cp.extensionLock.Lock()
defer cp.extensionLock.Unlock()
for _, extension := range cp.extensions {

View File

@ -155,7 +155,7 @@ func CreateEncryptedStore(profileDirectory string, password string) (*CwtchProfi
// FromEncryptedDatabase constructs a Cwtch Profile from an existing Encrypted Database
func FromEncryptedDatabase(profileDirectory string, password string) (CwtchPeer, error) {
log.Infof("Loading Encrypted Profile: %v", profileDirectory)
log.Debugf("Loading Encrypted Profile: %v", profileDirectory)
db, err := openEncryptedDatabase(profileDirectory, password, false)
if db == nil || err != nil {
return nil, fmt.Errorf("unable to open encrypted database: error: %v", err)