Merge 1ca956ef7e
into 33587a2a37
This commit is contained in:
commit
9c588681ae
|
@ -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')
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue