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"` SaveHistory string `json:"saveConversationHistory"`
Messages int `json:"numMessages"` Messages int `json:"numMessages"`
Unread int `json:"numUnread"` Unread int `json:"numUnread"`
LastSeenMessageId int `json:"lastSeenMessageId"`
LastMessage string `json:"lastMsgTime"` LastMessage string `json:"lastMsgTime"`
IsGroup bool `json:"isGroup"` IsGroup bool `json:"isGroup"`
GroupServer string `json:"groupServer"` GroupServer string `json:"groupServer"`

View File

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