diff options
author | 2022-10-08 14:00:39 +0200 | |
---|---|---|
committer | 2022-10-08 14:00:39 +0200 | |
commit | 80663061d8f361ae4bcea1307a10a40c41174ebe (patch) | |
tree | 999f9e8decfb3e6e211e8462415103819eddd1c2 /internal/db/bundb/account.go | |
parent | [chore] Standardize database queries, use `bun.Ident()` properly (#886) (diff) | |
download | gotosocial-80663061d8f361ae4bcea1307a10a40c41174ebe.tar.xz |
[feature] Add opt-in RSS feed for account's latest Public posts (#897)
* start adding rss functionality
* add gorilla/feeds dependency
* first bash at building rss feed
still needs work, this is an interim commit
* tidy up a bit
* add publicOnly option to GetAccountLastPosted
* implement rss endpoint
* fix test
* add initial user docs for rss
* update rss logo
* docs update
* add rssFeed to frontend
* feed -> feed.rss
* enableRSS
* increase rss logo size a lil bit
* add rss toggle
* move emojify to text package
* fiddle with rss feed formatting
* add Text field to test statuses
* move status to rss item to typeconverter
* update bun schema for enablerss
* simplify 304 checking
* assume account not rss
* update tests
* update swagger docs
* allow more characters in title, trim nicer
* update last posted to be more consistent
Diffstat (limited to 'internal/db/bundb/account.go')
-rw-r--r-- | internal/db/bundb/account.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/internal/db/bundb/account.go b/internal/db/bundb/account.go index c04948fee..4813f4e17 100644 --- a/internal/db/bundb/account.go +++ b/internal/db/bundb/account.go @@ -253,21 +253,29 @@ func (a *accountDB) GetInstanceAccount(ctx context.Context, domain string) (*gts return account, nil } -func (a *accountDB) GetAccountLastPosted(ctx context.Context, accountID string) (time.Time, db.Error) { - status := new(gtsmodel.Status) +func (a *accountDB) GetAccountLastPosted(ctx context.Context, accountID string, webOnly bool) (time.Time, db.Error) { + createdAt := time.Time{} q := a.conn. NewSelect(). - Model(status). + TableExpr("? AS ?", bun.Ident("statuses"), bun.Ident("status")). Column("status.created_at"). Where("? = ?", bun.Ident("status.account_id"), accountID). Order("status.id DESC"). Limit(1) - if err := q.Scan(ctx); err != nil { + if webOnly { + q = q. + WhereGroup(" AND ", whereEmptyOrNull("status.in_reply_to_uri")). + WhereGroup(" AND ", whereEmptyOrNull("status.boost_of_id")). + Where("? = ?", bun.Ident("status.visibility"), gtsmodel.VisibilityPublic). + Where("? = ?", bun.Ident("status.federated"), true) + } + + if err := q.Scan(ctx, &createdAt); err != nil { return time.Time{}, a.conn.ProcessError(err) } - return status.CreatedAt, nil + return createdAt, nil } func (a *accountDB) SetAccountHeaderOrAvatar(ctx context.Context, mediaAttachment *gtsmodel.MediaAttachment, accountID string) db.Error { |