Implemented account deletion. Not all cases covered with tests [skip ci]

This commit is contained in:
ErickSkrauch
2020-06-12 00:27:02 +03:00
parent c86817a93d
commit 0183e54442
56 changed files with 1041 additions and 188 deletions

View File

@@ -32,7 +32,7 @@ class ApiController extends Controller {
// who used the nickname has not changed it to something else
$account = null;
if ($record !== null) {
if ($record->account->username === $record->username || $record->findNext($at) !== null) {
if ($record->account->username === $record->username || $record->findNextOwnerUsername($at) !== null) {
$account = $record->account;
}
}
@@ -41,7 +41,7 @@ class ApiController extends Controller {
$account = Account::findOne(['username' => $username]);
}
if ($account === null) {
if ($account === null || $account->status === Account::STATUS_DELETED) {
return $this->noContentResponse();
}
@@ -58,7 +58,7 @@ class ApiController extends Controller {
return $this->illegalArgumentResponse('Invalid uuid format.');
}
$account = Account::findOne(['uuid' => $uuid]);
$account = Account::find()->excludeDeleted()->andWhere(['uuid' => $uuid])->one();
if ($account === null) {
return $this->noContentResponse();
}
@@ -103,6 +103,7 @@ class ApiController extends Controller {
/** @var Account[] $accounts */
$accounts = Account::find()
->andWhere(['username' => $usernames])
->excludeDeleted()
->orderBy(['username' => $usernames])
->limit(count($usernames))
->all();