~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] fix empty CHATHISTORY TARGETS

Details
Message ID
<20231011134227.151979-1-pounce@integraldoma.in>
DKIM signature
missing
Download raw message
Patch: +18 -6
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.
---
 msgstore/db.go | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/msgstore/db.go b/msgstore/db.go
index 18a428a..0e1ebdc 100644
--- a/msgstore/db.go
+++ b/msgstore/db.go
@@ -97,12 +97,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) {
	l, err := ms.db.ListMessageLastPerTarget(ctx, network.ID, &database.MessageOptions{
		AfterTime:  start,
		BeforeTime: end,
		Limit:      limit,
		Events:     events,
	})
	var opts  *database.MessageOptions
	if start.Before(end) {
		opts = &database.MessageOptions{
			AfterTime:  start,
			BeforeTime: end,
			Limit:      limit,
			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 {
		return nil, err
	}
-- 
2.42.0
Details
Message ID
<Ttoq4Ip7hX_JyLImhA0V_17xfHF9SWdpfQ57xmI7t3ID3yETDxMSKJe9i_1Ilt3GyTUAApYJvjUQTWCRlQ3MoERvSaF9Tiv1wypGRfFMrrE=@emersion.fr>
In-Reply-To
<20231011134227.151979-1-pounce@integraldoma.in> (view parent)
DKIM signature
missing
Download raw message
Good catch! Thanks a lot for debugging and fixing this! Pushed.
Reply to thread Export thread (mbox)