mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-07 10:18:08 -06:00
[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
This commit is contained in:
parent
c01d2f9b44
commit
093cf2ab12
17 changed files with 788 additions and 448 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtscontext"
|
||||
|
|
@ -167,6 +168,26 @@ func (r *relationshipDB) PutFollowRequest(ctx context.Context, follow *gtsmodel.
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *relationshipDB) UpdateFollowRequest(ctx context.Context, followRequest *gtsmodel.FollowRequest, columns ...string) error {
|
||||
followRequest.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.FollowRequest().Store(followRequest, func() error {
|
||||
if _, err := r.conn.NewUpdate().
|
||||
Model(followRequest).
|
||||
Where("? = ?", bun.Ident("follow_request.id"), followRequest.ID).
|
||||
Column(columns...).
|
||||
Exec(ctx); err != nil {
|
||||
return r.conn.ProcessError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (r *relationshipDB) AcceptFollowRequest(ctx context.Context, sourceAccountID string, targetAccountID string) (*gtsmodel.Follow, db.Error) {
|
||||
// Get original follow request.
|
||||
followReq, err := r.GetFollowRequest(ctx, sourceAccountID, targetAccountID)
|
||||
|
|
@ -183,6 +204,8 @@ func (r *relationshipDB) AcceptFollowRequest(ctx context.Context, sourceAccountI
|
|||
TargetAccountID: targetAccountID,
|
||||
TargetAccount: followReq.TargetAccount,
|
||||
URI: followReq.URI,
|
||||
ShowReblogs: followReq.ShowReblogs,
|
||||
Notify: followReq.Notify,
|
||||
}
|
||||
|
||||
// If the follow already exists, just
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue