From a7e9dee33d038c55090b1e657fdf1008d3c4e227 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 10 Apr 2022 15:11:12 +0200 Subject: [bugfix] Fix broken only_media and only_public flags on /api/v1/accounts/:id/statuses (#448) * bump superseriousbusiness/activity version * fetch list of follower inbox iris * add test for getting account statuses * fix incorrect publicOnly parsing * update media not null query --- internal/db/bundb/account.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'internal/db') diff --git a/internal/db/bundb/account.go b/internal/db/bundb/account.go index 9fc588207..50b0bfa38 100644 --- a/internal/db/bundb/account.go +++ b/internal/db/bundb/account.go @@ -263,10 +263,16 @@ func (a *accountDB) GetAccountStatuses(ctx context.Context, accountID string, li } if mediaOnly { + // attachments are stored as a json object; + // this implementation differs between sqlite and postgres, + // so we have to be very thorough to cover all eventualities q = q.WhereGroup(" AND ", func(q *bun.SelectQuery) *bun.SelectQuery { return q. - WhereOr("? IS NOT NULL", bun.Ident("attachments")). - WhereOr("attachments != '{}'") + Where("? IS NOT NULL", bun.Ident("attachments")). + Where("? != ''", bun.Ident("attachments")). + Where("? != 'null'", bun.Ident("attachments")). + Where("? != '{}'", bun.Ident("attachments")). + Where("? != '[]'", bun.Ident("attachments")) }) } -- cgit v1.2.3