1
0
Fork 0
mirror of synced 2024-06-13 16:24:47 +12:00
This commit is contained in:
Nikhil anand 2024-05-16 14:00:35 +02:00 committed by GitHub
commit 9c588681ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 14 deletions

View file

@ -1396,9 +1396,9 @@ App::patch('/v1/users/:userId/prefs')
->label('sdk.description', '/docs/references/users/update-user-prefs.md')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_PREFERENCES)
->label('sdk.response.model', Response::MODEL_USER)
->param('userId', '', new UID(), 'User ID.')
->param('prefs', '', new Assoc(), 'Prefs key-value JSON object.')
->param('prefs', [], new Assoc(), 'Prefs key-value JSON object.')
->inject('response')
->inject('dbForProject')
->inject('queueForEvents')
@ -1410,12 +1410,13 @@ App::patch('/v1/users/:userId/prefs')
throw new Exception(Exception::USER_NOT_FOUND);
}
$user = $dbForProject->updateDocument('users', $user->getId(), $user->setAttribute('prefs', $prefs));
$user->setAttribute('prefs', $prefs);
$queueForEvents
->setParam('userId', $user->getId());
$user = $dbForProject->updateDocument('users', $user->getId(), $user);
$response->dynamic(new Document($prefs), Response::MODEL_PREFERENCES);
$queueForEvents->setParam('userId', $user->getId());
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/targets/:targetId')

View file

@ -899,7 +899,15 @@ trait Base
case self::$UPDATE_USER_PREFS:
return 'mutation updateUserPrefs($userId: String!, $prefs: Assoc!){
usersUpdatePrefs(userId: $userId, prefs: $prefs) {
data
_id
name
registration
status
email
emailVerification
prefs {
data
}
}
}';
case self::$UPDATE_USER_EMAIL_VERIFICATION:

View file

@ -427,7 +427,6 @@ class UsersTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($user['body']['data']);
$this->assertArrayNotHasKey('errors', $user['body']);
$this->assertIsArray($user['body']['data']['usersUpdatePhone']);
@ -452,11 +451,10 @@ class UsersTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$this->assertIsArray($user['body']['data']);
$this->assertArrayNotHasKey('errors', $user['body']);
$this->assertIsArray($user['body']['data']['usersUpdatePrefs']);
$this->assertEquals('{"key":"value"}', $user['body']['data']['usersUpdatePrefs']['data']);
$this->assertEquals(['data' => \json_encode(['key' => 'value'])], $user['body']['data']['usersUpdatePrefs']['prefs']);
}
/**

View file

@ -1091,8 +1091,8 @@ trait UsersBase
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['funcKey1'], 'funcValue1');
$this->assertEquals($user['body']['funcKey2'], 'funcValue2');
$this->assertEquals($user['body']['prefs']['funcKey1'], 'funcValue1');
$this->assertEquals($user['body']['prefs']['funcKey2'], 'funcValue2');
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',

View file

@ -275,7 +275,8 @@ class WebhooksCustomServerTest extends Scope
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['a'], 'b');
$this->assertIsArray($user['body']);
$this->assertEquals($user['body']['prefs']['a'], 'b');
$webhook = $this->getLastRequest();
$signatureExpected = self::getWebhookSignature($webhook, $this->getProject()['signatureKey']);
@ -293,7 +294,7 @@ class WebhooksCustomServerTest extends Scope
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']);
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']);
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertEquals($webhook['data']['a'], 'b');
$this->assertEquals($webhook['data']['prefs'], ['a' => 'b']);
return $data;
}