1
0
Fork 0
mirror of synced 2024-08-29 09:01:41 +12:00

Merge pull request #8297 from appwrite/fix-subscribers

Disable validation for subquery to prevent error
This commit is contained in:
Jake Barnby 2024-06-25 13:38:47 +12:00 committed by GitHub
commit ef203dc075
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 103 additions and 54 deletions

View file

@ -607,9 +607,9 @@ Database::addFilter(
]) ])
)); ));
if (\count($targetIds) > 0) { if (\count($targetIds) > 0) {
return $database->find('targets', [ return $database->skipValidation(fn () => $database->find('targets', [
Query::equal('$internalId', $targetIds) Query::equal('$internalId', $targetIds)
]); ]));
} }
return []; return [];
} }

View file

@ -44,13 +44,13 @@
"ext-sockets": "*", "ext-sockets": "*",
"appwrite/php-runtimes": "0.13.*", "appwrite/php-runtimes": "0.13.*",
"appwrite/php-clamav": "2.0.*", "appwrite/php-clamav": "2.0.*",
"utopia-php/abuse": "0.37.*", "utopia-php/abuse": "0.38.*",
"utopia-php/analytics": "0.10.*", "utopia-php/analytics": "0.10.*",
"utopia-php/audit": "0.39.*", "utopia-php/audit": "0.40.*",
"utopia-php/cache": "0.10.*", "utopia-php/cache": "0.10.*",
"utopia-php/cli": "0.15.*", "utopia-php/cli": "0.15.*",
"utopia-php/config": "0.2.*", "utopia-php/config": "0.2.*",
"utopia-php/database": "0.49.*", "utopia-php/database": "0.50.*",
"utopia-php/domains": "0.5.*", "utopia-php/domains": "0.5.*",
"utopia-php/dsn": "0.2.1", "utopia-php/dsn": "0.2.1",
"utopia-php/framework": "0.33.*", "utopia-php/framework": "0.33.*",

98
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "e002600539435ca8eaaace6e73b4004d", "content-hash": "89f2552eaa152516be5bf89628c0f86e",
"packages": [ "packages": [
{ {
"name": "adhocore/jwt", "name": "adhocore/jwt",
@ -1128,16 +1128,16 @@
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.29.0", "version": "v1.30.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c",
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1188,7 +1188,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0"
}, },
"funding": [ "funding": [
{ {
@ -1204,20 +1204,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-01-29T20:11:03+00:00" "time": "2024-06-19T12:30:46+00:00"
}, },
{ {
"name": "symfony/polyfill-php80", "name": "symfony/polyfill-php80",
"version": "v1.29.0", "version": "v1.30.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php80.git", "url": "https://github.com/symfony/polyfill-php80.git",
"reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" "reference": "77fa7995ac1b21ab60769b7323d600a991a90433"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433",
"reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "reference": "77fa7995ac1b21ab60769b7323d600a991a90433",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1268,7 +1268,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0"
}, },
"funding": [ "funding": [
{ {
@ -1284,7 +1284,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-01-29T20:11:03+00:00" "time": "2024-05-31T15:07:36+00:00"
}, },
{ {
"name": "thecodingmachine/safe", "name": "thecodingmachine/safe",
@ -1427,23 +1427,23 @@
}, },
{ {
"name": "utopia-php/abuse", "name": "utopia-php/abuse",
"version": "0.37.1", "version": "0.38.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/abuse.git", "url": "https://github.com/utopia-php/abuse.git",
"reference": "4dfcff4754c7804d1a70039792c0f2d59a5cc981" "reference": "b7be9086c9d9b4561d810cbd42fdda798742f56c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/4dfcff4754c7804d1a70039792c0f2d59a5cc981", "url": "https://api.github.com/repos/utopia-php/abuse/zipball/b7be9086c9d9b4561d810cbd42fdda798742f56c",
"reference": "4dfcff4754c7804d1a70039792c0f2d59a5cc981", "reference": "b7be9086c9d9b4561d810cbd42fdda798742f56c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-curl": "*", "ext-curl": "*",
"ext-pdo": "*", "ext-pdo": "*",
"php": ">=8.0", "php": ">=8.0",
"utopia-php/database": "0.49.*" "utopia-php/database": "0.50.*"
}, },
"require-dev": { "require-dev": {
"laravel/pint": "1.5.*", "laravel/pint": "1.5.*",
@ -1470,9 +1470,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/abuse/issues", "issues": "https://github.com/utopia-php/abuse/issues",
"source": "https://github.com/utopia-php/abuse/tree/0.37.1" "source": "https://github.com/utopia-php/abuse/tree/0.38.0"
}, },
"time": "2024-06-05T18:03:59+00:00" "time": "2024-06-24T00:52:02+00:00"
}, },
{ {
"name": "utopia-php/analytics", "name": "utopia-php/analytics",
@ -1522,21 +1522,21 @@
}, },
{ {
"name": "utopia-php/audit", "name": "utopia-php/audit",
"version": "0.39.1", "version": "0.40.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/audit.git", "url": "https://github.com/utopia-php/audit.git",
"reference": "7ea91e0ceea7b94293612fea94022b73315677c2" "reference": "735ae211ce5fee5b52b736731571b4030b1d7cdc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/audit/zipball/7ea91e0ceea7b94293612fea94022b73315677c2", "url": "https://api.github.com/repos/utopia-php/audit/zipball/735ae211ce5fee5b52b736731571b4030b1d7cdc",
"reference": "7ea91e0ceea7b94293612fea94022b73315677c2", "reference": "735ae211ce5fee5b52b736731571b4030b1d7cdc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.0", "php": ">=8.0",
"utopia-php/database": "0.49.*" "utopia-php/database": "0.50.*"
}, },
"require-dev": { "require-dev": {
"laravel/pint": "1.5.*", "laravel/pint": "1.5.*",
@ -1563,9 +1563,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/audit/issues", "issues": "https://github.com/utopia-php/audit/issues",
"source": "https://github.com/utopia-php/audit/tree/0.39.1" "source": "https://github.com/utopia-php/audit/tree/0.40.0"
}, },
"time": "2024-06-05T19:28:22+00:00" "time": "2024-06-24T00:52:17+00:00"
}, },
{ {
"name": "utopia-php/cache", "name": "utopia-php/cache",
@ -1719,16 +1719,16 @@
}, },
{ {
"name": "utopia-php/database", "name": "utopia-php/database",
"version": "0.49.13", "version": "0.50.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/database.git", "url": "https://github.com/utopia-php/database.git",
"reference": "fff42e0bd1db5a03d8c5df4302d72443bde3b860" "reference": "ce3eaccb2f3bbd34b2b97419836fec633b26b8f7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/fff42e0bd1db5a03d8c5df4302d72443bde3b860", "url": "https://api.github.com/repos/utopia-php/database/zipball/ce3eaccb2f3bbd34b2b97419836fec633b26b8f7",
"reference": "fff42e0bd1db5a03d8c5df4302d72443bde3b860", "reference": "ce3eaccb2f3bbd34b2b97419836fec633b26b8f7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1769,9 +1769,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/database/issues", "issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.49.13" "source": "https://github.com/utopia-php/database/tree/0.50.0"
}, },
"time": "2024-06-18T14:33:55+00:00" "time": "2024-06-21T03:21:42+00:00"
}, },
{ {
"name": "utopia-php/domains", "name": "utopia-php/domains",
@ -3156,16 +3156,16 @@
}, },
{ {
"name": "laravel/pint", "name": "laravel/pint",
"version": "v1.16.0", "version": "v1.16.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/pint.git", "url": "https://github.com/laravel/pint.git",
"reference": "1b3a3dc5bc6a81ff52828ba7277621f1d49d6d98" "reference": "9266a47f1b9231b83e0cfd849009547329d871b1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/1b3a3dc5bc6a81ff52828ba7277621f1d49d6d98", "url": "https://api.github.com/repos/laravel/pint/zipball/9266a47f1b9231b83e0cfd849009547329d871b1",
"reference": "1b3a3dc5bc6a81ff52828ba7277621f1d49d6d98", "reference": "9266a47f1b9231b83e0cfd849009547329d871b1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3176,13 +3176,13 @@
"php": "^8.1.0" "php": "^8.1.0"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^3.57.1", "friendsofphp/php-cs-fixer": "^3.59.3",
"illuminate/view": "^10.48.10", "illuminate/view": "^10.48.12",
"larastan/larastan": "^2.9.6", "larastan/larastan": "^2.9.7",
"laravel-zero/framework": "^10.4.0", "laravel-zero/framework": "^10.4.0",
"mockery/mockery": "^1.6.12", "mockery/mockery": "^1.6.12",
"nunomaduro/termwind": "^1.15.1", "nunomaduro/termwind": "^1.15.1",
"pestphp/pest": "^2.34.7" "pestphp/pest": "^2.34.8"
}, },
"bin": [ "bin": [
"builds/pint" "builds/pint"
@ -3218,7 +3218,7 @@
"issues": "https://github.com/laravel/pint/issues", "issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint" "source": "https://github.com/laravel/pint"
}, },
"time": "2024-05-21T18:08:25+00:00" "time": "2024-06-18T16:50:05+00:00"
}, },
{ {
"name": "matthiasmullie/minify", "name": "matthiasmullie/minify",
@ -5340,16 +5340,16 @@
}, },
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
"version": "v1.29.0", "version": "v1.30.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git", "url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" "reference": "0424dff1c58f028c451efff2045f5d92410bd540"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540",
"reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "reference": "0424dff1c58f028c451efff2045f5d92410bd540",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5399,7 +5399,7 @@
"portable" "portable"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0"
}, },
"funding": [ "funding": [
{ {
@ -5415,7 +5415,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-01-29T20:11:03+00:00" "time": "2024-05-31T15:07:36+00:00"
}, },
{ {
"name": "textalk/websocket", "name": "textalk/websocket",
@ -5615,5 +5615,5 @@
"platform-overrides": { "platform-overrides": {
"php": "8.3" "php": "8.3"
}, },
"plugin-api-version": "2.2.0" "plugin-api-version": "2.6.0"
} }

View file

@ -511,6 +511,55 @@ trait MessagingBase
]; ];
} }
public function testSubscriberTargetSubQuery()
{
$response = $this->client->call(Client::METHOD_POST, '/messaging/topics', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'topicId' => 'sub-query-test',
'name' => 'sub-query-test',
]);
$this->assertEquals(201, $response['headers']['status-code']);
$topic = $response['body'];
$prefix = uniqid();
for ($i = 1; $i <= 101; $i++) {
$response = $this->client->call(Client::METHOD_POST, '/users', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'userId' => "$prefix-$i",
'email' => "$prefix-$i@example.com",
'password' => 'password',
'name' => "User $prefix $i",
]);
$this->assertEquals(201, $response['headers']['status-code']);
$user = $response['body'];
$targets = $user['targets'] ?? [];
$this->assertGreaterThan(0, count($targets));
$target = $targets[0];
$response = $this->client->call(Client::METHOD_POST, '/messaging/topics/' . $topic['$id'] . '/subscribers', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'subscriberId' => $user['$id'],
'targetId' => $target['$id'],
]);
$this->assertEquals(201, $response['headers']['status-code']);
}
}
/** /**
* @depends testCreateSubscriber * @depends testCreateSubscriber
*/ */