mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-08 05:34:27 +02:00
allow inserting username with UserDeletedRepository
This commit is contained in:
parent
23d052c7fe
commit
00b4bd19d8
2 changed files with 52 additions and 0 deletions
|
@ -9,8 +9,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Database\Repository;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DatabaseException;
|
||||
|
||||
/**
|
||||
* Repository for deleted users
|
||||
*/
|
||||
final class UserDeletedRepository
|
||||
{
|
||||
private Database $database;
|
||||
|
@ -20,6 +25,25 @@ final class UserDeletedRepository
|
|||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a deleted user by username.
|
||||
*
|
||||
* @throws \Exception If the username could not be inserted
|
||||
*/
|
||||
public function insertByUsername(string $username): void
|
||||
{
|
||||
$result = $this->database->insert('userd', ['username' => $username]);
|
||||
|
||||
if ($result === false) {
|
||||
throw new Exception(sprintf('Error while inserting username `%s` as deleted user.', $username));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a deleted username exists.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function existsByUsername(string $username): bool
|
||||
{
|
||||
return $this->database->exists('userd', ['username' => $username]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue