Compare commits

..

No commits in common. "17acc3b8ef5e80814e84b898f6f39f8dfdee7a22" and "4e4e3315ddd86001907efdb23ed842853554da8d" have entirely different histories.

4 changed files with 39 additions and 33 deletions

View File

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

10
lib.go
View File

@ -741,6 +741,16 @@ 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 // 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... // there is only one, and it is the custom profile image...
profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants2.CustomProfileImageKey, fileKey) 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 { } else {
profile.SendMessage(conversationID, overlay) profile.SendMessage(conversationID, overlay)
} }

View File

@ -1,19 +1,18 @@
package utils package utils
type Contact struct { type Contact struct {
Name string `json:"name"` Name string `json:"name"`
Onion string `json:"onion"` Onion string `json:"onion"`
Status string `json:"status"` Status string `json:"status"`
Picture string `json:"picture"` Picture string `json:"picture"`
DefaultPicture string `json:"defaultPicture"` Accepted bool `json:"accepted"`
Accepted bool `json:"accepted"` Blocked bool `json:"blocked"`
Blocked bool `json:"blocked"` SaveHistory string `json:"saveConversationHistory"`
SaveHistory string `json:"saveConversationHistory"` Messages int `json:"numMessages"`
Messages int `json:"numMessages"` Unread int `json:"numUnread"`
Unread int `json:"numUnread"` LastMessage string `json:"lastMsgTime"`
LastMessage string `json:"lastMsgTime"` IsGroup bool `json:"isGroup"`
IsGroup bool `json:"isGroup"` GroupServer string `json:"groupServer"`
GroupServer string `json:"groupServer"` IsArchived bool `json:"isArchived"`
IsArchived bool `json:"isArchived"` Identifier int `json:"identifier"`
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) online, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline)
// Name always exists // Name always exists
e.Data[constants.Name], _ = profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name) 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. // if a custom profile image exists then default to it.
key, exists := profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.CustomProfileImageKey) key, exists := profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.CustomProfileImageKey)
if !exists { if !exists {
@ -221,21 +221,20 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
lastMessage, _ := profile.GetMostRecentMessages(conversationInfo.ID, 0, 0, 1) lastMessage, _ := profile.GetMostRecentMessages(conversationInfo.ID, 0, 0, 1)
contacts = append(contacts, Contact{ contacts = append(contacts, Contact{
Name: name, Name: name,
Identifier: conversationInfo.ID, Identifier: conversationInfo.ID,
Onion: conversationInfo.Handle, Onion: conversationInfo.Handle,
Status: connections.ConnectionStateName[state], Status: connections.ConnectionStateName[state],
Picture: cpicPath, Picture: cpicPath,
DefaultPicture: RandomProfileImage(conversationInfo.Handle), Accepted: conversationInfo.Accepted,
Accepted: conversationInfo.Accepted, Blocked: blocked,
Blocked: blocked, SaveHistory: saveHistory,
SaveHistory: saveHistory, Messages: count,
Messages: count, Unread: 0,
Unread: 0, LastMessage: strconv.Itoa(getLastMessageTime(lastMessage)),
LastMessage: strconv.Itoa(getLastMessageTime(lastMessage)), IsGroup: conversationInfo.IsGroup(),
IsGroup: conversationInfo.IsGroup(), GroupServer: groupServer,
GroupServer: groupServer, IsArchived: isArchived == event.True,
IsArchived: isArchived == event.True,
}) })
} }
} }
@ -357,7 +356,6 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
lastMessage, _ := profile.GetMostRecentMessages(conversationID, 0, 0, 1) 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["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.Picture] = RandomProfileImage(conversationInfo.Handle)
ev.Event.Data[constants2.DefaultProfilePicture] = RandomProfileImage(conversationInfo.Handle)
ev.Event.Data["numMessages"] = strconv.Itoa(count) ev.Event.Data["numMessages"] = strconv.Itoa(count)
ev.Event.Data["nick"] = conversationInfo.Handle ev.Event.Data["nick"] = conversationInfo.Handle
ev.Event.Data["status"] = connections.ConnectionStateName[profile.GetPeerState(conversationInfo.Handle)] ev.Event.Data["status"] = connections.ConnectionStateName[profile.GetPeerState(conversationInfo.Handle)]