summaryrefslogtreecommitdiff
path: root/internal/db/bundb/relationship_follow.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-04-10 21:56:02 +0200
committerLibravatar GitHub <noreply@github.com>2023-04-10 20:56:02 +0100
commit093cf2ab12a1f6bfa9629917101afffd2aeb8376 (patch)
treec0897a610b884cdf8e9b9d88b01c1e062a45f1a3 /internal/db/bundb/relationship_follow.go
parent[chore]: Bump golang.org/x/oauth2 from 0.6.0 to 0.7.0 (#1684) (diff)
downloadgotosocial-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/relationship_follow.go')
-rw-r--r--internal/db/bundb/relationship_follow.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/db/bundb/relationship_follow.go b/internal/db/bundb/relationship_follow.go
index 4a315d116..1b1de77b1 100644
--- a/internal/db/bundb/relationship_follow.go
+++ b/internal/db/bundb/relationship_follow.go
@@ -21,6 +21,7 @@ import (
"context"
"errors"
"fmt"
+ "time"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtscontext"
@@ -189,6 +190,26 @@ func (r *relationshipDB) PutFollow(ctx context.Context, follow *gtsmodel.Follow)
return nil
}
+func (r *relationshipDB) UpdateFollow(ctx context.Context, follow *gtsmodel.Follow, columns ...string) error {
+ follow.UpdatedAt = time.Now()
+ if len(columns) > 0 {
+ // If we're updating by column, ensure "updated_at" is included.
+ columns = append(columns, "updated_at")
+ }
+
+ return r.state.Caches.GTS.Follow().Store(follow, func() error {
+ if _, err := r.conn.NewUpdate().
+ Model(follow).
+ Where("? = ?", bun.Ident("follow.id"), follow.ID).
+ Column(columns...).
+ Exec(ctx); err != nil {
+ return r.conn.ProcessError(err)
+ }
+
+ return nil
+ })
+}
+
func (r *relationshipDB) DeleteFollowByID(ctx context.Context, id string) error {
if _, err := r.conn.NewDelete().
Table("follows").