for getConnectionsSortedByLastSeen, ignore accepted on servers #480

Merged
sarah merged 2 commits from serverAccept into master 2022-12-06 05:28:31 +00:00
2 changed files with 17 additions and 6 deletions
Showing only changes of commit 491ff6e710 - Show all commits

View File

@ -203,7 +203,7 @@ func (cr *contactRetry) run() {
case event.QueueJoinServer:
fallthrough
case event.QueuePeerRequest:
lastSeen, err := time.Parse(e.Data[event.LastSeen], time.RFC3339Nano)
lastSeen, err := time.Parse(time.RFC3339Nano, e.Data[event.LastSeen])
if err != nil {
lastSeen = event.CwtchEpoch
}

View File

@ -1030,24 +1030,35 @@ type LastSeenConversation struct {
}
func (cp *cwtchPeer) GetConversationLastSeenTime(conversationId int) time.Time {
lastTime := event.CwtchEpoch
timestamp, err := cp.GetConversationAttribute(conversationId, attr.LocalScope.ConstructScopedZonedPath(attr.ProfileZone.ConstructZonedPath(constants.AttrLastConnectionTime)))
if err == nil {
if time, err := time.Parse(time.RFC3339Nano, timestamp); err == nil {
return time
lastTime = time
}
}
// for peers
lastMessage, _ := cp.GetMostRecentMessages(conversationId, 0, 0, 1)
if len(lastMessage) != 0 {
time, err := time.Parse(time.RFC3339Nano, lastMessage[0].Attr[constants.AttrSentTimestamp])
lastMsgTime, err := time.Parse(time.RFC3339Nano, lastMessage[0].Attr[constants.AttrSentTimestamp])
if err == nil {
return time
if lastMsgTime.After(lastTime) {
lastTime = lastMsgTime
}
}
}
// Cwtch launch date
return event.CwtchEpoch
// for servers
recentTimeStr, err := cp.GetConversationAttribute(conversationId, attr.LocalScope.ConstructScopedZonedPath(attr.LegacyGroupZone.ConstructZonedPath(constants.SyncMostRecentMessageTime)))
if err == nil {
if recentTime, err := time.Parse(time.RFC3339Nano, recentTimeStr); err == nil && recentTime.After(lastTime) {
lastTime = recentTime
}
}
return lastTime
}
func (cp *cwtchPeer) getConnectionsSortedByLastSeen(doPeers, doServers bool) []*LastSeenConversation {