diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 9f15632048..996e6acca1 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -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); diff --git a/src/Appwrite/Utopia/Response/Model/File.php b/src/Appwrite/Utopia/Response/Model/File.php index 875c6f4bd7..e483066a5f 100644 --- a/src/Appwrite/Utopia/Response/Model/File.php +++ b/src/Appwrite/Utopia/Response/Model/File.php @@ -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; } } \ No newline at end of file