Changeset 665 in code for trunk/downstream.go
- Timestamp:
- Nov 3, 2021, 2:17:16 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r664 r665 519 519 dc.SendMessage(msg) 520 520 521 if id == "" || !dc.messageSupports History(msg) {521 if id == "" || !dc.messageSupportsBacklog(msg) { 522 522 return 523 523 } … … 530 530 // isn't enabled. 531 531 func (dc *downstreamConn) advanceMessageWithID(msg *irc.Message, id string) { 532 if id == "" || !dc.messageSupports History(msg) {532 if id == "" || !dc.messageSupportsBacklog(msg) { 533 533 return 534 534 } … … 572 572 // marshalMessage re-formats a message coming from an upstream connection so 573 573 // that it's suitable for being sent on this downstream connection. Only 574 // messages that may appear in logs are supported, except MODE. 574 // messages that may appear in logs are supported, except MODE messages which 575 // may only appear in single-upstream mode. 575 576 func (dc *downstreamConn) marshalMessage(msg *irc.Message, net *network) *irc.Message { 577 if dc.network != nil { 578 return msg 579 } 580 576 581 msg = msg.Copy() 577 582 msg.Prefix = dc.marshalUserPrefix(net, msg.Prefix) … … 984 989 } 985 990 } 991 992 if dc.srv.LogPath != "" && dc.network != nil { 993 dc.setSupportedCap("draft/event-playback", "") 994 } else { 995 dc.unsetSupportedCap("draft/event-playback") 996 } 986 997 } 987 998 … … 1298 1309 } 1299 1310 1300 // messageSupports Historychecks whether the provided message can be sent as1311 // messageSupportsBacklog checks whether the provided message can be sent as 1301 1312 // part of an history batch. 1302 func (dc *downstreamConn) messageSupports History(msg *irc.Message) bool {1313 func (dc *downstreamConn) messageSupportsBacklog(msg *irc.Message) bool { 1303 1314 // Don't replay all messages, because that would mess up client 1304 1315 // state. For instance we just sent the list of users, sending 1305 1316 // PART messages for one of these users would be incorrect. 1306 // TODO: add support for draft/event-playback1307 1317 switch msg.Command { 1308 1318 case "PRIVMSG", "NOTICE": … … 1329 1339 dc.SendBatch("chathistory", []string{dc.marshalEntity(net, target)}, nil, func(batchRef irc.TagValue) { 1330 1340 for _, msg := range history { 1331 if !dc.messageSupportsHistory(msg) {1332 continue1333 }1334 1335 1341 if ch != nil && ch.Detached { 1336 1342 if net.detachedMessageNeedsRelay(ch, msg) { … … 2327 2333 } 2328 2334 2335 eventPlayback := dc.caps["draft/event-playback"] 2336 2329 2337 var history []*irc.Message 2330 2338 switch subcommand { 2331 2339 case "BEFORE": 2332 history, err = store.LoadBeforeTime(network, entity, bounds[0], time.Time{}, limit )2340 history, err = store.LoadBeforeTime(network, entity, bounds[0], time.Time{}, limit, eventPlayback) 2333 2341 case "AFTER": 2334 history, err = store.LoadAfterTime(network, entity, bounds[0], time.Now(), limit )2342 history, err = store.LoadAfterTime(network, entity, bounds[0], time.Now(), limit, eventPlayback) 2335 2343 case "BETWEEN": 2336 2344 if bounds[0].Before(bounds[1]) { 2337 history, err = store.LoadAfterTime(network, entity, bounds[0], bounds[1], limit )2345 history, err = store.LoadAfterTime(network, entity, bounds[0], bounds[1], limit, eventPlayback) 2338 2346 } else { 2339 history, err = store.LoadBeforeTime(network, entity, bounds[0], bounds[1], limit )2347 history, err = store.LoadBeforeTime(network, entity, bounds[0], bounds[1], limit, eventPlayback) 2340 2348 } 2341 2349 case "TARGETS": 2342 2350 // TODO: support TARGETS in multi-upstream mode 2343 targets, err := store.ListTargets(network, bounds[0], bounds[1], limit )2351 targets, err := store.ListTargets(network, bounds[0], bounds[1], limit, eventPlayback) 2344 2352 if err != nil { 2345 2353 dc.logger.Printf("failed fetching targets for chathistory: %v", err)
Note:
See TracChangeset
for help on using the changeset viewer.