mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Merge pull request #8833 from appwrite/fix-target-deletes
Fix target deletes
This commit is contained in:
commit
f6cfc80a1d
7 changed files with 68 additions and 14 deletions
|
|
@ -4315,7 +4315,7 @@ App::post('/v1/account/targets/push')
|
|||
|
||||
$device = $detector->getDevice();
|
||||
|
||||
$sessionId = Auth::sessionVerify($user->getAttribute('sessions'), Auth::$secret);
|
||||
$sessionId = Auth::sessionVerify($user->getAttribute('sessions', []), Auth::$secret);
|
||||
$session = $dbForProject->getDocument('sessions', $sessionId);
|
||||
|
||||
try {
|
||||
|
|
@ -4384,7 +4384,9 @@ App::put('/v1/account/targets/:targetId/push')
|
|||
}
|
||||
|
||||
if ($identifier) {
|
||||
$target->setAttribute('identifier', $identifier);
|
||||
$target
|
||||
->setAttribute('identifier', $identifier)
|
||||
->setAttribute('expired', false);
|
||||
}
|
||||
|
||||
$detector = new Detector($request->getUserAgent());
|
||||
|
|
|
|||
|
|
@ -1503,7 +1503,9 @@ App::patch('/v1/users/:userId/targets/:targetId')
|
|||
throw new Exception(Exception::PROVIDER_INCORRECT_TYPE);
|
||||
}
|
||||
|
||||
$target->setAttribute('identifier', $identifier);
|
||||
$target
|
||||
->setAttribute('identifier', $identifier)
|
||||
->setAttribute('expired', false);
|
||||
}
|
||||
|
||||
if ($providerId) {
|
||||
|
|
@ -1517,8 +1519,9 @@ App::patch('/v1/users/:userId/targets/:targetId')
|
|||
throw new Exception(Exception::PROVIDER_INCORRECT_TYPE);
|
||||
}
|
||||
|
||||
$target->setAttribute('providerId', $provider->getId());
|
||||
$target->setAttribute('providerInternalId', $provider->getInternalId());
|
||||
$target
|
||||
->setAttribute('providerId', $provider->getId())
|
||||
->setAttribute('providerInternalId', $provider->getInternalId());
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
|
|
|
|||
12
composer.lock
generated
12
composer.lock
generated
|
|
@ -2124,16 +2124,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/messaging",
|
||||
"version": "0.12.1",
|
||||
"version": "0.12.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/messaging.git",
|
||||
"reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b"
|
||||
"reference": "f6790fba1fcee12163d51c65d2c226a7856295d9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/messaging/zipball/b9dfafb5efc1d12cbee01d03dc98853ef026e35b",
|
||||
"reference": "b9dfafb5efc1d12cbee01d03dc98853ef026e35b",
|
||||
"url": "https://api.github.com/repos/utopia-php/messaging/zipball/f6790fba1fcee12163d51c65d2c226a7856295d9",
|
||||
"reference": "f6790fba1fcee12163d51c65d2c226a7856295d9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -2169,9 +2169,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/messaging/issues",
|
||||
"source": "https://github.com/utopia-php/messaging/tree/0.12.1"
|
||||
"source": "https://github.com/utopia-php/messaging/tree/0.12.2"
|
||||
},
|
||||
"time": "2024-10-09T08:17:07+00:00"
|
||||
"time": "2024-10-22T01:02:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/migration",
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Target extends Model
|
|||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Target Name.',
|
||||
'default' => '',
|
||||
'example' => 'Aegon apple token',
|
||||
'example' => 'Apple iPhone 12',
|
||||
])
|
||||
->addRule('userId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
@ -58,6 +58,12 @@ class Target extends Model
|
|||
'description' => 'The target identifier.',
|
||||
'default' => '',
|
||||
'example' => 'token',
|
||||
])
|
||||
->addRule('expired', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is the target expired.',
|
||||
'default' => false,
|
||||
'example' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2695,4 +2695,45 @@ class AccountCustomClientTest extends Scope
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testCreatePushTarget(): void
|
||||
{
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/targets/push', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id']
|
||||
], $this->getHeaders()), [
|
||||
'targetId' => ID::unique(),
|
||||
'identifier' => 'test-identifier',
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertEquals('test-identifier', $response['body']['identifier']);
|
||||
}
|
||||
|
||||
public function testUpdatePushTarget(): void
|
||||
{
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/targets/push', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'targetId' => ID::unique(),
|
||||
'identifier' => 'test-identifier-2',
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertEquals('test-identifier-2', $response['body']['identifier']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PUT, '/account/targets/'. $response['body']['$id'] .'/push', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'identifier' => 'test-identifier-updated',
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('test-identifier-updated', $response['body']['identifier']);
|
||||
$this->assertEquals(false, $response['body']['expired']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ class HealthCustomServerTest extends Scope
|
|||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('/CN=www.google.com', $response['body']['name']);
|
||||
$this->assertEquals('www.google.com', $response['body']['subjectSN']);
|
||||
$this->assertStringContainsString('Google Trust Services', $response['body']['issuerOrganisation']);
|
||||
$this->assertContains($response['body']['issuerOrganisation'], ['Let\'s Encrypt', 'Google Trust Services']);
|
||||
$this->assertIsInt($response['body']['validFrom']);
|
||||
$this->assertIsInt($response['body']['validTo']);
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ class HealthCustomServerTest extends Scope
|
|||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('/CN=appwrite.io', $response['body']['name']);
|
||||
$this->assertEquals('appwrite.io', $response['body']['subjectSN']);
|
||||
$this->assertEquals("Let's Encrypt", $response['body']['issuerOrganisation']);
|
||||
$this->assertContains($response['body']['issuerOrganisation'], ['Let\'s Encrypt', 'Google Trust Services']);
|
||||
$this->assertIsInt($response['body']['validFrom']);
|
||||
$this->assertIsInt($response['body']['validTo']);
|
||||
|
||||
|
|
|
|||
|
|
@ -1498,6 +1498,7 @@ trait UsersBase
|
|||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('random-email1@mail.org', $response['body']['identifier']);
|
||||
$this->assertEquals(false, $response['body']['expired']);
|
||||
return $response['body'];
|
||||
}
|
||||
|
||||
|
|
@ -1510,6 +1511,7 @@ trait UsersBase
|
|||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(3, \count($response['body']['targets']));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue