diff --git a/CHANGES.md b/CHANGES.md index 0dd92eeff6..0f24324eeb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,10 @@ - Renamed *Devices* to *Sessions* - Add Provider Icon to each Session - Add Anonymous Account Placeholder -- Upgraded telegraf docker image version to v1.1.0 +- Upgraded telegraf docker image version to v1.2.0 +- Added new environment variables to the `telegraf` service: + - _APP_INFLUXDB_HOST + - _APP_INFLUXDB_PORT ## Bugs diff --git a/app/config/locale/templates/email-base.tpl b/app/config/locale/templates/email-base.tpl index 561ce73855..c9b730f46e 100644 --- a/app/config/locale/templates/email-base.tpl +++ b/app/config/locale/templates/email-base.tpl @@ -56,13 +56,13 @@ .main { background: {{bg-content}}; - border-radius: 3px; + border-radius: 10px; width: 100%; } .wrapper { box-sizing: border-box; - padding: 20px; + padding: 30px 30px 15px 30px; } .content-block { @@ -97,16 +97,15 @@ .btn table td { background-color: {{bg-content}}; - border-radius: 5px; + border-radius: 20px; text-align: center; } .btn a { background-color: {{bg-content}}; - border: solid 1px {{bg-cta}}; - border-radius: 5px; + border-radius: 20px; box-sizing: border-box; - color: #3498db; + color: #577590; cursor: pointer; display: inline-block; font-size: 14px; @@ -123,45 +122,17 @@ .btn-primary a { background-color: {{bg-cta}}; - border-color: {{bg-cta}}; color: {{text-cta}}; } @media only screen and (max-width: 620px) { - table[class=body] h1 { - font-size: 28px !important; - margin-bottom: 10px !important; + .container { + padding: 0; + width: 100%; } - table[class=body] p { - font-size: 16px !important; - } - - table[class=body] .wrapper { - padding: 10px !important; - } - - table[class=body] .content { - padding: 0 !important; - } - - table[class=body] .container { - padding: 0 !important; - width: 100% !important; - } - - table[class=body] .main { - border-left-width: 0 !important; - border-radius: 0 !important; - border-right-width: 0 !important; - } - - table[class=body] .btn table { - width: 100% !important; - } - - table[class=body] .btn a { - width: 100% !important; + .btn-primary a { + font-size: 13px; } } @@ -198,12 +169,11 @@ } .btn-primary table td:hover { - background-color: {{bg-cta-hover}} !important; + opacity: 0.7 !important; } .btn-primary a:hover { - background-color: {{bg-cta-hover}} !important; - border-color: {{bg-cta-hover}} !important; + opacity: 0.7 !important; } } @@ -220,15 +190,17 @@
| - {{content}} - | +{{content}} |
New Flutter App (beta)
New iOS App (soon)
New Android App
New Android App (soon)
New iOS App (soon)
New Unity Game (soon)Initialize your SDK with your Appwrite server API endpoint and project ID, which can be found in your project settings page. + +```kotlin +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setSelfSigned(true) // Remove in production +``` + +Before starting to send any API calls to your new Appwrite instance, make sure your Android emulators has network access to the Appwrite server hostname or IP address. + +When trying to connect to Appwrite from an emulator or a mobile device, localhost is the hostname of the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP. You can also use a service like [ngrok](https://ngrok.com/) to proxy the Appwrite API. + +### Make Your First Request + +
Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
+
+```kotlin
+// Register User
+val account = Account(client)
+val response = account.create(
+ "email@example.com",
+ "password"
+)
+```
+
+### Full Example
+
+```kotlin
+import io.appwrite.Client
+import io.appwrite.services.Account
+
+val client = Client(context)
+ .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
+ .setProject("5df5acd0d48c2") // Your project ID
+ .setSelfSigned(true) // Remove in production
+
+val account = Account(client)
+val response = account.create(
+ "email@example.com",
+ "password"
+)
+```
+
+### Error Handling
+The Appwrite Android SDK raises an `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
+
+```kotlin
+try {
+ var response = account.create("email@example.com", "password")
+ Log.d("Appwrite response", response.body?.string())
+} catch(e : AppwriteException) {
+ Log.e("AppwriteException",e.message.toString())
+}
+```
+
+### Learn more
+You can use following resources to learn more and get help
+- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-android)
+- 📜 [Appwrite Docs](https://appwrite.io/docs)
+- 💬 [Discord Community](https://appwrite.io/discord)
+- 🚂 [Appwrite Android Playground](https://github.com/appwrite/playground-for-android)
\ No newline at end of file
diff --git a/docs/sdks/deno/GETTING_STARTED.md b/docs/sdks/deno/GETTING_STARTED.md
index b8f851a4b9..3a239003fa 100644
--- a/docs/sdks/deno/GETTING_STARTED.md
+++ b/docs/sdks/deno/GETTING_STARTED.md
@@ -1,7 +1,7 @@
## Getting Started
### Init your SDK
-Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
+Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
```typescript
let client = new sdk.Client();
@@ -17,7 +17,7 @@ client
### Make your first request
-Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
+Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```typescript
let users = new sdk.Users(client);
diff --git a/docs/sdks/flutter/GETTING_STARTED.md b/docs/sdks/flutter/GETTING_STARTED.md
index 9af9720d89..0a7244b197 100644
--- a/docs/sdks/flutter/GETTING_STARTED.md
+++ b/docs/sdks/flutter/GETTING_STARTED.md
@@ -23,7 +23,7 @@ The Appwrite SDK uses ASWebAuthenticationSession on iOS 12+ and SFAuthentication
4. In Deployment Info, 'Target' select iOS 11.0
### Android
-In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console.
+In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to replace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in the console.
```xml
Initialize your SDK code with your project ID, which can be found in your project settings page.
+ Initialize your SDK with your Appwrite server API endpoint and project ID, which can be found in your project settings page.
```dart
import 'package:appwrite/appwrite.dart';
@@ -68,7 +68,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos
### Make Your First Request
- Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
+ Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```dart
// Register User
diff --git a/docs/sdks/nodejs/GETTING_STARTED.md b/docs/sdks/nodejs/GETTING_STARTED.md
index b2ce5f091c..ee19ca3c3d 100644
--- a/docs/sdks/nodejs/GETTING_STARTED.md
+++ b/docs/sdks/nodejs/GETTING_STARTED.md
@@ -1,7 +1,7 @@
## Getting Started
### Init your SDK
-Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key project API keys section.
+Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section.
```js
const sdk = require('node-appwrite');
@@ -17,7 +17,7 @@ client
```
### Make Your First Request
-Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
+Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```js
let users = new sdk.Users(client);
diff --git a/docs/sdks/php/GETTING_STARTED.md b/docs/sdks/php/GETTING_STARTED.md
index a7ceb61372..7aef8cdccf 100644
--- a/docs/sdks/php/GETTING_STARTED.md
+++ b/docs/sdks/php/GETTING_STARTED.md
@@ -1,7 +1,7 @@
## Getting Started
### Init your SDK
-Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
+Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
```php
$client = new Client();
@@ -15,7 +15,7 @@ $client
```
### Make Your First Request
-Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
+Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```php
$users = new Users($client);
diff --git a/docs/sdks/python/GETTING_STARTED.md b/docs/sdks/python/GETTING_STARTED.md
index 81c7954509..b68f51affb 100644
--- a/docs/sdks/python/GETTING_STARTED.md
+++ b/docs/sdks/python/GETTING_STARTED.md
@@ -1,7 +1,7 @@
## Getting Started
### Init your SDK
-Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
+Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
```python
from appwrite.client import Client
@@ -18,7 +18,7 @@ client = Client()
```
### Make Your First Request
-Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
+Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```python
users = Users(client)
diff --git a/docs/sdks/ruby/GETTING_STARTED.md b/docs/sdks/ruby/GETTING_STARTED.md
index acabf1c0a9..820f1669eb 100644
--- a/docs/sdks/ruby/GETTING_STARTED.md
+++ b/docs/sdks/ruby/GETTING_STARTED.md
@@ -1,7 +1,7 @@
## Getting Started
### Init your SDK
-Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
+Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section.
```ruby
require 'appwrite'
@@ -17,7 +17,7 @@ client
```
### Make Your First Request
-Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
+Once your SDK object is set, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```ruby
users = Appwrite::Users.new(client);
diff --git a/docs/sdks/web/GETTING_STARTED.md b/docs/sdks/web/GETTING_STARTED.md
index ba337b178f..1fe6250d29 100644
--- a/docs/sdks/web/GETTING_STARTED.md
+++ b/docs/sdks/web/GETTING_STARTED.md
@@ -6,7 +6,7 @@ For you to init your SDK and interact with Appwrite services you need to add a w
From the options, choose to add a **Web** platform and add your client app hostname. By adding your hostname to your project platform you are allowing cross-domain communication between your project and the Appwrite API.
### Init your SDK
-Initialize your SDK code with your project ID which can be found in your project settings page.
+Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.
```js
// Init your Web SDK
@@ -19,7 +19,7 @@ sdk
```
### Make Your First Request
-Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.
+Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.
```js
// Register User
diff --git a/public/images/clients/ios.png b/public/images/clients/ios.png
new file mode 100644
index 0000000000..82e11f98d6
Binary files /dev/null and b/public/images/clients/ios.png differ
diff --git a/public/images/clients/linux.png b/public/images/clients/linux.png
new file mode 100644
index 0000000000..d819e17b0a
Binary files /dev/null and b/public/images/clients/linux.png differ
diff --git a/public/images/clients/macos.png b/public/images/clients/macos.png
new file mode 100644
index 0000000000..64d35acc0b
Binary files /dev/null and b/public/images/clients/macos.png differ
diff --git a/public/images/clients/windows.png b/public/images/clients/windows.png
new file mode 100644
index 0000000000..14575ae0f8
Binary files /dev/null and b/public/images/clients/windows.png differ
diff --git a/src/Appwrite/Database/Pool.php b/src/Appwrite/Database/Pool.php
index db8a7c5f6f..f914f38e77 100644
--- a/src/Appwrite/Database/Pool.php
+++ b/src/Appwrite/Database/Pool.php
@@ -9,11 +9,11 @@ abstract class Pool
abstract public function get();
- public function destruct ()
+ public function destruct()
{
$this->available = false;
while (!$this->pool->isEmpty()) {
$this->pool->pop();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Appwrite/Database/Pool/PDO.php b/src/Appwrite/Database/Pool/PDOPool.php
similarity index 80%
rename from src/Appwrite/Database/Pool/PDO.php
rename to src/Appwrite/Database/Pool/PDOPool.php
index 7233f874ff..75da61e6eb 100644
--- a/src/Appwrite/Database/Pool/PDO.php
+++ b/src/Appwrite/Database/Pool/PDOPool.php
@@ -12,12 +12,12 @@ class PDOPool extends Pool
{
$this->pool = new SplQueue;
$this->size = $size;
- for ($i=0; $i < $this->size; $i++) {
+ for ($i = 0; $i < $this->size; $i++) {
$pdo = new PDO(
- "mysql:".
- "host={$host};".
- "dbname={$schema};" .
- "charset={$charset}",
+ "mysql:" .
+ "host={$host};" .
+ "dbname={$schema};" .
+ "charset={$charset}",
$user,
$pass,
[
@@ -28,17 +28,17 @@ class PDOPool extends Pool
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
]
- );
+ );
$this->pool->enqueue($pdo);
}
}
- public function put (PDO $pdo)
+ public function put(PDO $pdo)
{
$this->pool->enqueue($pdo);
}
- public function get (): PDO
+ public function get(): PDO
{
if ($this->available && count($this->pool) > 0) {
return $this->pool->dequeue();
diff --git a/src/Appwrite/Database/Pool/Redis.php b/src/Appwrite/Database/Pool/RedisPool.php
similarity index 85%
rename from src/Appwrite/Database/Pool/Redis.php
rename to src/Appwrite/Database/Pool/RedisPool.php
index 197f20747c..08e102abb0 100644
--- a/src/Appwrite/Database/Pool/Redis.php
+++ b/src/Appwrite/Database/Pool/RedisPool.php
@@ -13,11 +13,11 @@ class RedisPool extends Pool
{
$this->pool = new SplQueue;
$this->size = $size;
- for ($i=0; $i < $this->size; $i++) {
+ for ($i = 0; $i < $this->size; $i++) {
$redis = new Redis();
$redis->pconnect($host, $port);
$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);
-
+
if ($auth) {
$redis->auth($auth);
}
@@ -26,12 +26,12 @@ class RedisPool extends Pool
}
}
- public function put (Redis $redis)
+ public function put(Redis $redis)
{
$this->pool->enqueue($redis);
}
- public function get (): Redis
+ public function get(): Redis
{
if ($this->available && !$this->pool->isEmpty()) {
return $this->pool->dequeue();
diff --git a/src/Appwrite/Network/Validator/Origin.php b/src/Appwrite/Network/Validator/Origin.php
index 8101d9a30c..1581c445c6 100644
--- a/src/Appwrite/Network/Validator/Origin.php
+++ b/src/Appwrite/Network/Validator/Origin.php
@@ -13,6 +13,9 @@ class Origin extends Validator
const CLIENT_TYPE_FLUTTER_MACOS = 'flutter-macos';
const CLIENT_TYPE_FLUTTER_WINDOWS = 'flutter-windows';
const CLIENT_TYPE_FLUTTER_LINUX = 'flutter-linux';
+ const CLIENT_TYPE_ANDROID = 'android';
+ const CLIENT_TYPE_IOS = 'ios';
+
const SCHEME_TYPE_HTTP = 'http';
const SCHEME_TYPE_HTTPS = 'https';
@@ -69,6 +72,8 @@ class Origin extends Validator
case self::CLIENT_TYPE_FLUTTER_MACOS:
case self::CLIENT_TYPE_FLUTTER_WINDOWS:
case self::CLIENT_TYPE_FLUTTER_LINUX:
+ case self::CLIENT_TYPE_ANDROID:
+ case self::CLIENT_TYPE_IOS:
$this->clients[] = (isset($platform['key'])) ? $platform['key'] : '';
break;
@@ -90,7 +95,7 @@ class Origin extends Validator
}
/**
- * Check if Origin has been whiltlisted
+ * Check if Origin has been allowed
* for access to the API
*
* @param mixed $origin
diff --git a/src/Appwrite/Realtime/Realtime.php b/src/Appwrite/Realtime/Parser.php
similarity index 99%
rename from src/Appwrite/Realtime/Realtime.php
rename to src/Appwrite/Realtime/Parser.php
index f0f893f267..f99e7bfbe9 100644
--- a/src/Appwrite/Realtime/Realtime.php
+++ b/src/Appwrite/Realtime/Parser.php
@@ -5,7 +5,7 @@ namespace Appwrite\Realtime;
use Appwrite\Auth\Auth;
use Appwrite\Database\Document;
-class Realtime
+class Parser
{
/**
* @var Document $user
diff --git a/src/Appwrite/Realtime/Server.php b/src/Appwrite/Realtime/Server.php
new file mode 100644
index 0000000000..0eed3f24b4
--- /dev/null
+++ b/src/Appwrite/Realtime/Server.php
@@ -0,0 +1,393 @@
+subscriptions = [];
+ $this->connections = [];
+ $this->register = $register;
+
+ $this->stats = new Table(4096, 1);
+ $this->stats->column('projectId', Table::TYPE_STRING, 64);
+ $this->stats->column('connections', Table::TYPE_INT);
+ $this->stats->column('connectionsTotal', Table::TYPE_INT);
+ $this->stats->column('messages', Table::TYPE_INT);
+ $this->stats->create();
+
+ $this->server = new SwooleServer($host, $port, SWOOLE_PROCESS);
+ $this->server->set($config);
+ $this->server->on('start', [$this, 'onStart']);
+ $this->server->on('workerStart', [$this, 'onWorkerStart']);
+ $this->server->on('open', [$this, 'onOpen']);
+ $this->server->on('message', [$this, 'onMessage']);
+ $this->server->on('close', [$this, 'onClose']);
+ $this->server->start();
+ }
+
+ /**
+ * This is executed when the Realtime server starts.
+ * @param SwooleServer $server
+ * @return void
+ */
+ public function onStart(SwooleServer $server): void
+ {
+ Console::success('Server started succefully');
+ Console::info("Master pid {$server->master_pid}, manager pid {$server->manager_pid}");
+
+ Timer::tick(10000, function () {
+ /** @var Table $stats */
+ foreach ($this->stats as $projectId => $value) {
+ if (empty($value['connections']) && empty($value['messages'])) {
+ continue;
+ }
+
+ $connections = $value['connections'];
+ $messages = $value['messages'];
+
+ $usage = new Event('v1-usage', 'UsageV1');
+ $usage
+ ->setParam('projectId', $projectId)
+ ->setParam('realtimeConnections', $connections)
+ ->setParam('realtimeMessages', $messages)
+ ->setParam('networkRequestSize', 0)
+ ->setParam('networkResponseSize', 0);
+
+ $this->stats->set($projectId, [
+ 'projectId' => $projectId,
+ 'messages' => 0,
+ 'connections' => 0
+ ]);
+
+ if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
+ $usage->trigger();
+ }
+ }
+ });
+
+ Process::signal(2, function () use ($server) {
+ Console::log('Stop by Ctrl+C');
+ $server->shutdown();
+ });
+ }
+
+ /**
+ * This is executed when a WebSocket worker process starts.
+ * @param SwooleServer $server
+ * @param int $workerId
+ * @return void
+ * @throws Exception
+ */
+ public function onWorkerStart(SwooleServer $server, int $workerId): void
+ {
+ Console::success('Worker ' . $workerId . ' started succefully');
+
+ $attempts = 0;
+ $start = time();
+ $redisPool = $this->register->get('redisPool');
+
+ /**
+ * Sending current connections to project channels on the console project every 5 seconds.
+ */
+ $server->tick(5000, function () use (&$server) {
+ $this->tickSendProjectUsage($server);
+ });
+
+ while ($attempts < 300) {
+ try {
+ if ($attempts > 0) {
+ Console::error('Pub/sub connection lost (lasted ' . (time() - $start) . ' seconds, worker: ' . $workerId . ').
+ Attempting restart in 5 seconds (attempt #' . $attempts . ')');
+ sleep(5); // 5 sec delay between connection attempts
+ }
+
+ /** @var Swoole\Coroutine\Redis $redis */
+ $redis = $redisPool->get();
+
+ if ($redis->ping(true)) {
+ $attempts = 0;
+ Console::success('Pub/sub connection established (worker: ' . $workerId . ')');
+ } else {
+ Console::error('Pub/sub failed (worker: ' . $workerId . ')');
+ }
+
+ $redis->subscribe(['realtime'], function ($redis, $channel, $payload) use ($server, $workerId) {
+ $this->onRedisPublish($payload, $server, $workerId);
+ });
+ } catch (\Throwable $th) {
+ Console::error('Pub/sub error: ' . $th->getMessage());
+ $redisPool->put($redis);
+ $attempts++;
+ continue;
+ }
+
+ $attempts++;
+ }
+
+ Console::error('Failed to restart pub/sub...');
+ }
+
+ /**
+ * This is executed when a new Realtime connection is established.
+ * @param SwooleServer $server
+ * @param Request $request
+ * @return void
+ * @throws Exception
+ * @throws UtopiaException
+ */
+ public function onOpen(SwooleServer $server, Request $request): void
+ {
+ $app = new App('UTC');
+ $connection = $request->fd;
+ $request = new SwooleRequest($request);
+
+ $db = $this->register->get('dbPool')->get();
+ $redis = $this->register->get('redisPool')->get();
+
+ $this->register->set('db', function () use (&$db) {
+ return $db;
+ });
+
+ $this->register->set('cache', function () use (&$redis) { // Register cache connection
+ return $redis;
+ });
+
+ Console::info("Connection open (user: {$connection}, worker: {$server->getWorkerId()})");
+
+ App::setResource('request', function () use ($request) {
+ return $request;
+ });
+
+ App::setResource('response', function () {
+ return new Response(new SwooleResponse());
+ });
+
+ try {
+ /** @var \Appwrite\Database\Document $user */
+ $user = $app->getResource('user');
+
+ /** @var \Appwrite\Database\Document $project */
+ $project = $app->getResource('project');
+
+ /** @var \Appwrite\Database\Document $console */
+ $console = $app->getResource('console');
+
+ /*
+ * Project Check
+ */
+ if (empty($project->getId())) {
+ throw new Exception('Missing or unknown project ID', 1008);
+ }
+
+ /*
+ * Abuse Check
+ *
+ * Abuse limits are connecting 128 times per minute and ip address.
+ */
+ $timeLimit = new TimeLimit('url:{url},ip:{ip}', 128, 60, function () use ($db) {
+ return $db;
+ });
+ $timeLimit
+ ->setNamespace('app_' . $project->getId())
+ ->setParam('{ip}', $request->getIP())
+ ->setParam('{url}', $request->getURI());
+
+ $abuse = new Abuse($timeLimit);
+
+ if ($abuse->check() && App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') === 'enabled') {
+ throw new Exception('Too many requests', 1013);
+ }
+
+ /*
+ * Validate Client Domain - Check to avoid CSRF attack.
+ * Adding Appwrite API domains to allow XDOMAIN communication.
+ * Skip this check for non-web platforms which are not required to send an origin header.
+ */
+ $origin = $request->getOrigin();
+ $originValidator = new Origin(\array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', [])));
+
+ if (!$originValidator->isValid($origin) && $project->getId() !== 'console') {
+ throw new Exception($originValidator->getDescription(), 1008);
+ }
+
+ Parser::setUser($user);
+
+ $roles = Parser::getRoles();
+ $channels = Parser::parseChannels($request->getQuery('channels', []));
+
+ /**
+ * Channels Check
+ */
+ if (empty($channels)) {
+ throw new Exception('Missing channels', 1008);
+ }
+
+ Parser::subscribe($project->getId(), $connection, $roles, $this->subscriptions, $this->connections, $channels);
+
+ $server->push($connection, json_encode($channels));
+
+ $this->stats->incr($project->getId(), 'connections');
+ $this->stats->incr($project->getId(), 'connectionsTotal');
+ } catch (\Throwable $th) {
+ $response = [
+ 'code' => $th->getCode(),
+ 'message' => $th->getMessage()
+ ];
+ // Temporarily print debug logs by default for Alpha testing.
+ //if (App::isDevelopment()) {
+ Console::error("[Error] Connection Error");
+ Console::error("[Error] Code: " . $response['code']);
+ Console::error("[Error] Message: " . $response['message']);
+ //}
+ $server->push($connection, json_encode($response));
+ $server->close($connection);
+ }
+ /**
+ * Put used PDO and Redis Connections back into their pools.
+ */
+ /** @var PDOPool $dbPool */
+ $dbPool = $this->register->get('dbPool');
+ $dbPool->put($db);
+
+ /** @var RedisPool $redisPool */
+ $redisPool = $this->register->get('redisPool');
+ $redisPool->put($redis);
+ }
+
+ /**
+ * This is executed when a message is received by the Realtime server.
+ * @param SwooleServer $server
+ * @param Frame $frame
+ * @return void
+ */
+ public function onMessage(SwooleServer $server, Frame $frame)
+ {
+ $server->push($frame->fd, 'Sending messages is not allowed.');
+ $server->close($frame->fd);
+ }
+
+ /**
+ * This is executed when a Realtime connection is closed.
+ * @param SwooleServer $server
+ * @param int $connection
+ * @return void
+ */
+ public function onClose(SwooleServer $server, int $connection)
+ {
+ if (array_key_exists($connection, $this->connections)) {
+ $this->stats->decr($this->connections[$connection]['projectId'], 'connectionsTotal');
+ }
+ Parser::unsubscribe($connection, $this->subscriptions, $this->connections);
+ Console::info('Connection close: ' . $connection);
+ }
+
+ /**
+ * This is executed when an event is published on realtime channel in Redis.
+ * @param string $payload
+ * @param SwooleServer $server
+ * @param int $workerId
+ * @return void
+ */
+ public function onRedisPublish(string $payload, SwooleServer &$server, int $workerId)
+ {
+ /**
+ * Supported Resources:
+ * - Collection
+ * - Document
+ * - File
+ * - Account
+ * - Session
+ * - Team? (not implemented yet)
+ * - Membership? (not implemented yet)
+ * - Function
+ * - Execution
+ */
+ $event = json_decode($payload, true);
+
+ $receivers = Parser::identifyReceivers($event, $this->subscriptions);
+
+ // Temporarily print debug logs by default for Alpha testing.
+ // if (App::isDevelopment() && !empty($receivers)) {
+ if (!empty($receivers)) {
+ Console::log("[Debug][Worker {$workerId}] Receivers: " . count($receivers));
+ Console::log("[Debug][Worker {$workerId}] Receivers Connection IDs: " . json_encode($receivers));
+ Console::log("[Debug][Worker {$workerId}] Event: " . $payload);
+ }
+
+ foreach ($receivers as $receiver) {
+ if ($server->exist($receiver) && $server->isEstablished($receiver)) {
+ $server->push(
+ $receiver,
+ json_encode($event['data']),
+ SWOOLE_WEBSOCKET_OPCODE_TEXT,
+ SWOOLE_WEBSOCKET_FLAG_FIN | SWOOLE_WEBSOCKET_FLAG_COMPRESS
+ );
+ } else {
+ $server->close($receiver);
+ }
+ }
+ if (($num = count($receivers)) > 0) {
+ $this->stats->incr($event['project'], 'messages', $num);
+ }
+ }
+
+ /**
+ * This sends the usage to the `console` channel.
+ * @param SwooleServer $server
+ * @return void
+ */
+ public function tickSendProjectUsage(SwooleServer &$server)
+ {
+ if (
+ array_key_exists('console', $this->subscriptions)
+ && array_key_exists('role:member', $this->subscriptions['console'])
+ && array_key_exists('project', $this->subscriptions['console']['role:member'])
+ ) {
+ $payload = [];
+ foreach ($this->stats as $projectId => $value) {
+ $payload[$projectId] = $value['connectionsTotal'];
+ }
+ foreach ($this->subscriptions['console']['role:member']['project'] as $connection => $value) {
+ $server->push(
+ $connection,
+ json_encode([
+ 'event' => 'stats.connections',
+ 'channels' => ['project'],
+ 'timestamp' => time(),
+ 'payload' => $payload
+ ]),
+ SWOOLE_WEBSOCKET_OPCODE_TEXT,
+ SWOOLE_WEBSOCKET_FLAG_FIN | SWOOLE_WEBSOCKET_FLAG_COMPRESS
+ );
+ }
+ }
+ }
+}
diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php
index 7c27b0f104..c82724ace9 100644
--- a/src/Appwrite/Resque/Worker.php
+++ b/src/Appwrite/Resque/Worker.php
@@ -2,18 +2,14 @@
namespace Appwrite\Resque;
-use Swoole\Runtime;
-
-use function Swoole\Coroutine\run;
-
abstract class Worker
{
public $args = [];
abstract public function init(): void;
-
+
abstract public function run(): void;
-
+
abstract public function shutdown(): void;
public function setUp(): void
diff --git a/src/Appwrite/Utopia/Response/Filters/V07.php b/src/Appwrite/Utopia/Response/Filters/V07.php
index 6001450b9a..36831b4733 100644
--- a/src/Appwrite/Utopia/Response/Filters/V07.php
+++ b/src/Appwrite/Utopia/Response/Filters/V07.php
@@ -55,6 +55,8 @@ class V07 extends Filter {
case Response::MODEL_ANY:
case Response::MODEL_PREFERENCES: /** ANY was replaced by PREFERENCES in 0.8.x but this is backward compatible with 0.7.x */
case Response::MODEL_NONE:
+ case Response::MODEL_ERROR:
+ case Response::MODEL_ERROR_DEV:
$parsedResponse = $content;
break;
default:
diff --git a/tests/e2e/General/HTTPTest.php b/tests/e2e/General/HTTPTest.php
index 8d38b3e882..c233f241b3 100644
--- a/tests/e2e/General/HTTPTest.php
+++ b/tests/e2e/General/HTTPTest.php
@@ -94,33 +94,33 @@ class HTTPTest extends Scope
$this->assertStringContainsString('# robotstxt.org/', $response['body']);
}
- public function testSpecSwagger2()
- {
- $response = $this->client->call(Client::METHOD_GET, '/specs/swagger2?platform=client', [
- 'content-type' => 'application/json',
- ], []);
+ // public function testSpecSwagger2()
+ // {
+ // $response = $this->client->call(Client::METHOD_GET, '/specs/swagger2?platform=client', [
+ // 'content-type' => 'application/json',
+ // ], []);
- if(!file_put_contents(__DIR__ . '/../../resources/swagger2.json', json_encode($response['body']))) {
- throw new Exception('Failed to save spec file');
- }
+ // if(!file_put_contents(__DIR__ . '/../../resources/swagger2.json', json_encode($response['body']))) {
+ // throw new Exception('Failed to save spec file');
+ // }
- $client = new Client();
- $client->setEndpoint('https://validator.swagger.io');
+ // $client = new Client();
+ // $client->setEndpoint('https://validator.swagger.io');
- /**
- * Test for SUCCESS
- */
- $response = $client->call(Client::METHOD_POST, '/validator/debug', [
- 'content-type' => 'application/json',
- ], json_decode(file_get_contents(realpath(__DIR__ . '/../../resources/swagger2.json')), true));
+ // /**
+ // * Test for SUCCESS
+ // */
+ // $response = $client->call(Client::METHOD_POST, '/validator/debug', [
+ // 'content-type' => 'application/json',
+ // ], json_decode(file_get_contents(realpath(__DIR__ . '/../../resources/swagger2.json')), true));
- $response['body'] = json_decode($response['body'], true);
+ // $response['body'] = json_decode($response['body'], true);
- $this->assertEquals(200, $response['headers']['status-code']);
- $this->assertTrue(empty($response['body']));
+ // $this->assertEquals(200, $response['headers']['status-code']);
+ // $this->assertTrue(empty($response['body']));
- unlink(realpath(__DIR__ . '/../../resources/swagger2.json'));
- }
+ // unlink(realpath(__DIR__ . '/../../resources/swagger2.json'));
+ // }
public function testSpecOpenAPI3()
{
@@ -209,4 +209,4 @@ class HTTPTest extends Scope
$this->assertIsString($body['server-ruby']);
$this->assertIsString($body['server-cli']);
}
-}
\ No newline at end of file
+}
diff --git a/tests/e2e/Services/Users/UsersBase.php b/tests/e2e/Services/Users/UsersBase.php
index ebefa2abb9..be64204749 100644
--- a/tests/e2e/Services/Users/UsersBase.php
+++ b/tests/e2e/Services/Users/UsersBase.php
@@ -122,6 +122,35 @@ trait UsersBase
return $data;
}
+ /**
+ * @depends testGetUser
+ */
+ public function testUpdateEmailVerification(array $data):array
+ {
+ /**
+ * Test for SUCCESS
+ */
+ $user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/verification', array_merge([
+ 'content-type' => 'application/json',
+ 'x-appwrite-project' => $this->getProject()['$id'],
+ ], $this->getHeaders()), [
+ 'emailVerification' => true,
+ ]);
+
+ $this->assertEquals($user['headers']['status-code'], 200);
+ $this->assertEquals($user['body']['emailVerification'], true);
+
+ $user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
+ 'content-type' => 'application/json',
+ 'x-appwrite-project' => $this->getProject()['$id'],
+ ], $this->getHeaders()));
+
+ $this->assertEquals($user['headers']['status-code'], 200);
+ $this->assertEquals($user['body']['emailVerification'], true);
+
+ return $data;
+ }
+
/**
* @depends testGetUser
*/
diff --git a/tests/unit/Realtime/RealtimeChannelsTest.php b/tests/unit/Realtime/RealtimeChannelsTest.php
index 5145acb2c4..923a38325e 100644
--- a/tests/unit/Realtime/RealtimeChannelsTest.php
+++ b/tests/unit/Realtime/RealtimeChannelsTest.php
@@ -3,7 +3,7 @@
namespace Appwrite\Tests;
use Appwrite\Database\Document;
-use Appwrite\Realtime\Realtime;
+use Appwrite\Realtime;
use PHPUnit\Framework\TestCase;
class RealtimeChannelsTest extends TestCase
@@ -46,7 +46,7 @@ class RealtimeChannelsTest extends TestCase
*/
for ($i = 0; $i < $this->connectionsPerChannel; $i++) {
foreach ($this->allChannels as $index => $channel) {
- Realtime::setUser(new Document([
+ Realtime\Parser::setUser(new Document([
'$id' => 'user' . $this->connectionsCount,
'memberships' => [
[
@@ -57,10 +57,10 @@ class RealtimeChannelsTest extends TestCase
]
]
]));
- $roles = Realtime::getRoles();
- $parsedChannels = Realtime::parseChannels([0 => $channel]);
+ $roles = Realtime\Parser::getRoles();
+ $parsedChannels = Realtime\Parser::parseChannels([0 => $channel]);
- Realtime::subscribe(
+ Realtime\Parser::subscribe(
'1',
$this->connectionsCount,
$roles,
@@ -78,14 +78,14 @@ class RealtimeChannelsTest extends TestCase
*/
for ($i = 0; $i < $this->connectionsPerChannel; $i++) {
foreach ($this->allChannels as $index => $channel) {
- Realtime::setUser(new Document([
+ Realtime\Parser::setUser(new Document([
'$id' => ''
]));
- $roles = Realtime::getRoles();
- $parsedChannels = Realtime::parseChannels([0 => $channel]);
+ $roles = Realtime\Parser::getRoles();
+ $parsedChannels = Realtime\Parser::parseChannels([0 => $channel]);
- Realtime::subscribe(
+ Realtime\Parser::subscribe(
'1',
$this->connectionsCount,
$roles,
@@ -130,13 +130,13 @@ class RealtimeChannelsTest extends TestCase
*/
$this->assertCount($this->connectionsTotal, $this->connections);
- Realtime::unsubscribe(-1, $this->subscriptions, $this->connections);
+ Realtime\Parser::unsubscribe(-1, $this->subscriptions, $this->connections);
$this->assertCount($this->connectionsTotal, $this->connections);
$this->assertCount(($this->connectionsAuthenticated + (3 * $this->connectionsPerChannel) + 2), $this->subscriptions['1']);
for ($i = 0; $i < $this->connectionsCount; $i++) {
- Realtime::unsubscribe($i, $this->subscriptions, $this->connections);
+ Realtime\Parser::unsubscribe($i, $this->subscriptions, $this->connections);
$this->assertCount(($this->connectionsCount - $i - 1), $this->connections);
}
@@ -161,7 +161,7 @@ class RealtimeChannelsTest extends TestCase
]
];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -197,7 +197,7 @@ class RealtimeChannelsTest extends TestCase
]
];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -234,7 +234,7 @@ class RealtimeChannelsTest extends TestCase
]
];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -271,7 +271,7 @@ class RealtimeChannelsTest extends TestCase
]
];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -300,7 +300,7 @@ class RealtimeChannelsTest extends TestCase
]
];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
diff --git a/tests/unit/Realtime/RealtimeGuestTest.php b/tests/unit/Realtime/RealtimeGuestTest.php
index b8cd68f8a9..01e43d7308 100644
--- a/tests/unit/Realtime/RealtimeGuestTest.php
+++ b/tests/unit/Realtime/RealtimeGuestTest.php
@@ -3,7 +3,7 @@
namespace Appwrite\Tests;
use Appwrite\Database\Document;
-use Appwrite\Realtime\Realtime;
+use Appwrite\Realtime;
use PHPUnit\Framework\TestCase;
class RealtimeGuestTest extends TestCase
@@ -13,11 +13,11 @@ class RealtimeGuestTest extends TestCase
public function testGuest()
{
- Realtime::setUser(new Document([
+ Realtime\Parser::setUser(new Document([
'$id' => ''
]));
- $roles = Realtime::getRoles();
+ $roles = Realtime\Parser::getRoles();
$this->assertCount(1, $roles);
$this->assertContains('role:guest', $roles);
@@ -29,7 +29,7 @@ class RealtimeGuestTest extends TestCase
4 => 'account.456'
];
- $channels = Realtime::parseChannels($channels);
+ $channels = Realtime\Parser::parseChannels($channels);
$this->assertCount(3, $channels);
$this->assertArrayHasKey('files', $channels);
$this->assertArrayHasKey('documents', $channels);
@@ -37,7 +37,7 @@ class RealtimeGuestTest extends TestCase
$this->assertArrayNotHasKey('account', $channels);
$this->assertArrayNotHasKey('account.456', $channels);
- Realtime::subscribe('1', 1, $roles, $this->subscriptions, $this->connections, $channels);
+ Realtime\Parser::subscribe('1', 1, $roles, $this->subscriptions, $this->connections, $channels);
$event = [
'project' => '1',
@@ -50,7 +50,7 @@ class RealtimeGuestTest extends TestCase
]
];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -60,7 +60,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['role:guest'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -70,7 +70,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['role:member'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -79,7 +79,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['user:123'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -88,7 +88,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['team:abc'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -97,7 +97,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['team:abc/administrator'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -106,7 +106,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['team:abc/god'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -115,7 +115,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['team:def'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -124,7 +124,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['team:def/guest'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -133,7 +133,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['user:456'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -142,7 +142,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['team:def/member'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -152,7 +152,7 @@ class RealtimeGuestTest extends TestCase
$event['permissions'] = ['*'];
$event['data']['channels'] = ['documents.123'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -161,7 +161,7 @@ class RealtimeGuestTest extends TestCase
$event['data']['channels'] = ['documents.789'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -171,19 +171,19 @@ class RealtimeGuestTest extends TestCase
$event['project'] = '2';
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
$this->assertEmpty($receivers);
- Realtime::unsubscribe(2, $this->subscriptions, $this->connections);
+ Realtime\Parser::unsubscribe(2, $this->subscriptions, $this->connections);
$this->assertCount(1, $this->connections);
$this->assertCount(1, $this->subscriptions['1']);
- Realtime::unsubscribe(1, $this->subscriptions, $this->connections);
+ Realtime\Parser::unsubscribe(1, $this->subscriptions, $this->connections);
$this->assertEmpty($this->connections);
$this->assertEmpty($this->subscriptions);
diff --git a/tests/unit/Realtime/RealtimeTest.php b/tests/unit/Realtime/RealtimeTest.php
index a819f4cb72..a722bea10d 100644
--- a/tests/unit/Realtime/RealtimeTest.php
+++ b/tests/unit/Realtime/RealtimeTest.php
@@ -3,7 +3,7 @@
namespace Appwrite\Tests;
use Appwrite\Database\Document;
-use Appwrite\Realtime\Realtime;
+use Appwrite\Realtime;
use PHPUnit\Framework\TestCase;
class RealtimeTest extends TestCase
@@ -21,7 +21,7 @@ class RealtimeTest extends TestCase
public function testUser()
{
- Realtime::setUser(new Document([
+ Realtime\Parser::setUser(new Document([
'$id' => '123',
'memberships' => [
[
@@ -40,7 +40,7 @@ class RealtimeTest extends TestCase
]
]));
- $roles = Realtime::getRoles();
+ $roles = Realtime\Parser::getRoles();
$this->assertCount(7, $roles);
$this->assertContains('user:123', $roles);
@@ -59,7 +59,7 @@ class RealtimeTest extends TestCase
4 => 'account.456'
];
- $channels = Realtime::parseChannels($channels);
+ $channels = Realtime\Parser::parseChannels($channels);
$this->assertCount(4, $channels);
$this->assertArrayHasKey('files', $channels);
@@ -69,7 +69,7 @@ class RealtimeTest extends TestCase
$this->assertArrayNotHasKey('account', $channels);
$this->assertArrayNotHasKey('account.456', $channels);
- Realtime::subscribe('1', 1, $roles, $this->subscriptions, $this->connections, $channels);
+ Realtime\Parser::subscribe('1', 1, $roles, $this->subscriptions, $this->connections, $channels);
$event = [
'project' => '1',
@@ -81,7 +81,7 @@ class RealtimeTest extends TestCase
]
];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -91,7 +91,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['role:member'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -101,7 +101,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['user:123'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -111,7 +111,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['team:abc'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -121,7 +121,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['team:abc/administrator'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -131,7 +131,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['team:abc/god'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -141,7 +141,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['team:def'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -151,7 +151,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['team:def/guest'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -161,7 +161,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['user:456'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -170,7 +170,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['team:def/member'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -180,7 +180,7 @@ class RealtimeTest extends TestCase
$event['permissions'] = ['*'];
$event['data']['channels'] = ['documents.123'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -189,7 +189,7 @@ class RealtimeTest extends TestCase
$event['data']['channels'] = ['documents.789'];
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
@@ -199,20 +199,20 @@ class RealtimeTest extends TestCase
$event['project'] = '2';
- $receivers = Realtime::identifyReceivers(
+ $receivers = Realtime\Parser::identifyReceivers(
$event,
$this->subscriptions
);
$this->assertEmpty($receivers);
- Realtime::unsubscribe(2, $this->subscriptions, $this->connections);
+ Realtime\Parser::unsubscribe(2, $this->subscriptions, $this->connections);
$this->assertCount(1, $this->connections);
$this->assertCount(7, $this->subscriptions['1']);
- Realtime::unsubscribe(1, $this->subscriptions, $this->connections);
+ Realtime\Parser::unsubscribe(1, $this->subscriptions, $this->connections);
$this->assertEmpty($this->connections);
$this->assertEmpty($this->subscriptions);