Changeset 759 in code for trunk


Ignore:
Timestamp:
Dec 9, 2021, 11:12:20 AM (3 years ago)
Author:
contact
Message:

Block RPL_{CREATIONTIME,TOPICWHOTIME} for detached channels

Closes: https://todo.sr.ht/~emersion/soju/132

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r757 r759  
    11561156                        return err
    11571157                }
    1158                 if firstMode {
    1159                         c := uc.network.channels.Value(channel)
    1160                         if c == nil || !c.Detached {
    1161                                 modeStr, modeParams := ch.modes.Format()
    1162 
    1163                                 uc.forEachDownstream(func(dc *downstreamConn) {
    1164                                         params := []string{dc.nick, dc.marshalEntity(uc.network, channel), modeStr}
    1165                                         params = append(params, modeParams...)
    1166 
    1167                                         dc.SendMessage(&irc.Message{
    1168                                                 Prefix:  dc.srv.prefix(),
    1169                                                 Command: irc.RPL_CHANNELMODEIS,
    1170                                                 Params:  params,
    1171                                         })
     1158
     1159                c := uc.network.channels.Value(channel)
     1160                if firstMode && (c == nil || !c.Detached) {
     1161                        modeStr, modeParams := ch.modes.Format()
     1162
     1163                        uc.forEachDownstream(func(dc *downstreamConn) {
     1164                                params := []string{dc.nick, dc.marshalEntity(uc.network, channel), modeStr}
     1165                                params = append(params, modeParams...)
     1166
     1167                                dc.SendMessage(&irc.Message{
     1168                                        Prefix:  dc.srv.prefix(),
     1169                                        Command: irc.RPL_CHANNELMODEIS,
     1170                                        Params:  params,
    11721171                                })
    1173                         }
     1172                        })
    11741173                }
    11751174        case rpl_creationtime:
     
    11861185                firstCreationTime := ch.creationTime == ""
    11871186                ch.creationTime = creationTime
    1188                 if firstCreationTime {
     1187
     1188                c := uc.network.channels.Value(channel)
     1189                if firstCreationTime && (c == nil || !c.Detached) {
    11891190                        uc.forEachDownstream(func(dc *downstreamConn) {
    11901191                                dc.SendMessage(&irc.Message{
     
    11961197                }
    11971198        case rpl_topicwhotime:
    1198                 var name, who, timeStr string
    1199                 if err := parseMessageParams(msg, nil, &name, &who, &timeStr); err != nil {
    1200                         return err
    1201                 }
    1202                 ch, err := uc.getChannel(name)
     1199                var channel, who, timeStr string
     1200                if err := parseMessageParams(msg, nil, &channel, &who, &timeStr); err != nil {
     1201                        return err
     1202                }
     1203
     1204                ch, err := uc.getChannel(channel)
    12031205                if err != nil {
    12041206                        return err
    12051207                }
     1208
    12061209                firstTopicWhoTime := ch.TopicWho == nil
    12071210                ch.TopicWho = irc.ParsePrefix(who)
     
    12111214                }
    12121215                ch.TopicTime = time.Unix(sec, 0)
    1213                 if firstTopicWhoTime {
     1216
     1217                c := uc.network.channels.Value(channel)
     1218                if firstTopicWhoTime && (c == nil || !c.Detached) {
    12141219                        uc.forEachDownstream(func(dc *downstreamConn) {
    12151220                                topicWho := dc.marshalUserPrefix(uc.network, ch.TopicWho)
Note: See TracChangeset for help on using the changeset viewer.