- Timestamp:
- Apr 13, 2021, 5:11:05 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r496 r499 1031 1031 return 1032 1032 } 1033 if ch := net.channels.Value(target); ch != nil && ch.Detached { 1034 return 1035 } 1033 1034 ch := net.channels.Value(target) 1036 1035 1037 1036 limit := 4000 … … 1057 1056 } 1058 1057 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 } 1063 1068 } 1064 1069 … … 1069 1074 Params: []string{"-" + batchRef}, 1070 1075 }) 1076 } 1077 } 1078 1079 func (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)) 1071 1090 } 1072 1091 } -
trunk/upstream.go
r498 r499 392 392 if ch != nil { 393 393 if ch.Detached { 394 uc.handleDetachedMessage( msg.Prefix.Name, text, ch)394 uc.handleDetachedMessage(ch, msg) 395 395 } 396 396 397 highlight := msg.Prefix.Name != uc.nick && isHighlight(text, uc.nick)397 highlight := uc.network.isHighlight(msg) 398 398 if ch.DetachOn == FilterMessage || ch.DetachOn == FilterDefault || (ch.DetachOn == FilterHighlight && highlight) { 399 399 uc.updateChannelAutoDetach(target) … … 1438 1438 } 1439 1439 1440 func (uc *upstreamConn) handleDetachedMessage(sender string, text string, ch *Channel) { 1441 highlight := sender != uc.nick && isHighlight(text, uc.nick) 1442 if ch.RelayDetached == FilterMessage || ((ch.RelayDetached == FilterHighlight || ch.RelayDetached == FilterDefault) && highlight) { 1440 func (uc *upstreamConn) handleDetachedMessage(ch *Channel, msg *irc.Message) { 1441 if uc.network.detachedMessageNeedsRelay(ch, msg) { 1443 1442 uc.forEachDownstream(func(dc *downstreamConn) { 1444 if highlight { 1445 sendServiceNOTICE(dc, fmt.Sprintf("highlight in %v: <%v> %v", dc.marshalEntity(uc.network, ch.Name), sender, text)) 1446 } else { 1447 sendServiceNOTICE(dc, fmt.Sprintf("message in %v: <%v> %v", dc.marshalEntity(uc.network, ch.Name), sender, text)) 1448 } 1449 }) 1450 } 1451 if ch.ReattachOn == FilterMessage || (ch.ReattachOn == FilterHighlight && highlight) { 1443 dc.relayDetachedMessage(uc.network, msg) 1444 }) 1445 } 1446 if ch.ReattachOn == FilterMessage || (ch.ReattachOn == FilterHighlight && uc.network.isHighlight(msg)) { 1452 1447 uc.network.attach(ch) 1453 1448 if err := uc.srv.db.StoreChannel(uc.network.ID, ch); err != nil { … … 1744 1739 // Don't forward messages if it's a detached channel 1745 1740 ch := uc.network.channels.Value(target) 1746 if ch != nil && ch.Detached { 1747 return 1748 } 1741 detached := ch != nil && ch.Detached 1749 1742 1750 1743 uc.forEachDownstream(func(dc *downstreamConn) { 1751 if dc != origin || dc.caps["echo-message"]{1744 if !detached && (dc != origin || dc.caps["echo-message"]) { 1752 1745 dc.sendMessageWithID(dc.marshalMessage(msg, uc.network), msgID) 1753 1746 } else { -
trunk/user.go
r497 r499 352 352 } 353 353 354 func (net *network) isHighlight(msg *irc.Message) bool { 355 if msg.Command != "PRIVMSG" && msg.Command != "NOTICE" { 356 return false 357 } 358 359 text := msg.Params[1] 360 361 nick := net.Nick 362 if net.conn != nil { 363 nick = net.conn.nick 364 } 365 366 // TODO: use case-mapping aware comparison here 367 return msg.Prefix.Name != nick && isHighlight(text, nick) 368 } 369 370 func (net *network) detachedMessageNeedsRelay(ch *Channel, msg *irc.Message) bool { 371 highlight := net.isHighlight(msg) 372 return ch.RelayDetached == FilterMessage || ((ch.RelayDetached == FilterHighlight || ch.RelayDetached == FilterDefault) && highlight) 373 } 374 354 375 type user struct { 355 376 User
Note:
See TracChangeset
for help on using the changeset viewer.