Merge pull request 'add lastSeenMessageId got contact' (#85) from lastSeenMid into trunk
continuous-integration/drone/push Build is passing Details

Reviewed-on: #85
Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2022-04-20 00:19:20 +00:00
commit d8ed0bf57c
2 changed files with 4 additions and 0 deletions

View File

@ -14,6 +14,7 @@ type Contact struct {
SaveHistory string `json:"saveConversationHistory"`
Messages int `json:"numMessages"`
Unread int `json:"numUnread"`
LastSeenMessageId int `json:"lastSeenMessageId"`
LastMessage string `json:"lastMsgTime"`
IsGroup bool `json:"isGroup"`
GroupServer string `json:"groupServer"`

View File

@ -202,6 +202,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
}
unread := 0
lastSeenMessageId := -1
lastSeenTimeStr, set := conversationInfo.GetAttribute(attr.LocalScope, attr.ProfileZone, constants2.LastSeenTime)
if set {
lastSeenTime, err := time.Parse(constants2.DartIso8601, lastSeenTimeStr)
@ -215,6 +216,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
if msgTime.UTC().After(lastSeenTime.UTC()) {
unread++
} else {
lastSeenMessageId = message.ID
break
}
}
@ -265,6 +267,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
SaveHistory: saveHistory,
Messages: count,
Unread: unread,
LastSeenMessageId: lastSeenMessageId,
LastMessage: strconv.Itoa(getLastMessageTime(lastMessage)),
IsGroup: conversationInfo.IsGroup(),
GroupServer: groupServer,