mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
fix #1144
This commit is contained in:
parent
7af1f20223
commit
17cd831319
@ -728,7 +728,7 @@ func (client *Client) Touch(active bool, session *Session) {
|
|||||||
client.lastActive = now
|
client.lastActive = now
|
||||||
session.lastActive = now
|
session.lastActive = now
|
||||||
}
|
}
|
||||||
if client.accountSettings.AutoreplayMissed {
|
if client.accountSettings.AutoreplayMissed || session.deviceID != "" {
|
||||||
client.setLastSeen(now, session.deviceID)
|
client.setLastSeen(now, session.deviceID)
|
||||||
if now.Sub(client.lastSeenLastWrite) > lastSeenWriteInterval {
|
if now.Sub(client.lastSeenLastWrite) > lastSeenWriteInterval {
|
||||||
markDirty = true
|
markDirty = true
|
||||||
@ -1228,8 +1228,10 @@ func (client *Client) Quit(message string, session *Session) {
|
|||||||
func (client *Client) destroy(session *Session) {
|
func (client *Client) destroy(session *Session) {
|
||||||
config := client.server.Config()
|
config := client.server.Config()
|
||||||
var sessionsToDestroy []*Session
|
var sessionsToDestroy []*Session
|
||||||
|
var saveLastSeen bool
|
||||||
|
|
||||||
client.stateMutex.Lock()
|
client.stateMutex.Lock()
|
||||||
|
|
||||||
details := client.detailsNoMutex()
|
details := client.detailsNoMutex()
|
||||||
brbState := client.brbTimer.state
|
brbState := client.brbTimer.state
|
||||||
brbAt := client.brbTimer.brbAt
|
brbAt := client.brbTimer.brbAt
|
||||||
@ -1237,7 +1239,7 @@ func (client *Client) destroy(session *Session) {
|
|||||||
sessionRemoved := false
|
sessionRemoved := false
|
||||||
registered := client.registered
|
registered := client.registered
|
||||||
alwaysOn := client.alwaysOn
|
alwaysOn := client.alwaysOn
|
||||||
saveLastSeen := alwaysOn && client.accountSettings.AutoreplayMissed
|
|
||||||
var remainingSessions int
|
var remainingSessions int
|
||||||
if session == nil {
|
if session == nil {
|
||||||
sessionsToDestroy = client.sessions
|
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?
|
// 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)
|
// BRB is not respected if this is a destroy of the whole client (i.e., session == nil)
|
||||||
brbEligible := session != nil && brbState == BrbEnabled
|
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)
|
newSessions := make([]*Session, len(client.sessions)+1)
|
||||||
copy(newSessions, client.sessions)
|
copy(newSessions, client.sessions)
|
||||||
newSessions[len(newSessions)-1] = session
|
newSessions[len(newSessions)-1] = session
|
||||||
if client.accountSettings.AutoreplayMissed {
|
if client.accountSettings.AutoreplayMissed || session.deviceID != "" {
|
||||||
lastSeen = client.lastSeen[session.deviceID]
|
lastSeen = client.lastSeen[session.deviceID]
|
||||||
}
|
}
|
||||||
client.sessions = newSessions
|
client.sessions = newSessions
|
||||||
|
Loading…
Reference in New Issue
Block a user