mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
simplify lastSeen handling
This commit is contained in:
parent
218bea5a3e
commit
df1be01f54
@ -307,7 +307,6 @@ func (server *Server) RunClient(conn IRCConn) {
|
|||||||
// give them 1k of grace over the limit:
|
// give them 1k of grace over the limit:
|
||||||
socket := NewSocket(conn, config.Server.MaxSendQBytes)
|
socket := NewSocket(conn, config.Server.MaxSendQBytes)
|
||||||
client := &Client{
|
client := &Client{
|
||||||
lastSeen: make(map[string]time.Time),
|
|
||||||
lastActive: now,
|
lastActive: now,
|
||||||
channels: make(ChannelSet),
|
channels: make(ChannelSet),
|
||||||
ctime: now,
|
ctime: now,
|
||||||
@ -369,11 +368,8 @@ func (server *Server) RunClient(conn IRCConn) {
|
|||||||
func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string, lastSeen map[string]time.Time, uModes modes.Modes) {
|
func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string, lastSeen map[string]time.Time, uModes modes.Modes) {
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
config := server.Config()
|
config := server.Config()
|
||||||
if lastSeen == nil {
|
if lastSeen == nil && account.Settings.AutoreplayMissed {
|
||||||
lastSeen = make(map[string]time.Time)
|
lastSeen = map[string]time.Time{"": now}
|
||||||
if account.Settings.AutoreplayMissed {
|
|
||||||
lastSeen[""] = now
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &Client{
|
client := &Client{
|
||||||
@ -746,6 +742,9 @@ func (client *Client) Touch(active bool, session *Session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) setLastSeen(now time.Time, deviceID string) {
|
func (client *Client) setLastSeen(now time.Time, deviceID string) {
|
||||||
|
if client.lastSeen == nil {
|
||||||
|
client.lastSeen = make(map[string]time.Time)
|
||||||
|
}
|
||||||
client.lastSeen[deviceID] = now
|
client.lastSeen[deviceID] = now
|
||||||
// evict the least-recently-used entry if necessary
|
// evict the least-recently-used entry if necessary
|
||||||
if maxDeviceIDsPerClient < len(client.lastSeen) {
|
if maxDeviceIDsPerClient < len(client.lastSeen) {
|
||||||
|
@ -334,7 +334,7 @@ func (client *Client) SetAccountSettings(settings AccountSettings) {
|
|||||||
becameAlwaysOn = (!client.alwaysOn && alwaysOn)
|
becameAlwaysOn = (!client.alwaysOn && alwaysOn)
|
||||||
client.alwaysOn = alwaysOn
|
client.alwaysOn = alwaysOn
|
||||||
if autoreplayMissedDisabled {
|
if autoreplayMissedDisabled {
|
||||||
client.lastSeen = make(map[string]time.Time)
|
client.lastSeen = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.accountSettings = settings
|
client.accountSettings = settings
|
||||||
|
Loading…
Reference in New Issue
Block a user