Compare commits

...

3 Commits

Author SHA1 Message Date
erinn 17acc3b8ef Merge pull request 'Add DefaultPicture parameter to Contact and Profiles' (#70) from profile_pictures into trunk
continuous-integration/drone/push Build is passing Details
Reviewed-on: #70
Reviewed-by: erinn <erinn@openprivacy.ca>
2022-02-07 22:29:33 +00:00
erinn 942b8b4709 Merge branch 'trunk' into profile_pictures
continuous-integration/drone/pr Build is pending Details
2022-02-07 22:29:22 +00:00
Sarah Jamie Lewis 44e5c38aa6 Add DefaultPicture parameter to Contact and Profiles
continuous-integration/drone/pr Build is passing Details
2022-02-07 14:21:52 -08:00
4 changed files with 33 additions and 39 deletions

View File

@ -5,6 +5,7 @@ const SchemaVersion = "schemaVersion"
const Name = "name"
const LastRead = "last-read"
const Picture = "picture"
const DefaultProfilePicture = "defaultPicture"
const ShowBlocked = "show-blocked"
const Archived = "archived"

10
lib.go
View File

@ -741,16 +741,6 @@ func ShareFile(profileOnion string, conversationID int, sharefilepath string) {
// FIXME: At some point we might want to allow arbitrary public files, but for now this API will assume
// there is only one, and it is the custom profile image...
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants2.CustomProfileImageKey, fileKey)
path, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", fileKey))
// tell the UI the the file has been "downloaded"
if exists {
eventHandler.Push(event.NewEvent(event.FileDownloaded, map[event.Field]string{
ProfileOnion: profileOnion,
event.FileKey: fileKey,
event.FilePath: path,
event.TempFile: "",
}))
}
} else {
profile.SendMessage(conversationID, overlay)
}

View File

@ -1,18 +1,19 @@
package utils
type Contact struct {
Name string `json:"name"`
Onion string `json:"onion"`
Status string `json:"status"`
Picture string `json:"picture"`
Accepted bool `json:"accepted"`
Blocked bool `json:"blocked"`
SaveHistory string `json:"saveConversationHistory"`
Messages int `json:"numMessages"`
Unread int `json:"numUnread"`
LastMessage string `json:"lastMsgTime"`
IsGroup bool `json:"isGroup"`
GroupServer string `json:"groupServer"`
IsArchived bool `json:"isArchived"`
Identifier int `json:"identifier"`
Name string `json:"name"`
Onion string `json:"onion"`
Status string `json:"status"`
Picture string `json:"picture"`
DefaultPicture string `json:"defaultPicture"`
Accepted bool `json:"accepted"`
Blocked bool `json:"blocked"`
SaveHistory string `json:"saveConversationHistory"`
Messages int `json:"numMessages"`
Unread int `json:"numUnread"`
LastMessage string `json:"lastMsgTime"`
IsGroup bool `json:"isGroup"`
GroupServer string `json:"groupServer"`
IsArchived bool `json:"isArchived"`
Identifier int `json:"identifier"`
}

View File

@ -130,7 +130,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
online, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline)
// Name always exists
e.Data[constants.Name], _ = profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
e.Data[constants2.DefaultProfilePicture] = RandomProfileImage(onion)
// if a custom profile image exists then default to it.
key, exists := profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.CustomProfileImageKey)
if !exists {
@ -221,20 +221,21 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
lastMessage, _ := profile.GetMostRecentMessages(conversationInfo.ID, 0, 0, 1)
contacts = append(contacts, Contact{
Name: name,
Identifier: conversationInfo.ID,
Onion: conversationInfo.Handle,
Status: connections.ConnectionStateName[state],
Picture: cpicPath,
Accepted: conversationInfo.Accepted,
Blocked: blocked,
SaveHistory: saveHistory,
Messages: count,
Unread: 0,
LastMessage: strconv.Itoa(getLastMessageTime(lastMessage)),
IsGroup: conversationInfo.IsGroup(),
GroupServer: groupServer,
IsArchived: isArchived == event.True,
Name: name,
Identifier: conversationInfo.ID,
Onion: conversationInfo.Handle,
Status: connections.ConnectionStateName[state],
Picture: cpicPath,
DefaultPicture: RandomProfileImage(conversationInfo.Handle),
Accepted: conversationInfo.Accepted,
Blocked: blocked,
SaveHistory: saveHistory,
Messages: count,
Unread: 0,
LastMessage: strconv.Itoa(getLastMessageTime(lastMessage)),
IsGroup: conversationInfo.IsGroup(),
GroupServer: groupServer,
IsArchived: isArchived == event.True,
})
}
}
@ -356,6 +357,7 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
lastMessage, _ := profile.GetMostRecentMessages(conversationID, 0, 0, 1)
ev.Event.Data["unread"] = strconv.Itoa(count) // if this is a new contact with messages attached then by-definition these are unread...
ev.Event.Data[constants2.Picture] = RandomProfileImage(conversationInfo.Handle)
ev.Event.Data[constants2.DefaultProfilePicture] = RandomProfileImage(conversationInfo.Handle)
ev.Event.Data["numMessages"] = strconv.Itoa(count)
ev.Event.Data["nick"] = conversationInfo.Handle
ev.Event.Data["status"] = connections.ConnectionStateName[profile.GetPeerState(conversationInfo.Handle)]