mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +01:00
commit
3662698f87
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user