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:
parent
b134a63dc2
commit
acc9d8c13d
@ -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",
|
||||
),
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -232,7 +232,7 @@ func init() {
|
||||
"RESUME": {
|
||||
handler: resumeHandler,
|
||||
usablePreReg: true,
|
||||
minParams: 1,
|
||||
minParams: 2,
|
||||
},
|
||||
"SAJOIN": {
|
||||
handler: sajoinHandler,
|
||||
|
@ -2359,27 +2359,24 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
||||
return false
|
||||
}
|
||||
|
||||
// RESUME <token> [timestamp]
|
||||
// RESUME <token> <timestamp>
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user