Changeset 499 in code for trunk/downstream.go


Ignore:
Timestamp:
Apr 13, 2021, 5:11:05 PM (4 years ago)
Author:
contact
Message:

Relay detached channel backlog as BouncerServ NOTICE if necessary

Instead of ignoring detached channels wehn replaying backlog,
process them as usual and relay messages as BouncerServ NOTICEs
if necessary. Advance the delivery receipts as if the channel was
attached.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r496 r499  
    10311031                return
    10321032        }
    1033         if ch := net.channels.Value(target); ch != nil && ch.Detached {
    1034                 return
    1035         }
     1033
     1034        ch := net.channels.Value(target)
    10361035
    10371036        limit := 4000
     
    10571056                }
    10581057
    1059                 if dc.caps["batch"] {
    1060                         msg.Tags["batch"] = irc.TagValue(batchRef)
    1061                 }
    1062                 dc.SendMessage(dc.marshalMessage(msg, net))
     1058                if ch != nil && ch.Detached {
     1059                        if net.detachedMessageNeedsRelay(ch, msg) {
     1060                                dc.relayDetachedMessage(net, msg)
     1061                        }
     1062                } else {
     1063                        if dc.caps["batch"] {
     1064                                msg.Tags["batch"] = irc.TagValue(batchRef)
     1065                        }
     1066                        dc.SendMessage(dc.marshalMessage(msg, net))
     1067                }
    10631068        }
    10641069
     
    10691074                        Params:  []string{"-" + batchRef},
    10701075                })
     1076        }
     1077}
     1078
     1079func (dc *downstreamConn) relayDetachedMessage(net *network, msg *irc.Message) {
     1080        if msg.Command != "PRIVMSG" && msg.Command != "NOTICE" {
     1081                return
     1082        }
     1083
     1084        sender := msg.Prefix.Name
     1085        target, text := msg.Params[0], msg.Params[1]
     1086        if net.isHighlight(msg) {
     1087                sendServiceNOTICE(dc, fmt.Sprintf("highlight in %v: <%v> %v", dc.marshalEntity(net, target), sender, text))
     1088        } else {
     1089                sendServiceNOTICE(dc, fmt.Sprintf("message in %v: <%v> %v", dc.marshalEntity(net, target), sender, text))
    10711090        }
    10721091}
Note: See TracChangeset for help on using the changeset viewer.