3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00
This commit is contained in:
Shivaram Lingamneni 2020-06-18 03:38:00 -04:00
parent 7af1f20223
commit 17cd831319
2 changed files with 19 additions and 3 deletions

View File

@ -728,7 +728,7 @@ func (client *Client) Touch(active bool, session *Session) {
client.lastActive = now
session.lastActive = now
}
if client.accountSettings.AutoreplayMissed {
if client.accountSettings.AutoreplayMissed || session.deviceID != "" {
client.setLastSeen(now, session.deviceID)
if now.Sub(client.lastSeenLastWrite) > lastSeenWriteInterval {
markDirty = true
@ -1228,8 +1228,10 @@ func (client *Client) Quit(message string, session *Session) {
func (client *Client) destroy(session *Session) {
config := client.server.Config()
var sessionsToDestroy []*Session
var saveLastSeen bool
client.stateMutex.Lock()
details := client.detailsNoMutex()
brbState := client.brbTimer.state
brbAt := client.brbTimer.brbAt
@ -1237,7 +1239,7 @@ func (client *Client) destroy(session *Session) {
sessionRemoved := false
registered := client.registered
alwaysOn := client.alwaysOn
saveLastSeen := alwaysOn && client.accountSettings.AutoreplayMissed
var remainingSessions int
if session == nil {
sessionsToDestroy = client.sessions
@ -1250,6 +1252,20 @@ func (client *Client) destroy(session *Session) {
}
}
// save last seen if applicable:
if alwaysOn {
if client.accountSettings.AutoreplayMissed {
saveLastSeen = true
} else {
for _, session := range sessionsToDestroy {
if session.deviceID != "" {
saveLastSeen = true
break
}
}
}
}
// should we destroy the whole client this time?
// BRB is not respected if this is a destroy of the whole client (i.e., session == nil)
brbEligible := session != nil && brbState == BrbEnabled

View File

@ -104,7 +104,7 @@ func (client *Client) AddSession(session *Session) (success bool, numSessions in
newSessions := make([]*Session, len(client.sessions)+1)
copy(newSessions, client.sessions)
newSessions[len(newSessions)-1] = session
if client.accountSettings.AutoreplayMissed {
if client.accountSettings.AutoreplayMissed || session.deviceID != "" {
lastSeen = client.lastSeen[session.deviceID]
}
client.sessions = newSessions