summaryrefslogtreecommitdiff
path: root/internal/db/bundb
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-02-20 18:50:54 +0100
committerLibravatar GitHub <noreply@github.com>2024-02-20 17:50:54 +0000
commit8cafa6b74b81fd8f0e5730007acdabd4c4e98944 (patch)
treebdea20d2bf47ed76c95b3f98e735d87112cc1e95 /internal/db/bundb
parent[bugfix] use start + end line in regex when validating emoji via API (#2671) (diff)
downloadgotosocial-8cafa6b74b81fd8f0e5730007acdabd4c4e98944.tar.xz
[feature] Add `requested_by` to relationship model (#2672)
* [feature] Add `requested_by` to relationship model * whoops, missed some tests
Diffstat (limited to 'internal/db/bundb')
-rw-r--r--internal/db/bundb/relationship.go9
-rw-r--r--internal/db/bundb/relationship_test.go8
2 files changed, 17 insertions, 0 deletions
diff --git a/internal/db/bundb/relationship.go b/internal/db/bundb/relationship.go
index 71ae37545..a97aa71ff 100644
--- a/internal/db/bundb/relationship.go
+++ b/internal/db/bundb/relationship.go
@@ -74,6 +74,15 @@ func (r *relationshipDB) GetRelationship(ctx context.Context, requestingAccount
return nil, gtserror.Newf("error checking requested: %w", err)
}
+ // check if target has follow requested requesting
+ rel.RequestedBy, err = r.IsFollowRequested(ctx,
+ targetAccount,
+ requestingAccount,
+ )
+ if err != nil {
+ return nil, gtserror.Newf("error checking requestedBy: %w", err)
+ }
+
// check if the requesting account is blocking the target account
rel.Blocking, err = r.IsBlocked(ctx, requestingAccount, targetAccount)
if err != nil {
diff --git a/internal/db/bundb/relationship_test.go b/internal/db/bundb/relationship_test.go
index aa2353961..9858e4768 100644
--- a/internal/db/bundb/relationship_test.go
+++ b/internal/db/bundb/relationship_test.go
@@ -596,6 +596,14 @@ func (suite *RelationshipTestSuite) TestAcceptFollowRequestOK() {
suite.False(relationship.Following)
suite.True(relationship.Requested)
+ // Check the other way around too; local_account_2
+ // should have requested_by true for admin now.
+ inverse, err := suite.db.GetRelationship(ctx, targetAccount.ID, account.ID)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+ suite.True(inverse.RequestedBy)
+
followRequestNotification := &gtsmodel.Notification{
ID: "01GV8MY1Q9KX2ZSWN4FAQ3V1PB",
OriginAccountID: account.ID,