forked from forgejo/forgejo
[MODERATION] Add repo transfers to blocked functionality (squash)
- When someone gets blocked, remove all pending repository transfers from the blocked user to the doer. - Do not allow to start transferring repositories to the doer as blocked user. - Added unit testing. - Added integration testing. (cherry picked from commit8a3caac330
) (cherry picked from commita92b4cfeb6
) (cherry picked from commitacaaaf07d9
) (cherry picked from commit735818863c
) (cherry picked from commitf50fa43b32
) (cherry picked from commite166836433
) (cherry picked from commit82a0e4a381
)
This commit is contained in:
parent
32893dbab1
commit
ff233c19c4
11 changed files with 111 additions and 12 deletions
|
@ -83,7 +83,7 @@
|
|||
is_empty: false
|
||||
is_archived: false
|
||||
is_mirror: false
|
||||
status: 0
|
||||
status: 2
|
||||
is_fork: false
|
||||
fork_id: 0
|
||||
is_template: false
|
||||
|
|
|
@ -417,3 +417,13 @@ func TransferOwnership(ctx context.Context, doer *user_model.User, newOwnerName
|
|||
|
||||
return committer.Commit()
|
||||
}
|
||||
|
||||
// GetPendingTransfers returns the pending transfers of recipient which were sent by by doer.
|
||||
func GetPendingTransferIDs(ctx context.Context, reciepientID, doerID int64) ([]int64, error) {
|
||||
pendingTransferIDs := make([]int64, 0, 8)
|
||||
return pendingTransferIDs, db.GetEngine(ctx).Table("repo_transfer").
|
||||
Where("doer_id = ?", doerID).
|
||||
And("recipient_id = ?", reciepientID).
|
||||
Cols("id").
|
||||
Find(&pendingTransferIDs)
|
||||
}
|
||||
|
|
|
@ -55,3 +55,16 @@ func TestRepositoryTransfer(t *testing.T) {
|
|||
// Cancel transfer
|
||||
assert.NoError(t, CancelRepositoryTransfer(db.DefaultContext, repo))
|
||||
}
|
||||
|
||||
func TestGetPendingTransferIDs(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
|
||||
reciepient := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
pendingTransfer := unittest.AssertExistsAndLoadBean(t, &RepoTransfer{RecipientID: reciepient.ID, DoerID: doer.ID})
|
||||
|
||||
pendingTransferIDs, err := GetPendingTransferIDs(db.DefaultContext, reciepient.ID, doer.ID)
|
||||
assert.NoError(t, err)
|
||||
if assert.Len(t, pendingTransferIDs, 1) {
|
||||
assert.EqualValues(t, pendingTransfer.ID, pendingTransferIDs[0])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue