Changeset 303 in code for trunk/upstream.go


Ignore:
Timestamp:
May 27, 2020, 9:48:08 PM (5 years ago)
Author:
delthas
Message:

Add support for TAGMSG and client message tags

Previously we dropped all TAGMSG as well as any client message tag sent
from downstream.

This adds support for properly forwarding TAGMSG and client message tags
from downstreams and upstreams.

TAGMSG messages are intentionally not logged, because they are currently
typically used for +typing, which can generate a lot of traffic and is
only useful for a few seconds after it is sent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r302 r303  
    321321                })
    322322                return nil
    323         case "NOTICE", "PRIVMSG":
     323        case "NOTICE", "PRIVMSG", "TAGMSG":
    324324                if msg.Prefix == nil {
    325325                        return fmt.Errorf("expected a prefix")
     
    327327
    328328                var entity, text string
    329                 if err := parseMessageParams(msg, &entity, &text); err != nil {
    330                         return err
     329                if msg.Command != "TAGMSG" {
     330                        if err := parseMessageParams(msg, &entity, &text); err != nil {
     331                                return err
     332                        }
     333                } else {
     334                        if err := parseMessageParams(msg, &entity); err != nil {
     335                                return err
     336                        }
    331337                }
    332338
     
    342348                if msg.Prefix.User == "" && msg.Prefix.Host == "" { // server message
    343349                        uc.produce("", msg, nil)
    344                 } else { // regular user NOTICE or PRIVMSG
     350                } else { // regular user message
    345351                        target := entity
    346352                        if target == uc.nick {
     
    12751281                        })
    12761282                }
    1277         case "TAGMSG":
    1278                 // TODO: relay to downstream connections that accept message-tags
    12791283        case "ACK":
    12801284                // Ignore
     
    14881492}
    14891493
     1494func (uc *upstreamConn) SendMessage(msg *irc.Message) {
     1495        if !uc.caps["message-tags"] {
     1496                msg = msg.Copy()
     1497                msg.Tags = nil
     1498        }
     1499
     1500        uc.conn.SendMessage(msg)
     1501}
     1502
    14901503func (uc *upstreamConn) SendMessageLabeled(downstreamID uint64, msg *irc.Message) {
    14911504        if uc.caps["labeled-response"] {
Note: See TracChangeset for help on using the changeset viewer.