~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] Add chat-history/LATEST support

Details
Message ID
<20211118194127.29901-1-tomvig38@gmail.com>
DKIM signature
pass
Download raw message
Patch: +6 -4
This patch adds a bit more compliance to the chat-history IRCv3 specification.
The v2 is justified by the comments made at https://github.com/emersion/soju/pull/37.

---
 downstream.go | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/downstream.go b/downstream.go
index 23a99fa..f844aae 100644
--- a/downstream.go
+++ b/downstream.go
@@ -2261,7 +2261,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
		var target, limitStr string
		var boundsStr [2]string
		switch subcommand {
		case "AFTER", "BEFORE":
		case "AFTER", "BEFORE", "LATEST":
			if err := parseMessageParams(msg, nil, &target, &boundsStr[0], &limitStr); err != nil {
				return err
			}
@@ -2274,7 +2274,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
				return err
			}
		default:
			// TODO: support LATEST, AROUND
			// TODO: support AROUND
			return ircError{&irc.Message{
				Command: "FAIL",
				Params:  []string{"CHATHISTORY", "INVALID_PARAMS", subcommand, "Unknown command"},
@@ -2304,7 +2304,9 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
		// TODO: support msgid criteria
		var bounds [2]time.Time
		bounds[0] = parseChatHistoryBound(boundsStr[0])
		if bounds[0].IsZero() {
		if subcommand == "LATEST" && boundsStr[0] == "*" {
			bounds[0] = time.Now();
		} else if bounds[0].IsZero() {
			return ircError{&irc.Message{
				Command: "FAIL",
				Params:  []string{"CHATHISTORY", "INVALID_PARAMS", subcommand, boundsStr[0], "Invalid first bound"},
@@ -2333,7 +2335,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {

		var history []*irc.Message
		switch subcommand {
		case "BEFORE":
		case "BEFORE", "LATEST":
			history, err = store.LoadBeforeTime(ctx, &network.Network, entity, bounds[0], time.Time{}, limit, eventPlayback)
		case "AFTER":
			history, err = store.LoadAfterTime(ctx, &network.Network, entity, bounds[0], time.Now(), limit, eventPlayback)
-- 
2.34.0
Details
Message ID
<Bik0nqtabCzDo3o3sFvKOhpggmOMSaNBVVOhfDB1PoP9ptkGoi2hrMx7520A4Gjp-qfaBVOd3ZrcShCUk3Q2quaowRPcdfj3WF9nob0Y-MI=@emersion.fr>
In-Reply-To
<20211118194127.29901-1-tomvig38@gmail.com> (view parent)
DKIM signature
pass
Download raw message
LGTM and pushed, thanks for the patch!
Reply to thread Export thread (mbox)