Fix downstream NICK on upstreams supporting MONITOR v1 SUPERSEDED

Ember Sawady: 1
 Fix downstream NICK on upstreams supporting MONITOR

 1 files changed, 4 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/34838/mbox | git am -3
Learn more about email & git

[PATCH] Fix downstream NICK on upstreams supporting MONITOR Export this patch

Previously, uc.network.Network.Nick wasn't successfully updated on
downstream NICK. This would cause soju to immediately switch back to the
old nick when the upstream supported MONITOR, so long as the network had
a nick configured as of initialization.
There's also a similar issue with SANICK, since upstream NICK doesn't
update the database either, but I'm not sure what the desired behavior
is there. Thoughts?
 downstream.go | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/downstream.go b/downstream.go
index f9d1d38..3d33298 100644
--- a/downstream.go
+++ b/downstream.go
@@ -1821,9 +1821,10 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.

		var err error
		if dc.network != nil {
			record := dc.network.Network
			record.Nick = nick
			err = dc.srv.db.StoreNetwork(ctx, dc.user.ID, &record)
			// Need to make sure that network.Network.Nick is updated
			dc.network.Network.Nick = nick
			err = dc.srv.db.StoreNetwork(ctx, dc.user.ID,
		} else {
			record := dc.user.User
			record.Nick = nick
Ah, good catch!

One small nit: the code was written this way to properly handle DB errors.
IOW, we shouldn't update dc.network.Network.Nick if the DB fails the update.

Maybe instead  of this patch we can keep the current logic and set
dc.network.Network.Nick if err == nill?