Changeset 301 in code for trunk/downstream.go


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

Send a label with all messages sent from downstream

This is preparatory work for forwarding errors of downstream-initiated
messages to their sender, as well as any other unknown message.

Preivously, we only sent labels (for labeled-response) for specific
downstream messages, such as WHO, where we knew the reply should only be
sent to that specific downstream.

However, in the case of an error of a message that is not labeled, the
error reply is not be tagged with a downstream id label and we can't
forward it to a specific downstream. It is not a good solution either to
forward this error to all downstreams.

This adds labels to all downstream-initiated messages (provided the
upstream supports it).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r299 r301  
    959959                                return
    960960                        }
    961                         uc.SendMessage(&irc.Message{
     961                        uc.SendMessageLabeled(dc.id, &irc.Message{
    962962                                Command: "NICK",
    963963                                Params:  []string{nick},
     
    999999                                params = append(params, key)
    10001000                        }
    1001                         uc.SendMessage(&irc.Message{
     1001                        uc.SendMessageLabeled(dc.id, &irc.Message{
    10021002                                Command: "JOIN",
    10031003                                Params:  params,
     
    10411041                                        params = append(params, reason)
    10421042                                }
    1043                                 uc.SendMessage(&irc.Message{
     1043                                uc.SendMessageLabeled(dc.id, &irc.Message{
    10441044                                        Command: "PART",
    10451045                                        Params:  params,
     
    11021102                                params = append(params, reason)
    11031103                        }
    1104                         uc.SendMessage(&irc.Message{
     1104                        uc.SendMessageLabeled(dc.id, &irc.Message{
    11051105                                Command: "KICK",
    11061106                                Params:  params,
     
    11211121                        if modeStr != "" {
    11221122                                dc.forEachUpstream(func(uc *upstreamConn) {
    1123                                         uc.SendMessage(&irc.Message{
     1123                                        uc.SendMessageLabeled(dc.id, &irc.Message{
    11241124                                                Command: "MODE",
    11251125                                                Params:  []string{uc.nick, modeStr},
     
    11511151                        params := []string{upstreamName, modeStr}
    11521152                        params = append(params, msg.Params[2:]...)
    1153                         uc.SendMessage(&irc.Message{
     1153                        uc.SendMessageLabeled(dc.id, &irc.Message{
    11541154                                Command: "MODE",
    11551155                                Params:  params,
     
    12001200                if len(msg.Params) > 1 { // setting topic
    12011201                        topic := msg.Params[1]
    1202                         uc.SendMessage(&irc.Message{
     1202                        uc.SendMessageLabeled(dc.id, &irc.Message{
    12031203                                Command: "TOPIC",
    12041204                                Params:  []string{upstreamChannel, topic},
     
    14181418                                unmarshaledText = dc.unmarshalText(uc, text)
    14191419                        }
    1420                         uc.SendMessage(&irc.Message{
     1420                        uc.SendMessageLabeled(dc.id, &irc.Message{
    14211421                                Command: "PRIVMSG",
    14221422                                Params:  []string{upstreamName, unmarshaledText},
     
    14521452                                unmarshaledText = dc.unmarshalText(uc, text)
    14531453                        }
    1454                         uc.SendMessage(&irc.Message{
     1454                        uc.SendMessageLabeled(dc.id, &irc.Message{
    14551455                                Command: "NOTICE",
    14561456                                Params:  []string{upstreamName, unmarshaledText},
Note: See TracChangeset for help on using the changeset viewer.