Add DefaultPicture parameter to Contact and Profiles #70
|
@ -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
10
lib.go
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
|
|
Reference in New Issue