~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] Forward user mode changes in single-upstream mode

Details
Message ID
<20210609195827.32018-1-greg@gpanders.com>
DKIM signature
pass
Download raw message
Patch: +34 -5
---
 downstream.go | 16 ++++++++++++++--
 upstream.go   | 23 ++++++++++++++++++++---
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/downstream.go b/downstream.go
index 8e94095..5ee99ec 100644
--- a/downstream.go
+++ b/downstream.go
@@ -1182,6 +1182,14 @@ func (dc *downstreamConn) welcome() error {
		}
	})

	if uc := dc.upstream(); uc != nil {
		dc.SendMessage(&irc.Message{
			Prefix: dc.srv.prefix(),
			Command: irc.RPL_UMODEIS,
			Params: []string{dc.nick, string(uc.modes)},
		})
	}

	return nil
}

@@ -1601,11 +1609,15 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
					})
				})
			} else {
				// TODO: only do this in multi-upstream mode
				var userMode string
				if dc.upstream() != nil {
					userMode = string(dc.upstream().modes)
				}

				dc.SendMessage(&irc.Message{
					Prefix:  dc.srv.prefix(),
					Command: irc.RPL_UMODEIS,
					Params:  []string{dc.nick, ""}, // TODO
					Params:  []string{dc.nick, userMode},
				})
			}
			return nil
diff --git a/upstream.go b/upstream.go
index 1f42a24..67ccc28 100644
--- a/upstream.go
+++ b/upstream.go
@@ -932,8 +932,18 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
			if name != uc.nick {
				return fmt.Errorf("received MODE message for unknown nick %q", name)
			}
			return uc.modes.Apply(modeStr)
			// TODO: notify downstreams about user mode change?

			if err := uc.modes.Apply(modeStr); err != nil {
				return err
			}

			uc.forEachDownstream(func (dc *downstreamConn) {
				if dc.upstream() == nil {
					return
				}

				dc.SendMessage(msg)
			})
		} else { // channel mode change
			ch, err := uc.getChannel(name)
			if err != nil {
@@ -982,7 +992,14 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
		if err := uc.modes.Apply(modeStr); err != nil {
			return err
		}
		// TODO: send RPL_UMODEIS to downstream connections when applicable

		uc.forEachDownstream(func (dc *downstreamConn) {
			if dc.upstream() == nil {
				return
			}

			dc.SendMessage(msg)
		})
	case irc.RPL_CHANNELMODEIS:
		var channel string
		if err := parseMessageParams(msg, nil, &channel); err != nil {
-- 
2.32.0
Details
Message ID
<XYz5YOK9WxlCS4EeLWRTSNrX6FAo4u4RuIRL8pl6j0cCHudGYqGhCWPX6zlS28LF9ER87aMCvRiON5gEbyadtGSDCRKrLK6zUm6XJtdc9Fk=@emersion.fr>
In-Reply-To
<20210609195827.32018-1-greg@gpanders.com> (view parent)
DKIM signature
pass
Download raw message
Moved the RPL_UMODEIS message right before RPL_NOMOTD in
downstreamConn.welcome(), as instructed by the spec. Also ran go fmt.
With these changes, this LGTM.

Pushed, thanks!
Reply to thread Export thread (mbox)