diff options
author | 2023-04-10 21:56:02 +0200 | |
---|---|---|
committer | 2023-04-10 20:56:02 +0100 | |
commit | 093cf2ab12a1f6bfa9629917101afffd2aeb8376 (patch) | |
tree | c0897a610b884cdf8e9b9d88b01c1e062a45f1a3 /internal/db/bundb/notification.go | |
parent | [chore]: Bump golang.org/x/oauth2 from 0.6.0 to 0.7.0 (#1684) (diff) | |
download | gotosocial-093cf2ab12a1f6bfa9629917101afffd2aeb8376.tar.xz |
[feature] Receive notification when followed account posts (if desired) (#1680)
* start working on notifs for new posts
* tidy up a bit
* update swagger
* carry over show reblogs + notify from follow req
* test notify on status post
* update column slice
* dedupe update logic + add tests
* fix own boosts not being timelined
* avoid type check, passing unnecessary accounts
* remove unnecessary 'inReplyToID' check
* add a couple todo's for future db functions
Diffstat (limited to 'internal/db/bundb/notification.go')
-rw-r--r-- | internal/db/bundb/notification.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/db/bundb/notification.go b/internal/db/bundb/notification.go index f32aed092..1cc286f44 100644 --- a/internal/db/bundb/notification.go +++ b/internal/db/bundb/notification.go @@ -48,6 +48,31 @@ func (n *notificationDB) GetNotificationByID(ctx context.Context, id string) (*g }, id) } +func (n *notificationDB) GetNotification( + ctx context.Context, + notificationType gtsmodel.NotificationType, + targetAccountID string, + originAccountID string, + statusID string, +) (*gtsmodel.Notification, db.Error) { + return n.state.Caches.GTS.Notification().Load("NotificationType.TargetAccountID.OriginAccountID.StatusID", func() (*gtsmodel.Notification, error) { + var notif gtsmodel.Notification + + q := n.conn.NewSelect(). + Model(¬if). + Where("? = ?", bun.Ident("notification_type"), notificationType). + Where("? = ?", bun.Ident("target_account_id"), targetAccountID). + Where("? = ?", bun.Ident("origin_account_id"), originAccountID). + Where("? = ?", bun.Ident("status_id"), statusID) + + if err := q.Scan(ctx); err != nil { + return nil, n.conn.ProcessError(err) + } + + return ¬if, nil + }, notificationType, targetAccountID, originAccountID, statusID) +} + func (n *notificationDB) GetAccountNotifications(ctx context.Context, accountID string, excludeTypes []string, limit int, maxID string, sinceID string) ([]*gtsmodel.Notification, db.Error) { // Ensure reasonable if limit < 0 { |