From 324d0fb0aca477bb8dc4c7f5060f47a8e512558e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 17 Oct 2021 21:53:18 +0200 Subject: [PATCH] Unify away-notify and account-notify handling --- downstream.go | 4 ++++ upstream.go | 17 +---------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/downstream.go b/downstream.go index 50e46f1..c37a599 100644 --- a/downstream.go +++ b/downstream.go @@ -410,6 +410,10 @@ func (dc *downstreamConn) SendMessage(msg *irc.Message) { if msg.Command == "SETNAME" && !dc.caps["setname"] { return } + if msg.Command == "AWAY" && !dc.caps["away-notify"] { + // TODO: we can send AWAY if we just sent a PRIVMSG/NOTICE to this user + return + } if msg.Command == "ACCOUNT" && !dc.caps["account-notify"] { return } diff --git a/upstream.go b/upstream.go index 4e835a8..903df8e 100644 --- a/upstream.go +++ b/upstream.go @@ -1371,22 +1371,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error { Params: []string{dc.nick, dc.marshalEntity(uc.network, nick), reason}, }) }) - case "AWAY": - if msg.Prefix == nil { - return fmt.Errorf("expected a prefix") - } - - uc.forEachDownstream(func(dc *downstreamConn) { - if !dc.caps["away-notify"] { - return - } - dc.SendMessage(&irc.Message{ - Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix), - Command: "AWAY", - Params: msg.Params, - }) - }) - case "ACCOUNT": + case "AWAY", "ACCOUNT": if msg.Prefix == nil { return fmt.Errorf("expected a prefix") }