GetConversationLastSeenTime use constants.SyncMostRecentMessageTime for servers; fix time parsing error in contact retry
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
6eef88fc2d
commit
491ff6e710
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue