Changeset 405 in code for trunk


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

Forward RPL_TOPICWHOTIME to downstreams

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bridge.go

    r349 r405  
    22
    33import (
     4        "strconv"
     5        "strings"
     6
    47        "gopkg.in/irc.v3"
    5         "strings"
    68)
    79
     
    1214
    1315        sendTopic(dc, ch)
    14 
    15         // TODO: rpl_topicwhotime
    1616        sendNames(dc, ch)
    1717}
     
    2626                        Params:  []string{dc.nick, downstreamName, ch.Topic},
    2727                })
     28                if ch.TopicWho != nil {
     29                        topicWho := dc.marshalUserPrefix(ch.conn.network, ch.TopicWho)
     30                        topicTime := strconv.FormatInt(ch.TopicTime.Unix(), 10)
     31                        dc.SendMessage(&irc.Message{
     32                                Prefix:  dc.srv.prefix(),
     33                                Command: rpl_topicwhotime,
     34                                Params:  []string{dc.nick, downstreamName, topicWho.String(), topicTime},
     35                        })
     36                }
    2837        } else {
    2938                dc.SendMessage(&irc.Message{
  • 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.