Ensure Settings Updates are Applied to Experiments
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
fcb07042d7
commit
264b8b9363
|
@ -351,6 +351,8 @@ func (app *application) registerHooks(profile peer.CwtchPeer) {
|
||||||
profile.RegisterHook(extensions.ProfileValueExtension{})
|
profile.RegisterHook(extensions.ProfileValueExtension{})
|
||||||
profile.RegisterHook(filesharing.Functionality{})
|
profile.RegisterHook(filesharing.Functionality{})
|
||||||
profile.RegisterHook(new(filesharing.ImagePreviewsFunctionality))
|
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
|
// installProfile takes a profile and if it isn't loaded in the app, installs it and returns true
|
||||||
|
|
|
@ -68,7 +68,7 @@ func (f Functionality) OnEvent(ev event.Event, profile peer.CwtchPeer) {
|
||||||
fileSizeLimit, err := strconv.ParseUint(fileSizeLimitValue, 10, bits.UintSize)
|
fileSizeLimit, err := strconv.ParseUint(fileSizeLimitValue, 10, bits.UintSize)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if manifest.FileSizeInBytes >= fileSizeLimit {
|
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 {
|
} else {
|
||||||
manifest.Title = manifest.FileName
|
manifest.Title = manifest.FileName
|
||||||
manifest.FileName = downloadFilePath
|
manifest.FileName = downloadFilePath
|
||||||
|
@ -349,10 +349,10 @@ func (f *Functionality) ReShareFiles(profile peer.CwtchPeer) error {
|
||||||
if err == nil && sharedFile.Active {
|
if err == nil && sharedFile.Active {
|
||||||
err := f.RestartFileShare(profile, filekey)
|
err := f.RestartFileShare(profile, filekey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("could not reshare file: %v", err)
|
log.Debugf("could not reshare file: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("could not get fileshare info %v", err)
|
log.Debugf("could not get fileshare info %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,13 +103,13 @@ func (i *ImagePreviewsFunctionality) handleImagePreviews(profile peer.CwtchPeer,
|
||||||
// Short-circuit failures
|
// Short-circuit failures
|
||||||
// Don't autodownload images if the download path does not exist.
|
// Don't autodownload images if the download path does not exist.
|
||||||
if i.downloadFolder == "" {
|
if i.downloadFolder == "" {
|
||||||
log.Debugf("download folder %v is not set", i.downloadFolder)
|
log.Errorf("download folder %v is not set", i.downloadFolder)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't autodownload images if the download path does not exist.
|
// Don't autodownload images if the download path does not exist.
|
||||||
if _, err := os.Stat(i.downloadFolder); os.IsNotExist(err) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ func (i *ImagePreviewsFunctionality) handleImagePreviews(profile peer.CwtchPeer,
|
||||||
if fm.ShouldAutoDL() {
|
if fm.ShouldAutoDL() {
|
||||||
basepath := i.downloadFolder
|
basepath := i.downloadFolder
|
||||||
fp, mp := GenerateDownloadPath(basepath, fm.Name, false)
|
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
|
ev.Data["Auto"] = constants.True
|
||||||
mID, _ := strconv.Atoi(ev.Data["Index"])
|
mID, _ := strconv.Atoi(ev.Data["Index"])
|
||||||
profile.UpdateMessageAttribute(conversationID, 0, mID, constants.AttrDownloaded, constants.True)
|
profile.UpdateMessageAttribute(conversationID, 0, mID, constants.AttrDownloaded, constants.True)
|
||||||
|
|
|
@ -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
|
// NotifySettingsUpdate notifies a Cwtch profile of a change in the nature of global experiments. The Cwtch Profile uses
|
||||||
// this information to update registered extensions.
|
// this information to update registered extensions.
|
||||||
func (cp *cwtchPeer) NotifySettingsUpdate(settings settings.GlobalSettings) {
|
func (cp *cwtchPeer) NotifySettingsUpdate(settings settings.GlobalSettings) {
|
||||||
|
log.Debugf("Cwtch Profile Settings Update: %v", settings)
|
||||||
cp.extensionLock.Lock()
|
cp.extensionLock.Lock()
|
||||||
defer cp.extensionLock.Unlock()
|
defer cp.extensionLock.Unlock()
|
||||||
for _, extension := range cp.extensions {
|
for _, extension := range cp.extensions {
|
||||||
|
|
|
@ -155,7 +155,7 @@ func CreateEncryptedStore(profileDirectory string, password string) (*CwtchProfi
|
||||||
|
|
||||||
// FromEncryptedDatabase constructs a Cwtch Profile from an existing Encrypted Database
|
// FromEncryptedDatabase constructs a Cwtch Profile from an existing Encrypted Database
|
||||||
func FromEncryptedDatabase(profileDirectory string, password string) (CwtchPeer, error) {
|
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)
|
db, err := openEncryptedDatabase(profileDirectory, password, false)
|
||||||
if db == nil || err != nil {
|
if db == nil || err != nil {
|
||||||
return nil, fmt.Errorf("unable to open encrypted database: error: %v", err)
|
return nil, fmt.Errorf("unable to open encrypted database: error: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue