[feature] Add requested_by to relationship model (#2672)

* [feature] Add `requested_by` to relationship model

* whoops, missed some tests
This commit is contained in:
tobi 2024-02-20 18:50:54 +01:00 committed by GitHub
commit 8cafa6b74b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 121 additions and 2 deletions

View file

@ -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 {

View file

@ -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,