Load Correct Profile Image when ProfileImageExperiment is Disabled
This commit is contained in:
parent
243727a131
commit
89f19928c2
|
@ -224,7 +224,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
cpicPath = RandomGroupImage(conversationInfo.Handle)
|
cpicPath = RandomGroupImage(conversationInfo.Handle)
|
||||||
defaultPath = RandomGroupImage(conversationInfo.Handle)
|
defaultPath = RandomGroupImage(conversationInfo.Handle)
|
||||||
} else {
|
} else {
|
||||||
cpicPath = GetProfileImage(profile, conversationInfo, settings.DownloadPath)
|
cpicPath = eh.GetProfileImage(profile, conversationInfo, settings.DownloadPath)
|
||||||
defaultPath = RandomProfileImage(conversationInfo.Handle)
|
defaultPath = RandomProfileImage(conversationInfo.Handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,15 +333,17 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
return string(json)
|
return string(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetProfileImage(profile peer.CwtchPeer, conversationInfo *model.Conversation, basepath string) string {
|
func (eh *EventHandler) GetProfileImage(profile peer.CwtchPeer, conversationInfo *model.Conversation, basepath string) string {
|
||||||
fileKey, err := profile.GetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.CustomProfileImageKey)))
|
if eh.app.IsFeatureEnabled(constants.ImagePreviewsExperiment) {
|
||||||
if err == nil {
|
fileKey, err := profile.GetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.CustomProfileImageKey)))
|
||||||
if value, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.complete", fileKey)); exists && value == event.True {
|
if err == nil {
|
||||||
fp, _ := filesharing.GenerateDownloadPath(basepath, fileKey, true)
|
if value, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.complete", fileKey)); exists && value == event.True {
|
||||||
// check if the file exists...if it does then set the path...
|
fp, _ := filesharing.GenerateDownloadPath(basepath, fileKey, true)
|
||||||
if _, err := os.Stat(fp); err == nil {
|
// check if the file exists...if it does then set the path...
|
||||||
image, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", fileKey))
|
if _, err := os.Stat(fp); err == nil {
|
||||||
return image
|
image, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", fileKey))
|
||||||
|
return image
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,7 +372,7 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
if ci != nil && err == nil {
|
if ci != nil && err == nil {
|
||||||
ev.Event.Data[event.ConversationID] = strconv.Itoa(ci.ID)
|
ev.Event.Data[event.ConversationID] = strconv.Itoa(ci.ID)
|
||||||
profile.SetConversationAttribute(ci.ID, attr.LocalScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants2.Archived)), event.False)
|
profile.SetConversationAttribute(ci.ID, attr.LocalScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants2.Archived)), event.False)
|
||||||
ev.Event.Data[constants2.Picture] = GetProfileImage(profile, ci, eh.app.ReadSettings().DownloadPath)
|
ev.Event.Data[constants2.Picture] = eh.GetProfileImage(profile, ci, eh.app.ReadSettings().DownloadPath)
|
||||||
} else {
|
} else {
|
||||||
// TODO This Conversation May Not Exist Yet...But we are not in charge of creating it...
|
// TODO This Conversation May Not Exist Yet...But we are not in charge of creating it...
|
||||||
log.Errorf("todo wait for contact to be added before processing this event...")
|
log.Errorf("todo wait for contact to be added before processing this event...")
|
||||||
|
@ -399,7 +401,7 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
ev.Event.Data["Nick"] = ev.Event.Data["RemotePeer"]
|
ev.Event.Data["Nick"] = ev.Event.Data["RemotePeer"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ev.Event.Data[constants2.Picture] = GetProfileImage(profile, ci, eh.app.ReadSettings().DownloadPath)
|
ev.Event.Data[constants2.Picture] = eh.GetProfileImage(profile, ci, eh.app.ReadSettings().DownloadPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
conversationID, _ := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
conversationID, _ := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||||
|
|
Loading…
Reference in New Issue