diff --git a/gencapdefs.py b/gencapdefs.py index f3825c51..23efda52 100644 --- a/gencapdefs.py +++ b/gencapdefs.py @@ -113,7 +113,7 @@ CAPDEFS = [ ), CapDef( identifier="Resume", - name="draft/resume-0.4", + name="draft/resume-0.5", url="https://github.com/DanielOaks/ircv3-specifications/blob/master+resume/extensions/resume.md", standard="proposed IRCv3", ), diff --git a/irc/caps/defs.go b/irc/caps/defs.go index 0ac48337..6a691bbc 100644 --- a/irc/caps/defs.go +++ b/irc/caps/defs.go @@ -77,7 +77,7 @@ const ( // https://github.com/SaberUK/ircv3-specifications/blob/rename/extensions/rename.md Rename Capability = iota - // Resume is the proposed IRCv3 capability named "draft/resume-0.4": + // Resume is the proposed IRCv3 capability named "draft/resume-0.5": // https://github.com/DanielOaks/ircv3-specifications/blob/master+resume/extensions/resume.md Resume Capability = iota @@ -141,7 +141,7 @@ var ( "message-tags", "multi-prefix", "draft/rename", - "draft/resume-0.4", + "draft/resume-0.5", "sasl", "server-time", "draft/setname", diff --git a/irc/client.go b/irc/client.go index add5b3d4..f28153db 100644 --- a/irc/client.go +++ b/irc/client.go @@ -579,9 +579,6 @@ func (session *Session) playResume() { } timestamp := session.resumeDetails.Timestamp - if timestamp.IsZero() { - timestamp = session.client.ctime - } gap := lastDiscarded.Sub(timestamp) session.resumeDetails.HistoryIncomplete = gap > 0 gapSeconds := int(gap.Seconds()) + 1 // round up to avoid confusion diff --git a/irc/commands.go b/irc/commands.go index f5049948..2b221621 100644 --- a/irc/commands.go +++ b/irc/commands.go @@ -232,7 +232,7 @@ func init() { "RESUME": { handler: resumeHandler, usablePreReg: true, - minParams: 1, + minParams: 2, }, "SAJOIN": { handler: sajoinHandler, diff --git a/irc/handlers.go b/irc/handlers.go index e6cf61ce..98b77c8d 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2359,27 +2359,24 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re return false } -// RESUME [timestamp] +// RESUME func resumeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { - details := ResumeDetails{ - PresentedToken: msg.Params[0], - } - if client.registered { rb.Add(nil, server.name, "FAIL", "RESUME", "REGISTRATION_IS_COMPLETED", client.t("Cannot resume connection, connection registration has already been completed")) return false } - if 1 < len(msg.Params) { - ts, err := time.Parse(IRCv3TimestampFormat, msg.Params[1]) - if err == nil { - details.Timestamp = ts - } else { - rb.Add(nil, server.name, "WARN", "RESUME", "HISTORY_LOST", client.t("Timestamp is not in 2006-01-02T15:04:05.999Z format, ignoring it")) - } + ts, err := time.Parse(IRCv3TimestampFormat, msg.Params[1]) + if err != nil { + rb.Add(nil, server.name, "FAIL", "RESUME", "INVALID_TIMESTAMP", client.t("Cannot resume connection, timestamp is not valid")) + return false + } + + rb.session.resumeDetails = &ResumeDetails{ + PresentedToken: msg.Params[0], + Timestamp: ts, } - rb.session.resumeDetails = &details return false }