diff --git a/irc/accounts.go b/irc/accounts.go index cbb600be..79646875 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -130,7 +130,8 @@ func (am *AccountManager) createAlwaysOnClients(config *Config) { am.server.AddAlwaysOnClient( account, am.loadChannels(accountName), - am.loadLastSeen(accountName), + am.loadTimeMap(keyAccountLastSeen, accountName), + am.loadTimeMap(keyAccountReadMarkers, accountName), am.loadModes(accountName), am.loadRealname(accountName), ) @@ -675,8 +676,8 @@ func (am *AccountManager) saveTimeMap(account, key string, timeMap map[string]ti } } -func (am *AccountManager) loadLastSeen(account string) (lastSeen map[string]time.Time) { - key := fmt.Sprintf(keyAccountLastSeen, account) +func (am *AccountManager) loadTimeMap(baseKey, account string) (lastSeen map[string]time.Time) { + key := fmt.Sprintf(baseKey, account) var lsText string am.server.store.Update(func(tx *buntdb.Tx) error { lsText, _ = tx.Get(key) diff --git a/irc/client.go b/irc/client.go index 7e2ead9c..debc8b1e 100644 --- a/irc/client.go +++ b/irc/client.go @@ -389,7 +389,7 @@ func (server *Server) RunClient(conn IRCConn) { client.run(session) } -func (server *Server) AddAlwaysOnClient(account ClientAccount, channelToStatus map[string]alwaysOnChannelStatus, lastSeen map[string]time.Time, uModes modes.Modes, realname string) { +func (server *Server) AddAlwaysOnClient(account ClientAccount, channelToStatus map[string]alwaysOnChannelStatus, lastSeen, readMarkers map[string]time.Time, uModes modes.Modes, realname string) { now := time.Now().UTC() config := server.Config() if lastSeen == nil && account.Settings.AutoreplayMissed { @@ -407,12 +407,13 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, channelToStatus m } client := &Client{ - lastSeen: lastSeen, - lastActive: now, - channels: make(ChannelSet), - ctime: now, - languages: server.Languages().Default(), - server: server, + lastSeen: lastSeen, + readMarkers: readMarkers, + lastActive: now, + channels: make(ChannelSet), + ctime: now, + languages: server.Languages().Default(), + server: server, username: username, cloakedHostname: cloakedHostname, diff --git a/irc/getters.go b/irc/getters.go index f4b86391..6031659f 100644 --- a/irc/getters.go +++ b/irc/getters.go @@ -4,6 +4,7 @@ package irc import ( + "fmt" "net" "sync/atomic" "time" @@ -493,7 +494,7 @@ func (client *Client) GetReadMarker(cfname string) (result string) { t, ok := client.readMarkers[cfname] client.stateMutex.RUnlock() if ok { - return t.Format(IRCv3TimestampFormat) + return fmt.Sprintf("timestamp=%s", t.Format(IRCv3TimestampFormat)) } return "*" } diff --git a/irc/handlers.go b/irc/handlers.go index 75f2d54f..43cd00f8 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2770,14 +2770,14 @@ func markReadHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res } // "MARKREAD client set command": MARKREAD - readTimestamp := msg.Params[1] + readTimestamp := strings.TrimPrefix(msg.Params[1], "timestamp=") readTime, err := time.Parse(IRCv3TimestampFormat, readTimestamp) if err != nil { rb.Add(nil, server.name, "FAIL", "MARKREAD", "INVALID_PARAMS", utils.SafeErrorParam(readTimestamp), client.t("Invalid timestamp")) return } result := client.SetReadMarker(cftarget, readTime) - readTimestamp = result.Format(IRCv3TimestampFormat) + readTimestamp = fmt.Sprintf("timestamp=%s", result.Format(IRCv3TimestampFormat)) // inform the originating session whether it was a success or a no-op: rb.Add(nil, server.name, "MARKREAD", unfoldedTarget, readTimestamp) if result.Equal(readTime) {