mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
implement draft/labeled-response-0.2
This commit is contained in:
parent
60d5586099
commit
34f11ddb97
@ -77,7 +77,7 @@ CAPDEFS = [
|
|||||||
),
|
),
|
||||||
CapDef(
|
CapDef(
|
||||||
identifier="LabeledResponse",
|
identifier="LabeledResponse",
|
||||||
name="draft/labeled-response",
|
name="draft/labeled-response-0.2",
|
||||||
url="https://ircv3.net/specs/extensions/labeled-response.html",
|
url="https://ircv3.net/specs/extensions/labeled-response.html",
|
||||||
standard="draft IRCv3",
|
standard="draft IRCv3",
|
||||||
),
|
),
|
||||||
|
@ -53,7 +53,7 @@ const (
|
|||||||
// https://ircv3.net/specs/extensions/invite-notify-3.2.html
|
// https://ircv3.net/specs/extensions/invite-notify-3.2.html
|
||||||
InviteNotify Capability = iota
|
InviteNotify Capability = iota
|
||||||
|
|
||||||
// LabeledResponse is the draft IRCv3 capability named "draft/labeled-response":
|
// LabeledResponse is the draft IRCv3 capability named "draft/labeled-response-0.2":
|
||||||
// https://ircv3.net/specs/extensions/labeled-response.html
|
// https://ircv3.net/specs/extensions/labeled-response.html
|
||||||
LabeledResponse Capability = iota
|
LabeledResponse Capability = iota
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ var (
|
|||||||
"echo-message",
|
"echo-message",
|
||||||
"extended-join",
|
"extended-join",
|
||||||
"invite-notify",
|
"invite-notify",
|
||||||
"draft/labeled-response",
|
"draft/labeled-response-0.2",
|
||||||
"draft/languages",
|
"draft/languages",
|
||||||
"oragono.io/maxline-2",
|
"oragono.io/maxline-2",
|
||||||
"message-tags",
|
"message-tags",
|
||||||
|
@ -212,16 +212,24 @@ func (rb *ResponseBuffer) flushInternal(final bool, blocking bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useLabel := rb.session.capabilities.Has(caps.LabeledResponse) && rb.Label != ""
|
useLabel := rb.session.capabilities.Has(caps.LabeledResponse) && rb.Label != ""
|
||||||
// use a batch if we have a label, and we either currently have 0 or 2+ messages,
|
// use a batch if we have a label, and we either currently have 2+ messages,
|
||||||
// or we are doing a Flush() and we have to assume that there will be more messages
|
// or we are doing a Flush() and we have to assume that there will be more messages
|
||||||
// in the future.
|
// in the future.
|
||||||
useBatch := useLabel && (len(rb.messages) != 1 || !final)
|
startBatch := useLabel && (1 < len(rb.messages) || !final)
|
||||||
|
|
||||||
// if label but no batch, add label to first message
|
if startBatch {
|
||||||
if useLabel && !useBatch && len(rb.messages) == 1 && rb.batchID == "" {
|
|
||||||
rb.messages[0].SetTag(caps.LabelTagName, rb.Label)
|
|
||||||
} else if useBatch {
|
|
||||||
rb.sendBatchStart(blocking)
|
rb.sendBatchStart(blocking)
|
||||||
|
} else if useLabel && len(rb.messages) == 0 && rb.batchID == "" && final {
|
||||||
|
// ACK message
|
||||||
|
message := ircmsg.MakeMessage(nil, rb.session.client.server.name, "ACK")
|
||||||
|
message.SetTag(caps.LabelTagName, rb.Label)
|
||||||
|
if rb.session.capabilities.Has(caps.ServerTime) {
|
||||||
|
message.SetTag("time", time.Now().UTC().Format(IRCv3TimestampFormat))
|
||||||
|
}
|
||||||
|
rb.session.SendRawMessage(message, blocking)
|
||||||
|
} else if useLabel && len(rb.messages) == 1 && rb.batchID == "" && final {
|
||||||
|
// single labeled message
|
||||||
|
rb.messages[0].SetTag(caps.LabelTagName, rb.Label)
|
||||||
}
|
}
|
||||||
|
|
||||||
// send each message out
|
// send each message out
|
||||||
|
Loading…
Reference in New Issue
Block a user