summaryrefslogtreecommitdiff
path: root/internal/db/pg/pg.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/pg/pg.go')
-rw-r--r--internal/db/pg/pg.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/db/pg/pg.go b/internal/db/pg/pg.go
index 7f65055d6..9b6c7a114 100644
--- a/internal/db/pg/pg.go
+++ b/internal/db/pg/pg.go
@@ -1138,6 +1138,35 @@ func (ps *postgresService) GetHomeTimelineForAccount(accountID string, maxID str
return statuses, nil
}
+func (ps *postgresService) GetNotificationsForAccount(accountID string, limit int, maxID string) ([]*gtsmodel.Notification, error) {
+ notifications := []*gtsmodel.Notification{}
+
+ q := ps.conn.Model(&notifications).Where("target_account_id = ?", accountID)
+
+
+ if maxID != "" {
+ n := &gtsmodel.Notification{}
+ if err := ps.conn.Model(n).Where("id = ?", maxID).Select(); err != nil {
+ return nil, err
+ }
+ q = q.Where("created_at < ?", n.CreatedAt)
+ }
+
+ if limit != 0 {
+ q = q.Limit(limit)
+ }
+
+ q = q.Order("created_at DESC")
+
+ if err := q.Select(); err != nil {
+ if err != pg.ErrNoRows {
+ return nil, err
+ }
+
+ }
+ return notifications, nil
+}
+
/*
CONVERSION FUNCTIONS
*/