Merge pull request #1597 from slingamn/away_session.1

fix #1531
This commit is contained in:
Shivaram Lingamneni
2021-03-18 03:28:03 -04:00
committed by GitHub
4 changed files with 60 additions and 37 deletions
+12 -15
View File
@@ -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,9 +487,7 @@ 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")
client.setAutoAwayNoMutex(config)
}
}
@@ -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)
}
@@ -1459,15 +1458,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 {
@@ -1524,7 +1521,7 @@ func (client *Client) destroy(session *Session) {
client.server.stats.Remove(registered, invisible, operator)
}
if autoAway {
if becameAutoAway {
dispatchAwayNotify(client, true, awayMessage)
}