fix empty CHATHISTORY TARGETS
Currently, if times sent to `CHATHISTORY TARGETS` are reversed (e.g. current time occurs first, and initial time occurs second) then no targets will be returned from the database backend. Changes have been tested with the sqlite backend.
This commit is contained in:
parent
b49552ed5b
commit
072e15d1e8
@ -89,12 +89,24 @@ func (ms *dbMessageStore) Append(network *database.Network, entity string, msg *
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ms *dbMessageStore) ListTargets(ctx context.Context, network *database.Network, start, end time.Time, limit int, events bool) ([]ChatHistoryTarget, error) {
|
func (ms *dbMessageStore) ListTargets(ctx context.Context, network *database.Network, start, end time.Time, limit int, events bool) ([]ChatHistoryTarget, error) {
|
||||||
l, err := ms.db.ListMessageLastPerTarget(ctx, network.ID, &database.MessageOptions{
|
var opts *database.MessageOptions
|
||||||
|
if start.Before(end) {
|
||||||
|
opts = &database.MessageOptions{
|
||||||
AfterTime: start,
|
AfterTime: start,
|
||||||
BeforeTime: end,
|
BeforeTime: end,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
Events: events,
|
Events: events,
|
||||||
})
|
}
|
||||||
|
} else {
|
||||||
|
opts = &database.MessageOptions{
|
||||||
|
AfterTime: end,
|
||||||
|
BeforeTime: start,
|
||||||
|
Limit: limit,
|
||||||
|
Events: events,
|
||||||
|
TakeLast: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l, err := ms.db.ListMessageLastPerTarget(ctx, network.ID, opts);
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user