forked from External/ergo
fix #1531
AWAY status should be tracked per-session: 1. With auto-away enabled, away status is aggregated across sessions (if any session is not away, the client is not away, else use the away status that was set most recently) 2. With auto-away disabled, we get the legacy behavior where AWAY applies directly to the client
This commit is contained in:
parent
507d53c507
commit
70b20750aa
4 changed files with 59 additions and 36 deletions
|
|
@ -78,8 +78,6 @@ type Client struct {
|
|||
accountName string // display name of the account: uncasefolded, '*' if not logged in
|
||||
accountRegDate time.Time
|
||||
accountSettings AccountSettings
|
||||
away bool
|
||||
autoAway bool
|
||||
awayMessage string
|
||||
brbTimer BrbTimer
|
||||
channels ChannelSet
|
||||
|
|
@ -177,6 +175,9 @@ type Session struct {
|
|||
|
||||
quitMessage string
|
||||
|
||||
awayMessage string
|
||||
awayAt time.Time
|
||||
|
||||
capabilities caps.Set
|
||||
capState caps.State
|
||||
capVersion caps.Version
|
||||
|
|
@ -486,8 +487,6 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, channelToStatus m
|
|||
}
|
||||
|
||||
if persistenceEnabled(config.Accounts.Multiclient.AutoAway, client.accountSettings.AutoAway) {
|
||||
client.autoAway = true
|
||||
client.away = true
|
||||
client.awayMessage = client.t("User is currently disconnected")
|
||||
}
|
||||
}
|
||||
|
|
@ -675,7 +674,7 @@ func (client *Client) run(session *Session) {
|
|||
session.playResume()
|
||||
session.resumeDetails = nil
|
||||
client.brbTimer.Disable()
|
||||
client.SetAway(false, "") // clear BRB message if any
|
||||
session.SetAway("") // clear BRB message if any
|
||||
} else {
|
||||
client.playReattachMessages(session)
|
||||
}
|
||||
|
|
@ -1458,15 +1457,13 @@ func (client *Client) destroy(session *Session) {
|
|||
client.dirtyBits |= IncludeLastSeen
|
||||
}
|
||||
|
||||
autoAway := false
|
||||
becameAutoAway := false
|
||||
var awayMessage string
|
||||
if alwaysOn && !client.away && remainingSessions == 0 &&
|
||||
persistenceEnabled(config.Accounts.Multiclient.AutoAway, client.accountSettings.AutoAway) {
|
||||
autoAway = true
|
||||
client.autoAway = true
|
||||
client.away = true
|
||||
awayMessage = config.languageManager.Translate(client.languages, `User is currently disconnected`)
|
||||
client.awayMessage = awayMessage
|
||||
if alwaysOn && persistenceEnabled(config.Accounts.Multiclient.AutoAway, client.accountSettings.AutoAway) {
|
||||
wasAway := client.awayMessage != ""
|
||||
client.setAutoAwayNoMutex(config)
|
||||
awayMessage = client.awayMessage
|
||||
becameAutoAway = !wasAway && awayMessage != ""
|
||||
}
|
||||
|
||||
if client.registrationTimer != nil {
|
||||
|
|
@ -1523,7 +1520,7 @@ func (client *Client) destroy(session *Session) {
|
|||
client.server.stats.Remove(registered, invisible, operator)
|
||||
}
|
||||
|
||||
if autoAway {
|
||||
if becameAutoAway {
|
||||
dispatchAwayNotify(client, true, awayMessage)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue