Changeset 303 in code for trunk/downstream.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/downstream.go

    r301 r303  
    251251func (dc *downstreamConn) SendMessage(msg *irc.Message) {
    252252        if !dc.caps["message-tags"] {
     253                if msg.Command == "TAGMSG" {
     254                        return
     255                }
    253256                msg = msg.Copy()
    254257                for name := range msg.Tags {
     
    275278
    276279        switch msg.Command {
    277         case "PRIVMSG", "NOTICE":
     280        case "PRIVMSG", "NOTICE", "TAGMSG":
    278281                msg.Params[0] = dc.marshalEntity(net, msg.Params[0])
    279282        case "NICK":
     
    13981401                        return err
    13991402                }
     1403                tags := copyClientTags(msg.Tags)
    14001404
    14011405                for _, name := range strings.Split(targetsStr, ",") {
     
    14191423                        }
    14201424                        uc.SendMessageLabeled(dc.id, &irc.Message{
     1425                                Tags:    tags,
    14211426                                Command: "PRIVMSG",
    14221427                                Params:  []string{upstreamName, unmarshaledText},
    14231428                        })
    14241429
     1430                        echoTags := tags.Copy()
     1431                        echoTags["time"] = irc.TagValue(time.Now().UTC().Format(serverTimeLayout))
    14251432                        echoMsg := &irc.Message{
    1426                                 Tags: irc.Tags{
    1427                                         "time": irc.TagValue(time.Now().UTC().Format(serverTimeLayout)),
    1428                                 },
     1433                                Tags: echoTags,
    14291434                                Prefix: &irc.Prefix{
    14301435                                        Name: uc.nick,
     
    14411446                        return err
    14421447                }
     1448                tags := copyClientTags(msg.Tags)
    14431449
    14441450                for _, name := range strings.Split(targetsStr, ",") {
     
    14531459                        }
    14541460                        uc.SendMessageLabeled(dc.id, &irc.Message{
     1461                                Tags:    tags,
    14551462                                Command: "NOTICE",
    14561463                                Params:  []string{upstreamName, unmarshaledText},
     1464                        })
     1465                }
     1466        case "TAGMSG":
     1467                var targetsStr string
     1468                if err := parseMessageParams(msg, &targetsStr); err != nil {
     1469                        return err
     1470                }
     1471                tags := copyClientTags(msg.Tags)
     1472
     1473                for _, name := range strings.Split(targetsStr, ",") {
     1474                        uc, upstreamName, err := dc.unmarshalEntity(name)
     1475                        if err != nil {
     1476                                return err
     1477                        }
     1478
     1479                        uc.SendMessageLabeled(dc.id, &irc.Message{
     1480                                Tags:    tags,
     1481                                Command: "TAGMSG",
     1482                                Params:  []string{upstreamName},
    14571483                        })
    14581484                }
Note: See TracChangeset for help on using the changeset viewer.