1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

Merge pull request #2486 from appwrite/feat-prefs-improvement

Feat prefs improvement
This commit is contained in:
Torsten Dittmann 2022-01-04 17:01:07 +01:00 committed by GitHub
commit b2b4c61d32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 25 deletions

View file

@ -998,7 +998,7 @@ $collections = [
'$id' => 'prefs',
'type' => Database::VAR_STRING,
'format' => '',
'size' => 16384,
'size' => 65535,
'signed' => true,
'required' => false,
'default' => new \stdClass(),

46
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d32b727a743b3a8811ec64c56f308694",
"content-hash": "d0df4734e38f660ce979011d70155357",
"packages": [
{
"name": "adhocore/jwt",
@ -2255,11 +2255,17 @@
},
{
"name": "utopia-php/framework",
"version": "dev-fix-get-args-after-init",
"version": "0.19.5",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/framework",
"reference": "36a42dce039f043288673f0ff46284353543624d"
"url": "https://github.com/utopia-php/framework.git",
"reference": "1c28ba9a5b491cf7c90c535fefee5832c7133623"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/framework/zipball/1c28ba9a5b491cf7c90c535fefee5832c7133623",
"reference": "1c28ba9a5b491cf7c90c535fefee5832c7133623",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
@ -2274,6 +2280,7 @@
"Utopia\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
@ -2289,7 +2296,11 @@
"php",
"upf"
],
"time": "2022-01-03T08:38:34+00:00"
"support": {
"issues": "https://github.com/utopia-php/framework/issues",
"source": "https://github.com/utopia-php/framework/tree/0.19.5"
},
"time": "2022-01-04T14:40:23+00:00"
},
{
"name": "utopia-php/image",
@ -3069,16 +3080,16 @@
},
{
"name": "appwrite/sdk-generator",
"version": "0.16.3",
"version": "0.17.0",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "6185cdfe4c4261287240639f3a7fdc05e7ae2337"
"reference": "a68e072170a81532cfb0ff914864d8f074a73a37"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6185cdfe4c4261287240639f3a7fdc05e7ae2337",
"reference": "6185cdfe4c4261287240639f3a7fdc05e7ae2337",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/a68e072170a81532cfb0ff914864d8f074a73a37",
"reference": "a68e072170a81532cfb0ff914864d8f074a73a37",
"shasum": ""
},
"require": {
@ -3112,9 +3123,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.16.3"
"source": "https://github.com/appwrite/sdk-generator/tree/0.17.0"
},
"time": "2021-12-16T23:56:47+00:00"
"time": "2022-01-04T09:24:44+00:00"
},
{
"name": "composer/pcre",
@ -6628,18 +6639,9 @@
"time": "2015-12-17T08:42:14+00:00"
}
],
"aliases": [
{
"package": "utopia-php/framework",
"version": "dev-fix-get-args-after-init",
"alias": "0.19",
"alias_normalized": "0.19.0.0"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"utopia-php/framework": 20
},
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

View file

@ -1 +1 @@
Update currently logged in user account preferences. You can pass only the specific settings you wish to update.
Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.

View file

@ -1 +1 @@
Update the user preferences by its unique ID. You can pass only the specific settings you wish to update.
Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.

View file

@ -3,6 +3,7 @@
namespace Tests\E2E\Services\Account;
use Tests\E2E\Client;
use function array_merge;
trait AccountBase
{
@ -751,6 +752,36 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 400);
/**
* Prefs size exceeded
*/
$prefsObject = ["longValue" => str_repeat("🍰", 100000)];
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'prefs' => $prefsObject
]);
$this->assertEquals(400, $response['headers']['status-code']);
// Now let's test the same thing, but with normal symbol instead of multi-byte cake emoji
$prefsObject = ["longValue" => str_repeat("-", 100000)];
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'prefs' => $prefsObject
]);
$this->assertEquals(400, $response['headers']['status-code']);
return $data;
}