Block RPL_{CREATIONTIME,TOPICWHOTIME} for detached channels
Closes: https://todo.sr.ht/~emersion/soju/132
This commit is contained in:
parent
bad8154da8
commit
e397cc2a1f
21
upstream.go
21
upstream.go
@ -1155,9 +1155,9 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
if _, err := applyChannelModes(ch, modeStr, msg.Params[3:]); err != nil {
|
||||
return err
|
||||
}
|
||||
if firstMode {
|
||||
|
||||
c := uc.network.channels.Value(channel)
|
||||
if c == nil || !c.Detached {
|
||||
if firstMode && (c == nil || !c.Detached) {
|
||||
modeStr, modeParams := ch.modes.Format()
|
||||
|
||||
uc.forEachDownstream(func(dc *downstreamConn) {
|
||||
@ -1171,7 +1171,6 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
case rpl_creationtime:
|
||||
var channel, creationTime string
|
||||
if err := parseMessageParams(msg, nil, &channel, &creationTime); err != nil {
|
||||
@ -1185,7 +1184,9 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
|
||||
firstCreationTime := ch.creationTime == ""
|
||||
ch.creationTime = creationTime
|
||||
if firstCreationTime {
|
||||
|
||||
c := uc.network.channels.Value(channel)
|
||||
if firstCreationTime && (c == nil || !c.Detached) {
|
||||
uc.forEachDownstream(func(dc *downstreamConn) {
|
||||
dc.SendMessage(&irc.Message{
|
||||
Prefix: dc.srv.prefix(),
|
||||
@ -1195,14 +1196,16 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
})
|
||||
}
|
||||
case rpl_topicwhotime:
|
||||
var name, who, timeStr string
|
||||
if err := parseMessageParams(msg, nil, &name, &who, &timeStr); err != nil {
|
||||
var channel, who, timeStr string
|
||||
if err := parseMessageParams(msg, nil, &channel, &who, &timeStr); err != nil {
|
||||
return err
|
||||
}
|
||||
ch, err := uc.getChannel(name)
|
||||
|
||||
ch, err := uc.getChannel(channel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
firstTopicWhoTime := ch.TopicWho == nil
|
||||
ch.TopicWho = irc.ParsePrefix(who)
|
||||
sec, err := strconv.ParseInt(timeStr, 10, 64)
|
||||
@ -1210,7 +1213,9 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
|
||||
return fmt.Errorf("failed to parse topic time: %v", err)
|
||||
}
|
||||
ch.TopicTime = time.Unix(sec, 0)
|
||||
if firstTopicWhoTime {
|
||||
|
||||
c := uc.network.channels.Value(channel)
|
||||
if firstTopicWhoTime && (c == nil || !c.Detached) {
|
||||
uc.forEachDownstream(func(dc *downstreamConn) {
|
||||
topicWho := dc.marshalUserPrefix(uc.network, ch.TopicWho)
|
||||
dc.SendMessage(&irc.Message{
|
||||
|
Loading…
Reference in New Issue
Block a user