Don't require upstream to be connected for CHATHISTORY
Closes: https://todo.sr.ht/~emersion/soju/127
This commit is contained in:
parent
cd64a7ffda
commit
fba1fdb31e
@ -2106,11 +2106,11 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
uc, entity, err := dc.unmarshalEntity(target)
|
network, entity, err := dc.unmarshalEntityNetwork(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
entity = uc.network.casemap(entity)
|
entity = network.casemap(entity)
|
||||||
|
|
||||||
// TODO: support msgid criteria
|
// TODO: support msgid criteria
|
||||||
var bounds [2]time.Time
|
var bounds [2]time.Time
|
||||||
@ -2143,18 +2143,18 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
var history []*irc.Message
|
var history []*irc.Message
|
||||||
switch subcommand {
|
switch subcommand {
|
||||||
case "BEFORE":
|
case "BEFORE":
|
||||||
history, err = store.LoadBeforeTime(uc.network, entity, bounds[0], time.Time{}, limit)
|
history, err = store.LoadBeforeTime(network, entity, bounds[0], time.Time{}, limit)
|
||||||
case "AFTER":
|
case "AFTER":
|
||||||
history, err = store.LoadAfterTime(uc.network, entity, bounds[0], time.Now(), limit)
|
history, err = store.LoadAfterTime(network, entity, bounds[0], time.Now(), limit)
|
||||||
case "BETWEEN":
|
case "BETWEEN":
|
||||||
if bounds[0].Before(bounds[1]) {
|
if bounds[0].Before(bounds[1]) {
|
||||||
history, err = store.LoadAfterTime(uc.network, entity, bounds[0], bounds[1], limit)
|
history, err = store.LoadAfterTime(network, entity, bounds[0], bounds[1], limit)
|
||||||
} else {
|
} else {
|
||||||
history, err = store.LoadBeforeTime(uc.network, entity, bounds[0], bounds[1], limit)
|
history, err = store.LoadBeforeTime(network, entity, bounds[0], bounds[1], limit)
|
||||||
}
|
}
|
||||||
case "TARGETS":
|
case "TARGETS":
|
||||||
// TODO: support TARGETS in multi-upstream mode
|
// TODO: support TARGETS in multi-upstream mode
|
||||||
targets, err := store.ListTargets(uc.network, bounds[0], bounds[1], limit)
|
targets, err := store.ListTargets(network, bounds[0], bounds[1], limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dc.logger.Printf("failed fetching targets for chathistory: %v", target, err)
|
dc.logger.Printf("failed fetching targets for chathistory: %v", target, err)
|
||||||
return ircError{&irc.Message{
|
return ircError{&irc.Message{
|
||||||
@ -2165,7 +2165,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
|
|
||||||
dc.SendBatch("draft/chathistory-targets", nil, nil, func(batchRef irc.TagValue) {
|
dc.SendBatch("draft/chathistory-targets", nil, nil, func(batchRef irc.TagValue) {
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
if ch := uc.network.channels.Value(target.Name); ch != nil && ch.Detached {
|
if ch := network.channels.Value(target.Name); ch != nil && ch.Detached {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2188,7 +2188,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
dc.SendBatch("chathistory", []string{target}, nil, func(batchRef irc.TagValue) {
|
dc.SendBatch("chathistory", []string{target}, nil, func(batchRef irc.TagValue) {
|
||||||
for _, msg := range history {
|
for _, msg := range history {
|
||||||
msg.Tags["batch"] = batchRef
|
msg.Tags["batch"] = batchRef
|
||||||
dc.SendMessage(dc.marshalMessage(msg, uc.network))
|
dc.SendMessage(dc.marshalMessage(msg, network))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
case "BOUNCER":
|
case "BOUNCER":
|
||||||
|
Loading…
Reference in New Issue
Block a user