Updated prefs update route
This commit is contained in:
parent
14dfcc93a5
commit
3cc2101ada
|
@ -862,6 +862,10 @@ App::patch('/v1/account/prefs')
|
|||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
|
||||
$user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [
|
||||
'prefs' => $prefs,
|
||||
]));
|
||||
|
||||
if (false === $user) {
|
||||
throw new Exception('Failed saving user to DB', 500);
|
||||
|
|
|
@ -9,7 +9,55 @@ class File extends Model
|
|||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this
|
||||
->addRule('$id', [
|
||||
'type' => 'string',
|
||||
'description' => 'User ID.',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => 'string',
|
||||
'description' => 'User name.',
|
||||
'default' => '',
|
||||
'example' => 'John Doe',
|
||||
])
|
||||
->addRule('registration', [
|
||||
'type' => 'integer',
|
||||
'description' => 'User registration date in Unix timestamp.',
|
||||
'example' => 1592981250,
|
||||
])
|
||||
->addRule('status', [
|
||||
'type' => 'integer',
|
||||
'description' => 'User status. 0 for Unavtivated, 1 for active and 2 is blocked.',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
])
|
||||
->addRule('email', [
|
||||
'type' => 'string',
|
||||
'description' => 'User email address.',
|
||||
'default' => '',
|
||||
'example' => 'john@appwrite.io',
|
||||
])
|
||||
->addRule('emailVerification', [
|
||||
'type' => 'boolean',
|
||||
'description' => 'Email verification status.',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
])
|
||||
->addRule('prefs', [
|
||||
'type' => 'json',
|
||||
'description' => 'User preferences as a key-value object',
|
||||
'default' => new \stdClass,
|
||||
'example' => ['theme' => 'pink', 'timezone' => 'UTC'],
|
||||
])
|
||||
->addRule('roles', [
|
||||
'type' => 'string',
|
||||
'description' => 'User list of roles',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,6 +77,6 @@ class File extends Model
|
|||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_LOCALE;
|
||||
return Response::MODEL_FILE;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue