summaryrefslogtreecommitdiff
path: root/internal/db/bundb/notification.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-08-17 17:26:21 +0100
committerLibravatar GitHub <noreply@github.com>2023-08-17 17:26:21 +0100
commitd5d6ad406f47ae738a7f6b1699b3b6e7ef916bb9 (patch)
tree44df2eaf48eca66023023569d4ba8d901d800226 /internal/db/bundb/notification.go
parent[chore]: Bump github.com/jackc/pgx/v5 from 5.4.2 to 5.4.3 (#2112) (diff)
downloadgotosocial-d5d6ad406f47ae738a7f6b1699b3b6e7ef916bb9.tar.xz
[bugfix] fix double firing bun.DB query hooks (#2124)
* improve bun.DB wrapping readability + comments, fix double-firing query hooks * fix incorrect code comment placement * fix linter issues * Update internal/db/basic.go * do as the linter commmands ... --------- Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: Daenney <daenney@users.noreply.github.com>
Diffstat (limited to 'internal/db/bundb/notification.go')
-rw-r--r--internal/db/bundb/notification.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/db/bundb/notification.go b/internal/db/bundb/notification.go
index b0757fb1e..423fd0be1 100644
--- a/internal/db/bundb/notification.go
+++ b/internal/db/bundb/notification.go
@@ -31,7 +31,7 @@ import (
)
type notificationDB struct {
- db *WrappedDB
+ db *DB
state *state.State
}
@@ -43,7 +43,7 @@ func (n *notificationDB) GetNotificationByID(ctx context.Context, id string) (*g
Model(&notif).
Where("? = ?", bun.Ident("notification.id"), id)
if err := q.Scan(ctx); err != nil {
- return nil, n.db.ProcessError(err)
+ return nil, err
}
return &notif, nil
@@ -68,7 +68,7 @@ func (n *notificationDB) GetNotification(
Where("? = ?", bun.Ident("status_id"), statusID)
if err := q.Scan(ctx); err != nil {
- return nil, n.db.ProcessError(err)
+ return nil, err
}
return &notif, nil
@@ -140,7 +140,7 @@ func (n *notificationDB) GetAccountNotifications(
}
if err := q.Scan(ctx, &notifIDs); err != nil {
- return nil, n.db.ProcessError(err)
+ return nil, err
}
if len(notifIDs) == 0 {
@@ -175,7 +175,7 @@ func (n *notificationDB) GetAccountNotifications(
func (n *notificationDB) PutNotification(ctx context.Context, notif *gtsmodel.Notification) error {
return n.state.Caches.GTS.Notification().Store(notif, func() error {
_, err := n.db.NewInsert().Model(notif).Exec(ctx)
- return n.db.ProcessError(err)
+ return err
})
}
@@ -199,7 +199,7 @@ func (n *notificationDB) DeleteNotificationByID(ctx context.Context, id string)
TableExpr("? AS ?", bun.Ident("notifications"), bun.Ident("notification")).
Where("? = ?", bun.Ident("notification.id"), id).
Exec(ctx)
- return n.db.ProcessError(err)
+ return err
}
func (n *notificationDB) DeleteNotifications(ctx context.Context, types []string, targetAccountID string, originAccountID string) error {
@@ -227,7 +227,7 @@ func (n *notificationDB) DeleteNotifications(ctx context.Context, types []string
}
if _, err := q.Exec(ctx, &notifIDs); err != nil {
- return n.db.ProcessError(err)
+ return err
}
defer func() {
@@ -252,7 +252,7 @@ func (n *notificationDB) DeleteNotifications(ctx context.Context, types []string
Table("notifications").
Where("? IN (?)", bun.Ident("id"), bun.In(notifIDs)).
Exec(ctx)
- return n.db.ProcessError(err)
+ return err
}
func (n *notificationDB) DeleteNotificationsForStatus(ctx context.Context, statusID string) error {
@@ -265,7 +265,7 @@ func (n *notificationDB) DeleteNotificationsForStatus(ctx context.Context, statu
Where("? = ?", bun.Ident("status_id"), statusID)
if _, err := q.Exec(ctx, &notifIDs); err != nil {
- return n.db.ProcessError(err)
+ return err
}
defer func() {
@@ -290,5 +290,5 @@ func (n *notificationDB) DeleteNotificationsForStatus(ctx context.Context, statu
Table("notifications").
Where("? IN (?)", bun.Ident("id"), bun.In(notifIDs)).
Exec(ctx)
- return n.db.ProcessError(err)
+ return err
}