3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +01:00

update to proposed draft/resume-0.5 behavior

This commit is contained in:
Shivaram Lingamneni 2019-05-29 05:58:47 -04:00
parent b134a63dc2
commit acc9d8c13d
5 changed files with 14 additions and 20 deletions

View File

@ -113,7 +113,7 @@ CAPDEFS = [
), ),
CapDef( CapDef(
identifier="Resume", 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", url="https://github.com/DanielOaks/ircv3-specifications/blob/master+resume/extensions/resume.md",
standard="proposed IRCv3", standard="proposed IRCv3",
), ),

View File

@ -77,7 +77,7 @@ const (
// https://github.com/SaberUK/ircv3-specifications/blob/rename/extensions/rename.md // https://github.com/SaberUK/ircv3-specifications/blob/rename/extensions/rename.md
Rename Capability = iota 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 // https://github.com/DanielOaks/ircv3-specifications/blob/master+resume/extensions/resume.md
Resume Capability = iota Resume Capability = iota
@ -141,7 +141,7 @@ var (
"message-tags", "message-tags",
"multi-prefix", "multi-prefix",
"draft/rename", "draft/rename",
"draft/resume-0.4", "draft/resume-0.5",
"sasl", "sasl",
"server-time", "server-time",
"draft/setname", "draft/setname",

View File

@ -579,9 +579,6 @@ func (session *Session) playResume() {
} }
timestamp := session.resumeDetails.Timestamp timestamp := session.resumeDetails.Timestamp
if timestamp.IsZero() {
timestamp = session.client.ctime
}
gap := lastDiscarded.Sub(timestamp) gap := lastDiscarded.Sub(timestamp)
session.resumeDetails.HistoryIncomplete = gap > 0 session.resumeDetails.HistoryIncomplete = gap > 0
gapSeconds := int(gap.Seconds()) + 1 // round up to avoid confusion gapSeconds := int(gap.Seconds()) + 1 // round up to avoid confusion

View File

@ -232,7 +232,7 @@ func init() {
"RESUME": { "RESUME": {
handler: resumeHandler, handler: resumeHandler,
usablePreReg: true, usablePreReg: true,
minParams: 1, minParams: 2,
}, },
"SAJOIN": { "SAJOIN": {
handler: sajoinHandler, handler: sajoinHandler,

View File

@ -2359,27 +2359,24 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
return false return false
} }
// RESUME <token> [timestamp] // RESUME <token> <timestamp>
func resumeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func resumeHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
details := ResumeDetails{
PresentedToken: msg.Params[0],
}
if client.registered { if client.registered {
rb.Add(nil, server.name, "FAIL", "RESUME", "REGISTRATION_IS_COMPLETED", client.t("Cannot resume connection, connection registration has already been completed")) rb.Add(nil, server.name, "FAIL", "RESUME", "REGISTRATION_IS_COMPLETED", client.t("Cannot resume connection, connection registration has already been completed"))
return false return false
} }
if 1 < len(msg.Params) { ts, err := time.Parse(IRCv3TimestampFormat, msg.Params[1])
ts, err := time.Parse(IRCv3TimestampFormat, msg.Params[1]) if err != nil {
if err == nil { rb.Add(nil, server.name, "FAIL", "RESUME", "INVALID_TIMESTAMP", client.t("Cannot resume connection, timestamp is not valid"))
details.Timestamp = ts return false
} 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"))
} rb.session.resumeDetails = &ResumeDetails{
PresentedToken: msg.Params[0],
Timestamp: ts,
} }
rb.session.resumeDetails = &details
return false return false
} }