Changeset 405 in code for trunk/upstream.go


Ignore:
Timestamp:
Aug 20, 2020, 9:12:54 AM (5 years ago)
Author:
hubert
Message:

Forward RPL_TOPICWHOTIME to downstreams

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r403 r405  
    4343        conn         *upstreamConn
    4444        Topic        string
    45         TopicWho     string
     45        TopicWho     *irc.Prefix
    4646        TopicTime    time.Time
    4747        Status       channelStatus
     
    843843                }
    844844        case "TOPIC":
     845                if msg.Prefix == nil {
     846                        return fmt.Errorf("expected a prefix")
     847                }
     848
    845849                var name string
    846850                if err := parseMessageParams(msg, &name); err != nil {
     
    853857                if len(msg.Params) > 1 {
    854858                        ch.Topic = msg.Params[1]
     859                        ch.TopicWho = msg.Prefix.Copy()
     860                        ch.TopicTime = time.Now() // TODO use msg.Tags["time"]
    855861                } else {
    856862                        ch.Topic = ""
     
    984990                        return err
    985991                }
    986                 ch.TopicWho = who
     992                firstTopicWhoTime := ch.TopicWho == nil
     993                ch.TopicWho = irc.ParsePrefix(who)
    987994                sec, err := strconv.ParseInt(timeStr, 10, 64)
    988995                if err != nil {
     
    990997                }
    991998                ch.TopicTime = time.Unix(sec, 0)
     999                if firstTopicWhoTime {
     1000                        uc.forEachDownstream(func(dc *downstreamConn) {
     1001                                topicWho := dc.marshalUserPrefix(uc.network, ch.TopicWho)
     1002                                dc.SendMessage(&irc.Message{
     1003                                        Prefix:  dc.srv.prefix(),
     1004                                        Command: rpl_topicwhotime,
     1005                                        Params: []string{
     1006                                                dc.nick,
     1007                                                dc.marshalEntity(uc.network, ch.Name),
     1008                                                topicWho.String(),
     1009                                                timeStr,
     1010                                        },
     1011                                })
     1012                        })
     1013                }
    9921014        case irc.RPL_LIST:
    9931015                var channel, clients, topic string
Note: See TracChangeset for help on using the changeset viewer.