Merge pull request 'include ACL struct in relevant conversation events' (#82) from acl into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #82 Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
commit
3d8ef9f06b
|
@ -1,20 +1,23 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
|
import "cwtch.im/cwtch/model"
|
||||||
|
|
||||||
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"`
|
DefaultPicture string `json:"defaultPicture"`
|
||||||
Accepted bool `json:"accepted"`
|
Accepted bool `json:"accepted"`
|
||||||
Blocked bool `json:"blocked"`
|
AccessControlList model.AccessControlList `json:"accessControlList"`
|
||||||
SaveHistory string `json:"saveConversationHistory"`
|
Blocked bool `json:"blocked"`
|
||||||
Messages int `json:"numMessages"`
|
SaveHistory string `json:"saveConversationHistory"`
|
||||||
Unread int `json:"numUnread"`
|
Messages int `json:"numMessages"`
|
||||||
LastMessage string `json:"lastMsgTime"`
|
Unread int `json:"numUnread"`
|
||||||
IsGroup bool `json:"isGroup"`
|
LastMessage string `json:"lastMsgTime"`
|
||||||
GroupServer string `json:"groupServer"`
|
IsGroup bool `json:"isGroup"`
|
||||||
IsArchived bool `json:"isArchived"`
|
GroupServer string `json:"groupServer"`
|
||||||
Identifier int `json:"identifier"`
|
IsArchived bool `json:"isArchived"`
|
||||||
NotificationPolicy string `json:"notificationPolicy"`
|
Identifier int `json:"identifier"`
|
||||||
|
NotificationPolicy string `json:"notificationPolicy"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
Picture: cpicPath,
|
Picture: cpicPath,
|
||||||
DefaultPicture: defaultPath,
|
DefaultPicture: defaultPath,
|
||||||
Accepted: conversationInfo.Accepted,
|
Accepted: conversationInfo.Accepted,
|
||||||
|
AccessControlList: conversationInfo.ACL,
|
||||||
Blocked: blocked,
|
Blocked: blocked,
|
||||||
SaveHistory: saveHistory,
|
SaveHistory: saveHistory,
|
||||||
Messages: count,
|
Messages: count,
|
||||||
|
@ -395,6 +396,8 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
accepted = constants.True
|
accepted = constants.True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acl, _ := json.Marshal(conversationInfo.ACL)
|
||||||
|
|
||||||
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)
|
||||||
|
@ -403,6 +406,7 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
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)]
|
||||||
ev.Event.Data["accepted"] = accepted
|
ev.Event.Data["accepted"] = accepted
|
||||||
|
ev.Event.Data["accessControlList"] = string(acl)
|
||||||
ev.Event.Data["blocked"] = blocked
|
ev.Event.Data["blocked"] = blocked
|
||||||
ev.Event.Data["loading"] = "false"
|
ev.Event.Data["loading"] = "false"
|
||||||
ev.Event.Data["lastMsgTime"] = strconv.Itoa(getLastMessageTime(lastMessage))
|
ev.Event.Data["lastMsgTime"] = strconv.Itoa(getLastMessageTime(lastMessage))
|
||||||
|
@ -411,6 +415,11 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
// condition *should* never happen.
|
// condition *should* never happen.
|
||||||
groupPic := RandomGroupImage(ev.Event.Data[event.GroupID])
|
groupPic := RandomGroupImage(ev.Event.Data[event.GroupID])
|
||||||
ev.Event.Data[constants2.Picture] = groupPic
|
ev.Event.Data[constants2.Picture] = groupPic
|
||||||
|
|
||||||
|
conversationID, _ := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||||
|
conversationInfo, _ := profile.GetConversationInfo(conversationID)
|
||||||
|
acl, _ := json.Marshal(conversationInfo.ACL)
|
||||||
|
ev.Event.Data["accessControlList"] = string(acl)
|
||||||
case event.NewGroup:
|
case event.NewGroup:
|
||||||
// This event should only happen after we have validated the invite, as such the error
|
// This event should only happen after we have validated the invite, as such the error
|
||||||
// condition *should* never happen.
|
// condition *should* never happen.
|
||||||
|
@ -418,8 +427,13 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
if invite, err := model.ValidateInvite(serializedInvite); err == nil {
|
if invite, err := model.ValidateInvite(serializedInvite); err == nil {
|
||||||
groupPic := RandomGroupImage(invite.GroupID)
|
groupPic := RandomGroupImage(invite.GroupID)
|
||||||
ev.Event.Data[constants2.Picture] = groupPic
|
ev.Event.Data[constants2.Picture] = groupPic
|
||||||
|
|
||||||
|
conversationID, _ := strconv.Atoi(ev.Event.Data[event.ConversationID])
|
||||||
|
conversationInfo, _ := profile.GetConversationInfo(conversationID)
|
||||||
|
acl, _ := json.Marshal(conversationInfo.ACL)
|
||||||
|
ev.Event.Data["accessControlList"] = string(acl)
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("received a new group event which contained an invalid invite %v. this should never happen and likely means there is a bug in cwtch. Please file a ticket @ https://git.openprivcy.ca/cwtch.im/cwtch", err)
|
log.Errorf("received a new group event which contained an invalid invite %v. this should never happen and likely means there is a bug in cwtch. Please file a ticket @ https://git.openprivacy.ca/cwtch.im/cwtch", err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
case event.PeerStateChange:
|
case event.PeerStateChange:
|
||||||
|
|
Reference in New Issue