From 6b77fcf21f775c28ab328b43650300c3cfeccc9a Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Wed, 12 Jan 2022 20:51:13 +0100 Subject: [PATCH 01/35] FIxed 409 for createCollection --- app/controllers/api/database.php | 4 ++-- .../Database/DatabaseCustomServerTest.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index c6fb149700..00e951030f 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -166,8 +166,6 @@ App::post('/v1/database/collections') $collectionId = $collectionId == 'unique()' ? $dbForProject->getId() : $collectionId; try { - $dbForProject->createCollection('collection_' . $collectionId); - $collection = $dbForProject->createDocument('collections', new Document([ '$id' => $collectionId, '$read' => $read ?? [], // Collection permissions for collection documents (based on permission model) @@ -183,6 +181,8 @@ App::post('/v1/database/collections') throw new Exception('Collection already exists', 409); } + $dbForProject->createCollection('collection_' . $collectionId); + $audits ->setParam('event', 'database.collections.create') ->setParam('resource', 'collection/'.$collectionId) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 659839debe..cd14974c6c 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -7,6 +7,7 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; use Tests\E2E\Client; use Utopia\Database\Database; +use function array_merge; class DatabaseCustomServerTest extends Scope { @@ -136,6 +137,21 @@ class DatabaseCustomServerTest extends Scope ]); $this->assertEquals($response['headers']['status-code'], 400); + + // This collection already exists + $response = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'name' => 'Test 1', + 'collectionId' => 'first', + 'read' => ['role:all'], + 'write' => ['role:all'], + 'permission' => 'document' + ]); + + $this->assertEquals($response['headers']['status-code'], 409); } public function testDeleteAttribute(): array From 2f75f9d13de1f056d28996c4921f1dc5e8d7c9fd Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Wed, 12 Jan 2022 20:54:19 +0100 Subject: [PATCH 02/35] Removed leftover --- tests/e2e/Services/Database/DatabaseCustomServerTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index cd14974c6c..117ca960d4 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -7,7 +7,6 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; use Tests\E2E\Client; use Utopia\Database\Database; -use function array_merge; class DatabaseCustomServerTest extends Scope { From c57fe89b3be4c3b775f28f6126ef13b959aad511 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Sat, 15 Jan 2022 11:18:16 +0000 Subject: [PATCH 03/35] fix: upgrade chart.js from 3.6.2 to 3.7.0 Snyk has created this PR to upgrade chart.js from 3.6.2 to 3.7.0. See this package in npm: https://www.npmjs.com/package/chart.js See this project in Snyk: https://app.snyk.io/org/eldadfux/project/8574b5e4-6e89-4ade-bc02-2eaabc43eed0?utm_source=github&utm_medium=referral&page=upgrade-pr --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4d6acc54bc..414dafb806 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "license": "BSD-3-Clause", "dependencies": { - "chart.js": "^3.6.2", + "chart.js": "^3.7.0", "markdown-it": "^12.3.0", "pell": "^1.0.6", "prismjs": "^1.25.0", @@ -549,9 +549,9 @@ } }, "node_modules/chart.js": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.2.tgz", - "integrity": "sha512-Xz7f/fgtVltfQYWq0zL1Xbv7N2inpG+B54p3D5FSvpCdy3sM+oZhbqa42eNuYXltaVvajgX5UpKCU2GeeJIgxg==" + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.7.0.tgz", + "integrity": "sha512-31gVuqqKp3lDIFmzpKIrBeum4OpZsQjSIAqlOpgjosHDJZlULtvwLEZKtEhIAZc7JMPaHlYMys40Qy9Mf+1AAg==" }, "node_modules/chokidar": { "version": "2.1.8", @@ -5484,9 +5484,9 @@ "dev": true }, "chart.js": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.6.2.tgz", - "integrity": "sha512-Xz7f/fgtVltfQYWq0zL1Xbv7N2inpG+B54p3D5FSvpCdy3sM+oZhbqa42eNuYXltaVvajgX5UpKCU2GeeJIgxg==" + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.7.0.tgz", + "integrity": "sha512-31gVuqqKp3lDIFmzpKIrBeum4OpZsQjSIAqlOpgjosHDJZlULtvwLEZKtEhIAZc7JMPaHlYMys40Qy9Mf+1AAg==" }, "chokidar": { "version": "2.1.8", diff --git a/package.json b/package.json index 9b0ba21e17..d22cc18e1b 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "gulp-less": "^5.0.0" }, "dependencies": { - "chart.js": "^3.6.2", + "chart.js": "^3.7.0", "markdown-it": "^12.3.0", "pell": "^1.0.6", "prismjs": "^1.25.0", From 5a0559096658574dae6814dfcf1d1969e8b05b82 Mon Sep 17 00:00:00 2001 From: Vincent Ge Date: Mon, 17 Jan 2022 15:03:39 -0500 Subject: [PATCH 04/35] adds Chinese translations to README --- README-CN.md | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 README-CN.md diff --git a/README-CN.md b/README-CN.md new file mode 100644 index 0000000000..90283042b7 --- /dev/null +++ b/README-CN.md @@ -0,0 +1,169 @@ +
+

+ Appwrite Logo +
+
+ 适用于[Flutter/Vue/Angular/React/iOS/Android/* 等等平台 *]的完整后端服务 +
+
+

+ + +[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord?r=Github) +[![Docker Pulls](https://img.shields.io/docker/pulls/appwrite/appwrite?color=f02e65&style=flat-square)](https://hub.docker.com/r/appwrite/appwrite) +[![Build Status](https://img.shields.io/travis/com/appwrite/appwrite?style=flat-square)](https://travis-ci.com/appwrite/appwrite) +[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) +[![翻译](https://img.shields.io/badge/translate-f02e65?style=flat-square)](docs/tutorials/add-translations.md) +[![周边商店](https://img.shields.io/badge/swag%20store-f02e65?style=flat-square)](https://store.appwrite.io) + +Appwrite 是一个可应用于网页,移动,和后端开发的端到端后端平台, 以一系列 Docker 容器化的微服务形式包装发行。Appwrite 以高度抽象化的界面简化了从零编写 API 的繁琐过程,在保证软件安全的前提下给开发者一个高效的开发过程。 + +Appwrite 可以提供给开发者用户验证,外部授权,用户数据读写检索,文件储存, 图像处理,云函数计算,[等多种服务](https:/ /appwrite.io/docs)。 + +![Appwrite](public/images/github.png) + +更多信息请到 Appwrite 官网查看: [https://appwrite.io](https://appwrite.io) + +内容: + +- [安装](#安装) + - [Unix](#unix) + - [Windows](#windows) + - [CMD](#cmd) + - [PowerShell](#powershell) + - [从旧版本升级](#从旧版本升级) +- [快速入门](#入门) + - [软件服务](#软件服务) + - [开发套件](#开发套件) + - [客户端](#客户端) + - [服务器](#服务器) + - [开发者社区](#开发者社区) +- [软件架构]](#软件架构) +- [贡献代码](#贡献代码) +- [安全](#安全) +- [订阅我们](#订阅我们) +- [版权说明](#版权说明) + +## 安装 + +Appwrite 的容器化服务器只需要一行指令就可以运行。您可以使用 docker-compose 在本地主机上运行 Appwrite,也可以在任何其他容器化工具(如 Kubernetes、Docker Swarm 或 Rancher)上运行 Appwrite。 + +开始运行 Appwrite 服务器的最简单方法是运行我们的 docker-compose 文件。在运行安装命令之前,请确保您的机器上安装了 [Docker](https://dockerdocs.cn/get-docker/index.html): + +### Unix + +```bash +docker run -it --rm \ + --volume /var/run/docker.sock:/var/run/docker.sock \ + --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ + --entrypoint="install" \ + appwrite/appwrite:0.12.1 +``` + +### Windows + +#### CMD + +```cmd +docker run -it --rm ^ + --volume //var/run/docker.sock:/var/run/docker.sock ^ + --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ + --entrypoint="install" ^ + appwrite/appwrite:0.12.1 +``` + +#### PowerShell + +```powershell +docker run -it --rm , + --volume /var/run/docker.sock:/var/run/docker.sock , + --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , + --entrypoint="install" , + appwrite/appwrite:0.12.1 +``` + +运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。请注意,在非 Linux 本机主机上,安装完成后服务器可能需要几分钟才能启动。 + + +需要自定义容器构架,请查看我们的 Docker [环境变量](https://appwrite.io/docs/environment-variables) 文档。您还可以参考我们的 [docker-compose.yml](https://gist.github.com/eldadfux/977869ff6bdd7312adfd4e629ee15cc5#file-docker-compose-yml) 文件手动设置环境。 + +### 从旧版本升级 + +如果您从旧版本升级 Appwrite 服务器,则应在设置完成后使用 Appwrite 迁移工具。有关这方面的更多信息,请查看 [安装文档](https://appwrite.io/docs/installation)。 + +## 入门 + +开始使用 Appwrite 只需要在控制台创建一个新项目,选择开发平台,然后抓取我们的开发套件。您可以从以下的教程中找到你喜欢的平台开始使用 Appwrite。 + +* [开始使用 Web](https://appwrite.io/docs/getting-started-for-web) +* [开始使用 Flutter](https://appwrite.io/docs/getting-started-for-flutter) +* [开始使用 Apple](https://appwrite.io/docs/getting-started-for-apple) +* [开始使用 Android](https://appwrite.io/docs/getting-started-for-android) +* [开始使用 Server](https://appwrite.io/docs/getting-started-for-server) +* [开始使用 CLI](https://appwrite.io/docs/command-line) + +### 软件服务 + +* [**帐户**](https://appwrite.io/docs/client/account) -管理当前用户的帐户和登录方式。跟踪和管理用户 Session, 的名号,登录设备,登录方法和记录。 +* [**用户**](https://appwrite.io/docs/server/users) - 在以管理员模式登录时管理和列出所有用户。 +* [**团队**](https://appwrite.io/docs/client/teams) - 管理用户分组。管理团队中的成员权限,邀请,和用户角色。 +* [**数据库**](https://appwrite.io/docs/client/database) - 管理数据库文档和文档集。用检索界面来对文档和文档集进行读取,创建,更新,和删除。 +* [**贮存**](https://appwrite.io/docs/client/storage) - 管理文件的阅读、创建、删除和预览。设置文件的预览来满足程序的个性化需求。所有文件都由 ClamAV 扫描并安全存储和加密。 +* [**云函数**](https://appwrite.io/docs/server/functions) - 在安全,隔离的环境中运行自定义代码。这些代码可以被事件,CRON,或者手动操作触发。 +* [**语言适配**](https://appwrite.io/docs/client/locale) - 根据用户所在的的国家和地区做出合适的语言适配。 +* [**头像**](https://appwrite.io/docs/client/avatars) -管理用户头像、国家旗帜、浏览器图标、信用卡符号,和生成二维码。 +如需完整的 API 界面文档,请访问 [https://appwrite.io/docs](https://appwrite.io/docs)。如需更多教程、新闻和公告,请订阅我们的 [博客](https://medium.com/appwrite-io) 和 加入我们的[Discord 社区](https://discord.gg/GSeTUeA)。 + +### 开发套件 + +以下是当前支持的平台和语言列表。如果您想帮助我们为您选择的平台添加支持,您可以访问我们的 [SDK 生成器](https://github.com/appwrite/sdk-generator) 项目并查看我们的 [贡献指南]( https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md)。 + +#### 客户端 +* ✅   [Web](https://github.com/appwrite/sdk-for-web) (由 Appwrite 团队维护) +* ✅   [Flutter](https://github.com/appwrite/sdk-for-flutter) (由 Appwrite 团队维护) +* ✅   [Apple](https://github.com/appwrite/sdk-for-apple) - **公侧** (由 Appwrite 团队维护) +* ✅   [Android](https://github.com/appwrite/sdk-for-android) (由 Appwrite 团队维护) + +#### 服务器 +* ✅   [NodeJS](https://github.com/appwrite/sdk-for-node) (由 Appwrite 团队维护) +* ✅   [PHP](https://github.com/appwrite/sdk-for-php) (由 Appwr实验 团队维护) +* ✅   [Dart](https://github.com/appwrite/sdk-for-dart) - (由 Appwrite 团队维护) +* ✅   [Deno](https://github.com/appwrite/sdk-for-deno) - **公侧** (由 Appwrite 团队维护) +* ✅   [Ruby](https://github.com/appwrite/sdk-for-ruby) (由 Appwrite 团队维护) +* ✅   [Python](https://github.com/appwrite/sdk-for-python) (由 Appwrite 团队维护) +* ✅   [Kotlin](https://github.com/appwrite/sdk-for-kotlin) - **公侧** (由 Appwrite 团队维护) +* ✅   [Apple](https://github.com/appwrite/sdk-for-apple) - **公侧** (由 Appwrite 团队维护) +* ✅   [.NET](https://github.com/appwrite/sdk-for-dotnet) - **公侧** (由 Appwrite 团队维护) + +#### 开发者社区 +* ✅   [Appcelerator Titanium](https://github.com/m1ga/ti.appwrite) (维护者 [Michael Gangolf](https://github.com/m1ga/)) +* ✅   [Godot Engine](https://github.com/GodotNuts/appwrite-sdk) (维护者 [fenix-hub @GodotNuts](https://github.com/fenix-hub)) + +找不到需要的的 SDK? - 欢迎通过发起PR来帮助我们完善Appwrite的软件生态环境 [SDK 生成器](https://github.com/appwrite/sdk-generator)! + + +## 软件架构 + +![Appwrite 软件架构](docs/specs/overview.drawio.svg) + +Appwrite 使用高拓展性的微服务架构。此外,Appwrite 支持多种 API(REST、WebSocket 和 即将推出的 GraphQL),来迎合您的个性化开发习惯。 + +Appwrite API 界面层利用后台缓存和任务委派来提供极地的反应时间。后台的 Worker 代理还允许您使用消息队列来处理负载,并精确控制硬件合理分配和成本。您可以在 [贡献指南](CONTRIBUTING.md#architecture-1) 中了解有关我们架构的更多信息。 + +## 贡献代码 + +所有代码贡献 - 包括来自具有直接提交更改权限的贡献者 - 都必须提交PR请求并在合并分支之前得到核心开发人员的批准。这是为了确保正确审查所有代码。 + +我们欢迎所有人提交PR!如果您愿意提供帮助,可以在 [贡献指南](CONTRIBUTING.md) 中了解有关如何为项目做出贡献的更多信息。 + +## 安全 + +对于安全问题,请发送电子邮件至 [security@appwrite.io](mailto:security@appwrite.io),而不是在 GitHub 上发布公开问题。 + +## 订阅我们 + +加入我们在世界各地不断发展的社区!请参阅我们的官方 [博客](https://medium.com/appwrite-io)。在 [Twitter](https://twitter.com/appwrite)、[Facebook 页面](https://www.facebook.com/appwrite.io)、[Facebook 群组](https://www.facebook)、[开发者社区](https://dev.to/appwrite) 等平台订阅我们或加入我们的 [Discord 社区](https://discord.gg/GSeTUeA) 以获得更多帮助,想法和讨论。 + +## 版权说明 + +版权详情,访问 [BSD 3-Clause License](./LICENSE)。 \ No newline at end of file From 4a2614ad05478e32800203cdb9e9ec266c422f39 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Jan 2022 17:39:47 +1300 Subject: [PATCH 05/35] Fix V08 response filter fallthrough --- app/controllers/general.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index 8b0fbf8e09..7f82c36a30 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -167,6 +167,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons break; case version_compare ($responseFormat , '0.8.0', '<=') : Response::setFilter(new V08()); + break; case version_compare ($responseFormat , '0.11.0', '<=') : Response::setFilter(new V11()); break; From d8a9003714306c5e1484afa7d48844b52dcd3546 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 18 Jan 2022 07:21:03 +0200 Subject: [PATCH 06/35] Updated password length min requirment in the console --- app/views/console/users/index.phtml | 2 +- app/views/home/auth/recovery/reset.phtml | 4 ++-- app/views/home/auth/signin.phtml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/console/users/index.phtml b/app/views/console/users/index.phtml index b55917eb5c..607e4d3586 100644 --- a/app/views/console/users/index.phtml +++ b/app/views/console/users/index.phtml @@ -174,7 +174,7 @@ $smtpEnabled = $this->getParam('smtpEnabled', false); - +
diff --git a/app/views/home/auth/recovery/reset.phtml b/app/views/home/auth/recovery/reset.phtml index 6ccefc419c..9d27f22e34 100644 --- a/app/views/home/auth/recovery/reset.phtml +++ b/app/views/home/auth/recovery/reset.phtml @@ -28,10 +28,10 @@ - + - + diff --git a/app/views/home/auth/signin.phtml b/app/views/home/auth/signin.phtml index fc21da1de8..7586b3ddf3 100644 --- a/app/views/home/auth/signin.phtml +++ b/app/views/home/auth/signin.phtml @@ -37,7 +37,7 @@ $root = ($this->getParam('root') !== 'disabled'); - + From 0f209f8430a2cf6112dec13ba78e758e3fe6e690 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Jan 2022 19:38:10 +1300 Subject: [PATCH 07/35] Fix function authorization exception when missing permission --- app/controllers/api/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index f56a9e3a8c..a64c47597a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -714,7 +714,7 @@ App::post('/v1/functions/:functionId/executions') throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); } - $validator = new Authorization($function, 'execute'); + $validator = new Authorization('execute'); if (!$validator->isValid($function->getAttribute('execute'))) { // Check if user has write access to execute function throw new Exception($validator->getDescription(), 401); From 219e31483476145c89dd7bc8c9828572570cd7f1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Jan 2022 20:04:36 +1300 Subject: [PATCH 08/35] Add unauthorized test --- .../Functions/FunctionsCustomClientTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 264fae0735..8a55a0ded4 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -218,6 +218,32 @@ class FunctionsCustomClientTest extends Scope ]; } + public function testCreateExecutionUnauthorized():array + { + $function = $this->client->call(Client::METHOD_POST, '/functions', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'functionId' => 'unique()', + 'name' => 'Test', + 'execute' => [], + 'runtime' => 'php-8.0', + 'timeout' => 10, + ]); + + $execution = $this->client->call(Client::METHOD_POST, '/functions/'.$function['body']['$id'].'/executions', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], [ + 'async' => 1, + ]); + + $this->assertEquals(401, $execution['headers']['status-code']); + + return []; + } + /** * @depends testCreateCustomExecution */ From 1a6a1498bc80c831e30db5867aa1704d3b9c4b07 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 19 Jan 2022 00:45:44 +1300 Subject: [PATCH 09/35] Add fulltext index for collections collection `name` column to fix `listCollections` search --- app/config/collections.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/config/collections.php b/app/config/collections.php index abcdec9c1d..0138756177 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -102,6 +102,13 @@ $collections = [ 'lengths' => [1024], 'orders' => [Database::ORDER_ASC], ], + [ + '$id' => '_fulltext_name', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['name'], + 'lengths' => [256], + 'orders' => [Database::ORDER_ASC], + ], ], ], From 1311aa35a237aa4dc4651759f60ac2dd554e284d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jan 2022 13:35:12 +0000 Subject: [PATCH 10/35] chore(deps): bump markdown-it from 12.3.0 to 12.3.2 Bumps [markdown-it](https://github.com/markdown-it/markdown-it) from 12.3.0 to 12.3.2. - [Release notes](https://github.com/markdown-it/markdown-it/releases) - [Changelog](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md) - [Commits](https://github.com/markdown-it/markdown-it/compare/12.3.0...12.3.2) --- updated-dependencies: - dependency-name: markdown-it dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 414dafb806..8f1340f9b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "BSD-3-Clause", "dependencies": { "chart.js": "^3.7.0", - "markdown-it": "^12.3.0", + "markdown-it": "^12.3.2", "pell": "^1.0.6", "prismjs": "^1.25.0", "turndown": "^7.1.1" @@ -2862,9 +2862,9 @@ } }, "node_modules/markdown-it": { - "version": "12.3.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.0.tgz", - "integrity": "sha512-T345UZZ6ejQWTjG6PSEHplzNy5m4kF6zvUpHVDv8Snl/pEU0OxIK0jGg8YLVNwJvT8E0YJC7/2UvssJDk/wQCQ==", + "version": "12.3.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", + "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", "dependencies": { "argparse": "^2.0.1", "entities": "~2.1.0", @@ -7413,9 +7413,9 @@ } }, "markdown-it": { - "version": "12.3.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.0.tgz", - "integrity": "sha512-T345UZZ6ejQWTjG6PSEHplzNy5m4kF6zvUpHVDv8Snl/pEU0OxIK0jGg8YLVNwJvT8E0YJC7/2UvssJDk/wQCQ==", + "version": "12.3.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", + "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", "requires": { "argparse": "^2.0.1", "entities": "~2.1.0", diff --git a/package.json b/package.json index d22cc18e1b..2a95fbed23 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "chart.js": "^3.7.0", - "markdown-it": "^12.3.0", + "markdown-it": "^12.3.2", "pell": "^1.0.6", "prismjs": "^1.25.0", "turndown": "^7.1.1" From 61131434cbe754a94b8b529e52b68094c4e3f6f0 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 18 Jan 2022 16:25:14 +0200 Subject: [PATCH 11/35] Updated to use minlength and fixed alt attribute --- app/views/console/users/index.phtml | 2 +- app/views/home/auth/recovery/reset.phtml | 4 ++-- app/views/home/auth/signin.phtml | 2 +- app/views/home/auth/signup.phtml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/console/users/index.phtml b/app/views/console/users/index.phtml index 607e4d3586..e0a0306f05 100644 --- a/app/views/console/users/index.phtml +++ b/app/views/console/users/index.phtml @@ -174,7 +174,7 @@ $smtpEnabled = $this->getParam('smtpEnabled', false); - +
diff --git a/app/views/home/auth/recovery/reset.phtml b/app/views/home/auth/recovery/reset.phtml index 9d27f22e34..de67823513 100644 --- a/app/views/home/auth/recovery/reset.phtml +++ b/app/views/home/auth/recovery/reset.phtml @@ -28,10 +28,10 @@ - + - + diff --git a/app/views/home/auth/signin.phtml b/app/views/home/auth/signin.phtml index 7586b3ddf3..98cb513358 100644 --- a/app/views/home/auth/signin.phtml +++ b/app/views/home/auth/signin.phtml @@ -37,7 +37,7 @@ $root = ($this->getParam('root') !== 'disabled'); - + diff --git a/app/views/home/auth/signup.phtml b/app/views/home/auth/signup.phtml index 9aecea62b5..817e1d75f1 100644 --- a/app/views/home/auth/signup.phtml +++ b/app/views/home/auth/signup.phtml @@ -46,7 +46,7 @@ $root = ($this->getParam('root') !== 'disabled'); - +
From 51585b29c545f94190c9903588478711fc4bb1b4 Mon Sep 17 00:00:00 2001 From: Vincent Ge Date: Tue, 18 Jan 2022 11:33:38 -0500 Subject: [PATCH 12/35] corrected translation issues found by Adam Yang --- README-CN.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README-CN.md b/README-CN.md index 90283042b7..1bf6db365f 100644 --- a/README-CN.md +++ b/README-CN.md @@ -104,9 +104,9 @@ docker run -it --rm , ### 软件服务 -* [**帐户**](https://appwrite.io/docs/client/account) -管理当前用户的帐户和登录方式。跟踪和管理用户 Session, 的名号,登录设备,登录方法和记录。 +* [**帐户**](https://appwrite.io/docs/client/account) -管理当前用户的帐户和登录方式。跟踪和管理用户 Session,登录设备,登录方法和查看相关记录。 * [**用户**](https://appwrite.io/docs/server/users) - 在以管理员模式登录时管理和列出所有用户。 -* [**团队**](https://appwrite.io/docs/client/teams) - 管理用户分组。管理团队中的成员权限,邀请,和用户角色。 +* [**团队**](https://appwrite.io/docs/client/teams) - 管理用户分组。邀请成员,管理团队中的用户权限和用户角色。 * [**数据库**](https://appwrite.io/docs/client/database) - 管理数据库文档和文档集。用检索界面来对文档和文档集进行读取,创建,更新,和删除。 * [**贮存**](https://appwrite.io/docs/client/storage) - 管理文件的阅读、创建、删除和预览。设置文件的预览来满足程序的个性化需求。所有文件都由 ClamAV 扫描并安全存储和加密。 * [**云函数**](https://appwrite.io/docs/server/functions) - 在安全,隔离的环境中运行自定义代码。这些代码可以被事件,CRON,或者手动操作触发。 @@ -121,19 +121,19 @@ docker run -it --rm , #### 客户端 * ✅   [Web](https://github.com/appwrite/sdk-for-web) (由 Appwrite 团队维护) * ✅   [Flutter](https://github.com/appwrite/sdk-for-flutter) (由 Appwrite 团队维护) -* ✅   [Apple](https://github.com/appwrite/sdk-for-apple) - **公侧** (由 Appwrite 团队维护) +* ✅   [Apple](https://github.com/appwrite/sdk-for-apple) - **公测** (由 Appwrite 团队维护) * ✅   [Android](https://github.com/appwrite/sdk-for-android) (由 Appwrite 团队维护) #### 服务器 * ✅   [NodeJS](https://github.com/appwrite/sdk-for-node) (由 Appwrite 团队维护) * ✅   [PHP](https://github.com/appwrite/sdk-for-php) (由 Appwr实验 团队维护) * ✅   [Dart](https://github.com/appwrite/sdk-for-dart) - (由 Appwrite 团队维护) -* ✅   [Deno](https://github.com/appwrite/sdk-for-deno) - **公侧** (由 Appwrite 团队维护) +* ✅   [Deno](https://github.com/appwrite/sdk-for-deno) - **公测** (由 Appwrite 团队维护) * ✅   [Ruby](https://github.com/appwrite/sdk-for-ruby) (由 Appwrite 团队维护) * ✅   [Python](https://github.com/appwrite/sdk-for-python) (由 Appwrite 团队维护) -* ✅   [Kotlin](https://github.com/appwrite/sdk-for-kotlin) - **公侧** (由 Appwrite 团队维护) -* ✅   [Apple](https://github.com/appwrite/sdk-for-apple) - **公侧** (由 Appwrite 团队维护) -* ✅   [.NET](https://github.com/appwrite/sdk-for-dotnet) - **公侧** (由 Appwrite 团队维护) +* ✅   [Kotlin](https://github.com/appwrite/sdk-for-kotlin) - **公测** (由 Appwrite 团队维护) +* ✅   [Apple](https://github.com/appwrite/sdk-for-apple) - **公测** (由 Appwrite 团队维护) +* ✅   [.NET](https://github.com/appwrite/sdk-for-dotnet) - **公测** (由 Appwrite 团队维护) #### 开发者社区 * ✅   [Appcelerator Titanium](https://github.com/m1ga/ti.appwrite) (维护者 [Michael Gangolf](https://github.com/m1ga/)) @@ -148,7 +148,7 @@ docker run -it --rm , Appwrite 使用高拓展性的微服务架构。此外,Appwrite 支持多种 API(REST、WebSocket 和 即将推出的 GraphQL),来迎合您的个性化开发习惯。 -Appwrite API 界面层利用后台缓存和任务委派来提供极地的反应时间。后台的 Worker 代理还允许您使用消息队列来处理负载,并精确控制硬件合理分配和成本。您可以在 [贡献指南](CONTRIBUTING.md#architecture-1) 中了解有关我们架构的更多信息。 +Appwrite API 界面层利用后台缓存和任务委派来提供极速的响应时间。后台的 Worker 代理还允许您使用消息队列来处理负载,并精确控制硬件合理分配和成本。您可以在 [贡献指南](CONTRIBUTING.md#architecture-1) 中了解有关我们架构的更多信息。 ## 贡献代码 From fc99863ba649739c4d7a9a7d63598a09bb230e47 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 18 Jan 2022 23:41:51 +0100 Subject: [PATCH 13/35] ci: add github action --- .../workflows/{tests.yml.tmp => tests.yml} | 29 ++++--- .travis-ci/build.sh | 29 ------- .travis-ci/deploy.sh | 1 - .travis.yml | 87 ------------------- 4 files changed, 17 insertions(+), 129 deletions(-) rename .github/workflows/{tests.yml.tmp => tests.yml} (69%) delete mode 100644 .travis-ci/build.sh delete mode 100644 .travis-ci/deploy.sh delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml.tmp b/.github/workflows/tests.yml similarity index 69% rename from .github/workflows/tests.yml.tmp rename to .github/workflows/tests.yml index 29bd70ec83..0a81553df0 100644 --- a/.github/workflows/tests.yml.tmp +++ b/.github/workflows/tests.yml @@ -1,10 +1,9 @@ name: "Tests" - on: [pull_request] jobs: tests: name: Unit & E2E - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout repository @@ -19,16 +18,28 @@ jobs: - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} - - name: Build Appwrite - # Upstream bug causes buildkit pulls to fail so prefetch base images - # https://github.com/moby/moby/issues/41864 + - name: Prepare Docker run: | + export COMPOSE_INTERACTIVE_NO_CLI + export DOCKER_BUILDKIT=1 + export COMPOSE_DOCKER_CLI_BUILD=1 echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env docker pull composer:2.0 docker pull php:8.0-cli-alpine - docker compose build --progress=plain + docker compose pull + + - uses: satackey/action-docker-layer-caching@v0.0.11 + # Ignore the failure of a step and avoid terminating the job. + continue-on-error: true + + - name: Build Appwrite + run: docker compose build --progress=plain appwrite + + - name: Start Appwrite + run: | docker compose up -d sleep 30 + - name: Doctor run: docker compose exec -T appwrite doctor @@ -37,9 +48,3 @@ jobs: - name: Run Tests run: docker compose exec -T appwrite test --debug - - - name: Teardown - if: always() - run: | - docker compose down -v - docker ps -aq | xargs docker rm --force diff --git a/.travis-ci/build.sh b/.travis-ci/build.sh deleted file mode 100644 index 57aa5ca110..0000000000 --- a/.travis-ci/build.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash bash - -RED='\033[0;31m' -NC='\033[0m' # No Color - -if [ -z "$1" ] -then - echo "Missing tag number" - exit 1 -fi - -if [ -z "$2" ] -then - echo "Missing version number" - exit 1 -fi - -if test $(find "./app/db/DBIP/dbip-country-lite-2021-12.mmdb" -mmin +259200) -then - printf "${RED}GEO country DB has not been updated for more than 6 months. Go to https://db-ip.com/db/download/ip-to-country-lite to download a newer version${NC}\n" -fi - -echo 'Starting build...' - -docker build --build-arg VERSION="$2" --tag appwrite/appwrite:"$1" . - -echo 'Pushing build to registry...' - -docker push appwrite/appwrite:"$1" diff --git a/.travis-ci/deploy.sh b/.travis-ci/deploy.sh deleted file mode 100644 index b4c132022a..0000000000 --- a/.travis-ci/deploy.sh +++ /dev/null @@ -1 +0,0 @@ -echo 'Nothing to deploy right now.' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da5897dec5..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,87 +0,0 @@ -dist: focal - -arch: - - amd64 - -os: linux - -vm: - size: large - -language: shell - -notifications: - email: - - team@appwrite.io - -before_install: -# Install latest Docker -- curl -fsSL https://get.docker.com | sh -# Enable Buildkit in Docker config -- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json -- mkdir -p $HOME/.docker -- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json -- sudo service docker start -# Login to increase Docker Hub ratelimit -- > - if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then - echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin - fi -- docker --version -# Install latest Compose -- sudo rm /usr/local/bin/docker-compose -- curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > docker-compose -- chmod +x docker-compose -- sudo mv docker-compose /usr/local/bin -- docker-compose --version -# Enable Buildkit -- docker buildx create --name travis_builder --use -- export COMPOSE_INTERACTIVE_NO_CLI -- export DOCKER_BUILDKIT=1 -- export COMPOSE_DOCKER_CLI_BUILD=1 -- export BUILDKIT_PROGRESS=plain -# Only pass a single runtime for CI stability -- echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env -# Ensure Travis scripts are executable -- chmod -R u+x ./.travis-ci - -install: -- docker-compose pull -# Upstream bug causes buildkit pulls to fail so prefetch base images -# https://github.com/moby/moby/issues/41864 -- docker pull composer:2.0 -- docker pull php:8.0-cli-alpine -- docker-compose build -- docker-compose up -d -- sleep 60 - -script: -- docker ps -a -# Tests should fail if any container is in exited status -# - ALL_UP=`docker ps -aq --filter "status=exited"` -# - > -# if [[ "$ALL_UP" != "" ]]; then -# exit 1 -# fi -- docker-compose logs appwrite -- docker-compose logs appwrite-realtime -- docker-compose logs mariadb -- docker-compose logs appwrite-worker-functions -- docker-compose exec appwrite doctor -- docker-compose exec appwrite vars -- docker-compose exec appwrite test --debug - -after_script: -# travis re-uses their build nodes so clean them up -- docker buildx rm travis_builder - -after_failure: -- docker-compose logs appwrite - -deploy: - - provider: script - edge: true - script: ./.travis-ci/deploy.sh - on: - repo: appwrite/appwrite - branch: deploy From 7a9d477e3ea35753f01dbed613f816d192a638e4 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 18 Jan 2022 23:58:24 +0100 Subject: [PATCH 14/35] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a81553df0..8507ac69f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: continue-on-error: true - name: Build Appwrite - run: docker compose build --progress=plain appwrite + run: docker compose build --progress=plain - name: Start Appwrite run: | From c9d53e01341388b8f9f0f2d3d6980de13a99a185 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 19 Jan 2022 00:02:48 +0100 Subject: [PATCH 15/35] Update tests.yml --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8507ac69f4..bff77612f1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,8 @@ jobs: docker pull php:8.0-cli-alpine docker compose pull - - uses: satackey/action-docker-layer-caching@v0.0.11 + - name: Prepare Cache + uses: satackey/action-docker-layer-caching@v0.0.11 # Ignore the failure of a step and avoid terminating the job. continue-on-error: true From e45fc7c46ec4c04e18731d72a56a1fa16f229089 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 19 Jan 2022 00:23:19 +0100 Subject: [PATCH 16/35] Update Scope.php --- tests/e2e/Scopes/Scope.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index b5b5e0e775..079777be4c 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -33,7 +33,7 @@ abstract class Scope extends TestCase protected function getLastEmail():array { - sleep(5); + sleep(3); $emails = json_decode(file_get_contents('http://maildev:1080/email'), true); @@ -46,7 +46,7 @@ abstract class Scope extends TestCase protected function getLastRequest():array { - sleep(5); + sleep(2); $resquest = json_decode(file_get_contents('http://request-catcher:5000/__last_request__'), true); $resquest['data'] = json_decode($resquest['data'], true); @@ -167,4 +167,4 @@ abstract class Scope extends TestCase return self::$user[$this->getProject()['$id']]; } -} \ No newline at end of file +} From 88f43c32a4350640675a47d0e2a59b7d9780241c Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Tue, 7 Dec 2021 00:01:09 -0800 Subject: [PATCH 17/35] Fix non-owner not able to delete their membership --- app/controllers/api/teams.php | 9 ++- tests/e2e/Services/Teams/TeamsBaseClient.php | 71 ++++++++++++++++++-- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index ab5534edc6..b319bb04d6 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -16,6 +16,7 @@ use Utopia\Validator\ArrayList; use Utopia\Validator\WhiteList; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Duplicate; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; @@ -761,7 +762,11 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId') throw new Exception('Team not found', 404); } - if (!$dbForProject->deleteDocument('memberships', $membership->getId())) { + try { + $dbForProject->deleteDocument('memberships', $membership->getId()); + } catch (AuthorizationException $exception) { + throw new Exception('Unauthorized permissions', 401); + } catch (\Exception $exception) { throw new Exception('Failed to remove membership from DB', 500); } @@ -782,7 +787,7 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId') if ($membership->getAttribute('confirm')) { // Count only confirmed members $team->setAttribute('sum', \max($team->getAttribute('sum', 0) - 1, 0)); - $team = $dbForProject->updateDocument('teams', $team->getId(), $team); + Authorization::skip(fn() => $dbForProject->updateDocument('teams', $team->getId(), $team)); } $audits diff --git a/tests/e2e/Services/Teams/TeamsBaseClient.php b/tests/e2e/Services/Teams/TeamsBaseClient.php index 89ac02da74..e03ce89a9c 100644 --- a/tests/e2e/Services/Teams/TeamsBaseClient.php +++ b/tests/e2e/Services/Teams/TeamsBaseClient.php @@ -391,11 +391,75 @@ trait TeamsBaseClient { $teamUid = $data['teamUid'] ?? ''; $membershipUid = $data['membershipUid'] ?? ''; + $session = $data['session'] ?? ''; + + $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals(2, $response['body']['sum']); + $ownerMembershipUid = $response['body']['memberships'][0]['$id']; + + /** + * Test for FAILURE + */ + + /** + * Test deleting a membership that does not exists + */ + $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/dne', [ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$session, + ]); + + $this->assertEquals(404, $response['headers']['status-code']); + + /** + * Test deleting another user's membership + */ + $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/'.$ownerMembershipUid, [ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$session, + ]); + + $this->assertEquals(401, $response['headers']['status-code']); + /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/'.$membershipUid, array_merge([ + + /** + * Test for when a user other than the owner tries to delete their membership + */ + $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/'.$membershipUid, [ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$session, + ]); + + $this->assertEquals(204, $response['headers']['status-code']); + $this->assertEmpty($response['body']); + + $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals(1, $response['body']['sum']); + + /** + * Test for when the owner tries to delete their membership + */ + $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/'.$ownerMembershipUid, array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -404,10 +468,7 @@ trait TeamsBaseClient $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - /** - * Test for FAILURE - */ - $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships/'.$membershipUid, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships/'.$ownerMembershipUid, array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], From 438f80cc5a2d6457b585280fb61e0c6f69beddb7 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 19 Jan 2022 20:57:18 +1300 Subject: [PATCH 18/35] Update query attribute to search, remove name index --- app/config/collections.php | 7 ------- app/controllers/api/database.php | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 0138756177..abcdec9c1d 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -102,13 +102,6 @@ $collections = [ 'lengths' => [1024], 'orders' => [Database::ORDER_ASC], ], - [ - '$id' => '_fulltext_name', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], ], ], diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index a25e5e62ae..9d5ac716b3 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -230,7 +230,7 @@ App::get('/v1/database/collections') $queries = []; if (!empty($search)) { - $queries[] = new Query('name', Query::TYPE_SEARCH, [$search]); + $queries[] = new Query('search', Query::TYPE_SEARCH, [$search]); } $usage->setParam('database.collections.read', 1); From 06719b172cefdbbd4d15dbfcef2e7387c7c1ae7f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 19 Jan 2022 22:04:57 +1300 Subject: [PATCH 19/35] Add listCollection using `search` parameter tests --- .../Database/DatabaseCustomServerTest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 659839debe..b770b2b6c3 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -125,6 +125,39 @@ class DatabaseCustomServerTest extends Scope $this->assertCount(0, $collections['body']['collections']); $this->assertEmpty($collections['body']['collections']); + /** + * Test for Search + */ + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'first' + ]); + + $this->assertEquals(1, $collections['body']['sum']); + $this->assertEquals('first', $collections['body']['collections'][0]['$id']); + + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'Test' + ]); + + $this->assertEquals(2, $collections['body']['sum']); + $this->assertEquals('Test 1', $collections['body']['collections'][0]['name']); + $this->assertEquals('Test 2', $collections['body']['collections'][1]['name']); + + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'Nonexistent' + ]); + + $this->assertEquals(0, $collections['body']['sum']); + /** * Test for FAILURE */ From 1cf7da26d4aff9b22b7f0729b5359cc227bb59c1 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 19 Jan 2022 17:15:22 -0500 Subject: [PATCH 20/35] Test new exists behavior in database --- composer.json | 2 +- composer.lock | 44 +++++++++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index d6c0a7ff2d..016c33888b 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "utopia-php/cache": "0.4.*", "utopia-php/cli": "0.11.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.13.*", + "utopia-php/database": "dev-feat-check-if-collection-exists as 0.14.0", "utopia-php/locale": "0.4.*", "utopia-php/orchestration": "0.2.*", "utopia-php/registry": "0.5.*", diff --git a/composer.lock b/composer.lock index 62a9f81bd6..644b6bc749 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f022f43cc2d6023c3dad3805b7c4455a", + "content-hash": "f864e323b153e24e1392840eb114b951", "packages": [ { "name": "adhocore/jwt", @@ -355,16 +355,16 @@ }, { "name": "composer/package-versions-deprecated", - "version": "1.11.99.4", + "version": "1.11.99.5", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "b174585d1fe49ceed21928a945138948cb394600" + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b174585d1fe49ceed21928a945138948cb394600", - "reference": "b174585d1fe49ceed21928a945138948cb394600", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b4f54f74ef3453349c24a845d22392cd31e65f1d", + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d", "shasum": "" }, "require": { @@ -408,7 +408,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.4" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.5" }, "funding": [ { @@ -424,7 +424,7 @@ "type": "tidelift" } ], - "time": "2021-09-13T08:41:34+00:00" + "time": "2022-01-17T14:14:24+00:00" }, { "name": "dragonmantank/cron-expression", @@ -2141,16 +2141,16 @@ }, { "name": "utopia-php/database", - "version": "0.13.2", + "version": "dev-feat-check-if-collection-exists", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "bf92279b707b3a10ee5ec5df5c065023b2221357" + "reference": "49b4eef6728f44a33df2707993319a2f352e75fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/bf92279b707b3a10ee5ec5df5c065023b2221357", - "reference": "bf92279b707b3a10ee5ec5df5c065023b2221357", + "url": "https://api.github.com/repos/utopia-php/database/zipball/49b4eef6728f44a33df2707993319a2f352e75fa", + "reference": "49b4eef6728f44a33df2707993319a2f352e75fa", "shasum": "" }, "require": { @@ -2198,9 +2198,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.13.2" + "source": "https://github.com/utopia-php/database/tree/feat-check-if-collection-exists" }, - "time": "2022-01-04T10:51:22+00:00" + "time": "2022-01-19T21:01:38+00:00" }, { "name": "utopia-php/domains", @@ -3703,9 +3703,6 @@ "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" - }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", @@ -6645,9 +6642,18 @@ "time": "2015-12-17T08:42:14+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-feat-check-if-collection-exists", + "alias": "0.14.0", + "alias_normalized": "0.14.0.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -6669,5 +6675,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } From 4a8c87970661124de6f62ff54e2be4ac1c6209ae Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 19 Jan 2022 17:15:38 -0500 Subject: [PATCH 21/35] Retry database connections in realtime server --- app/realtime.php | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/app/realtime.php b/app/realtime.php index 9acb37570d..e783f166de 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -91,13 +91,34 @@ $server->error($logError); function getDatabase(Registry &$register, string $namespace) { - $db = $register->get('dbPool')->get(); - $redis = $register->get('redisPool')->get(); + $attempts = 0; + $sleep = 2; + $maxAttempts = 10; - $cache = new Cache(new RedisCache($redis)); - $database = new Database(new MariaDB($db), $cache); - $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); - $database->setNamespace($namespace); + do { + try { + $attempts++; + + $db = $register->get('dbPool')->get(); + $redis = $register->get('redisPool')->get(); + + $cache = new Cache(new RedisCache($redis)); + $database = new Database(new MariaDB($db), $cache); + $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); + $database->setNamespace($namespace); + + if (!$database->exists(App::getEnv('_APP_DB_SCHEMA', 'appwrite'), 'realtime')) { + throw new Exception('Collection not ready'); + } + break; // leave loop if successful + } catch(\Exception $e) { + Console::warning("Database not ready. Retrying connection ({$attempts})..."); + if ($attempts >= $maxAttempts) { + throw new \Exception('Failed to connect to database: '. $e->getMessage()); + } + sleep($sleep); + } + } while ($attempts < $maxAttempts); return [ $database, @@ -106,6 +127,7 @@ function getDatabase(Registry &$register, string $namespace) $register->get('redisPool')->put($redis); } ]; + }; $server->onStart(function () use ($stats, $register, $containerId, &$statsDocument, $logError) { From f5fedf05d5618bf35254c454f551760329ce5121 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 20 Jan 2022 10:55:33 +0100 Subject: [PATCH 22/35] fix: ui reset form after creating attribute --- app/views/console/database/collection.phtml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index 34b9bfa8c4..93db293ad1 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -620,6 +620,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -675,6 +676,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -739,6 +741,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -803,6 +806,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -855,6 +859,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -911,6 +916,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -963,6 +969,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -1015,6 +1022,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> From d9eb1e9545aed9e10154c3dd1b75c01339c4d5b3 Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Fri, 21 Jan 2022 09:05:41 +0100 Subject: [PATCH 23/35] Use dynamic value in controller --- app/controllers/api/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index a64c47597a..8488b341f0 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -46,7 +46,7 @@ App::post('/v1/functions') ->param('vars', [], new Assoc(), 'Key-value JSON object that will be passed to the function as environment variables.', true) ->param('events', [], new ArrayList(new WhiteList(array_keys(Config::getParam('events')), true)), 'Events list.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) - ->param('timeout', 15, new Range(1, 900), 'Function maximum execution time in seconds.', true) + ->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Function maximum execution time in seconds.', true) ->inject('response') ->inject('dbForProject') ->action(function ($functionId, $name, $execute, $runtime, $vars, $events, $schedule, $timeout, $response, $dbForProject) { @@ -294,7 +294,7 @@ App::put('/v1/functions/:functionId') ->param('vars', [], new Assoc(), 'Key-value JSON object that will be passed to the function as environment variables.', true) ->param('events', [], new ArrayList(new WhiteList(array_keys(Config::getParam('events')), true)), 'Events list.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) - ->param('timeout', 15, new Range(1, 900), 'Maximum execution time in seconds.', true) + ->param('timeout', 15, new Range(1, (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)), 'Maximum execution time in seconds.', true) ->inject('response') ->inject('dbForProject') ->inject('project') From 6715d9a00ea90b2b62dd8666c674897aabc314fa Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 21 Jan 2022 06:25:17 -0600 Subject: [PATCH 24/35] docs: update description for delete session endpoint --- docs/references/account/delete-session.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/references/account/delete-session.md b/docs/references/account/delete-session.md index e0ca6d29ac..cd1f22f627 100644 --- a/docs/references/account/delete-session.md +++ b/docs/references/account/delete-session.md @@ -1 +1 @@ -Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted. \ No newline at end of file +Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the Session ID argument, only the unique session ID provided is deleted. From a7c81c0d28f02e229ab0d90b8dbfa888c338027c Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 21 Jan 2022 11:11:39 -0500 Subject: [PATCH 25/35] Pin to patch version to avoid regressions --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f8192427d..e9e08f5a8f 100755 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ COPY public /usr/local/src/public RUN npm ci RUN npm run build -FROM php:8.0-cli-alpine as compile +FROM php:8.0.14-cli-alpine as compile ARG DEBUG=false ENV DEBUG=$DEBUG @@ -123,7 +123,7 @@ RUN \ ./configure && \ make && make install -FROM php:8.0-cli-alpine as final +FROM php:8.0.14-cli-alpine as final LABEL maintainer="team@appwrite.io" From 7566547ff38a03ad9bb261ca262f16d6b8c19171 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 21 Jan 2022 11:21:52 -0500 Subject: [PATCH 26/35] Pin alpine where possible --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e9e08f5a8f..eda20f73af 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM node:16-alpine as node +FROM node:16-alpine3.15 as node WORKDIR /usr/local/src/ @@ -24,7 +24,7 @@ COPY public /usr/local/src/public RUN npm ci RUN npm run build -FROM php:8.0.14-cli-alpine as compile +FROM php:8.0.14-cli-alpine3.15 as compile ARG DEBUG=false ENV DEBUG=$DEBUG @@ -123,7 +123,7 @@ RUN \ ./configure && \ make && make install -FROM php:8.0.14-cli-alpine as final +FROM php:8.0.14-cli-alpine3.15 as final LABEL maintainer="team@appwrite.io" From 43f65a3b2cf5d34ae0b883f982df44ff870e4a33 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 21 Jan 2022 11:31:08 -0500 Subject: [PATCH 27/35] Pin to specific node version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eda20f73af..a4ae5c1563 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM node:16-alpine3.15 as node +FROM node:16.13.2-alpine3.15 as node WORKDIR /usr/local/src/ From f7373fff2b10d8cfde1bda2e62998f71dbe2e362 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 21 Jan 2022 11:39:21 -0500 Subject: [PATCH 28/35] Update utopia/database to latest --- composer.json | 2 +- composer.lock | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 016c33888b..e7bd6646a9 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "utopia-php/cache": "0.4.*", "utopia-php/cli": "0.11.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-check-if-collection-exists as 0.14.0", + "utopia-php/database": "0.14.*", "utopia-php/locale": "0.4.*", "utopia-php/orchestration": "0.2.*", "utopia-php/registry": "0.5.*", diff --git a/composer.lock b/composer.lock index 644b6bc749..91440e4a7a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f864e323b153e24e1392840eb114b951", + "content-hash": "ab493f0a7f01a1105f8bc5caaf9b928b", "packages": [ { "name": "adhocore/jwt", @@ -2141,16 +2141,16 @@ }, { "name": "utopia-php/database", - "version": "dev-feat-check-if-collection-exists", + "version": "0.14.0", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "49b4eef6728f44a33df2707993319a2f352e75fa" + "reference": "2f2527bb080cf578fba327ea2ec637064561d403" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/49b4eef6728f44a33df2707993319a2f352e75fa", - "reference": "49b4eef6728f44a33df2707993319a2f352e75fa", + "url": "https://api.github.com/repos/utopia-php/database/zipball/2f2527bb080cf578fba327ea2ec637064561d403", + "reference": "2f2527bb080cf578fba327ea2ec637064561d403", "shasum": "" }, "require": { @@ -2198,9 +2198,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/feat-check-if-collection-exists" + "source": "https://github.com/utopia-php/database/tree/0.14.0" }, - "time": "2022-01-19T21:01:38+00:00" + "time": "2022-01-21T16:34:34+00:00" }, { "name": "utopia-php/domains", @@ -6642,18 +6642,9 @@ "time": "2015-12-17T08:42:14+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-feat-check-if-collection-exists", - "alias": "0.14.0", - "alias_normalized": "0.14.0.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 7e6c9b9d87e0348b158cc24a21034d8caf808b5a Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 21 Jan 2022 12:32:27 -0500 Subject: [PATCH 29/35] Harmonize database reconnect across services --- app/init.php | 3 +++ app/realtime.php | 10 ++++------ src/Appwrite/Resque/Worker.php | 15 +++++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/init.php b/app/init.php index 439e7cc3b1..d591d1ddbd 100644 --- a/app/init.php +++ b/app/init.php @@ -86,6 +86,9 @@ const APP_SOCIAL_DISCORD_CHANNEL = '564160730845151244'; const APP_SOCIAL_DEV = 'https://dev.to/appwrite'; const APP_SOCIAL_STACKSHARE = 'https://stackshare.io/appwrite'; const APP_SOCIAL_YOUTUBE = 'https://www.youtube.com/c/appwrite?sub_confirmation=1'; +// Database Reconnect +const DATABASE_RECONNECT_SLEEP = 2; +const DATABASE_RECONNECT_MAX_ATTEMPTS = 10; // Database Worker Types const DATABASE_TYPE_CREATE_ATTRIBUTE = 'createAttribute'; const DATABASE_TYPE_CREATE_INDEX = 'createIndex'; diff --git a/app/realtime.php b/app/realtime.php index e783f166de..b2ddf67634 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -92,8 +92,6 @@ $server->error($logError); function getDatabase(Registry &$register, string $namespace) { $attempts = 0; - $sleep = 2; - $maxAttempts = 10; do { try { @@ -107,18 +105,18 @@ function getDatabase(Registry &$register, string $namespace) $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $database->setNamespace($namespace); - if (!$database->exists(App::getEnv('_APP_DB_SCHEMA', 'appwrite'), 'realtime')) { + if (!$database->exists($database->getDefaultDatabase(), 'realtime')) { throw new Exception('Collection not ready'); } break; // leave loop if successful } catch(\Exception $e) { Console::warning("Database not ready. Retrying connection ({$attempts})..."); - if ($attempts >= $maxAttempts) { + if ($attempts >= DATABASE_RECONNECT_MAX_ATTEMPTS) { throw new \Exception('Failed to connect to database: '. $e->getMessage()); } - sleep($sleep); + sleep(DATABASE_RECONNECT_SLEEP); } - } while ($attempts < $maxAttempts); + } while ($attempts < DATABASE_RECONNECT_MAX_ATTEMPTS); return [ $database, diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index 1444c90663..b9ed5af275 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -70,9 +70,6 @@ abstract class Worker throw new Exception("Please implement getName method in worker"); } - const MAX_ATTEMPTS = 10; - const SLEEP_TIME = 2; - const DATABASE_PROJECT = 'project'; const DATABASE_CONSOLE = 'console'; @@ -174,7 +171,7 @@ abstract class Worker global $register; $namespace = ''; - $sleep = self::SLEEP_TIME; // overwritten when necessary + $sleep = DATABASE_RECONNECT_SLEEP; // overwritten when necessary switch ($type) { case self::DATABASE_PROJECT: @@ -201,18 +198,24 @@ abstract class Worker $database = new Database(new MariaDB($register->get('db')), $cache); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $database->setNamespace($namespace); // Main DB + if (!empty($projectId) && !$database->getDocument('projects', $projectId)->isEmpty()) { throw new \Exception("Project does not exist: {$projectId}"); } + + if ($type === self::DATABASE_CONSOLE && !$database->exists($database->getDefaultDatabase(), 'realtime')) { + throw new \Exception('Console project not ready'); + } + break; // leave loop if successful } catch(\Exception $e) { Console::warning("Database not ready. Retrying connection ({$attempts})..."); - if ($attempts >= self::MAX_ATTEMPTS) { + if ($attempts >= DATABASE_RECONNECT_MAX_ATTEMPTS) { throw new \Exception('Failed to connect to database: '. $e->getMessage()); } sleep($sleep); } - } while ($attempts < self::MAX_ATTEMPTS); + } while ($attempts < DATABASE_RECONNECT_MAX_ATTEMPTS); return $database; } From 7ddcf4142e3b18cd9446b6a71009c9c553ba2137 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 21 Jan 2022 12:53:13 -0500 Subject: [PATCH 30/35] Briefly sleep to give realtime a chance to disconnect --- tests/e2e/Services/Realtime/RealtimeBase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/Services/Realtime/RealtimeBase.php b/tests/e2e/Services/Realtime/RealtimeBase.php index 277537d407..4357bec383 100644 --- a/tests/e2e/Services/Realtime/RealtimeBase.php +++ b/tests/e2e/Services/Realtime/RealtimeBase.php @@ -66,6 +66,7 @@ trait RealtimeBase $this->assertEquals('error', $payload['type']); $this->assertEquals(1008, $payload['data']['code']); $this->assertEquals('Missing or unknown project ID', $payload['data']['message']); + \usleep(250000); // 250ms $this->expectException(ConnectionException::class); // Check if server disconnnected client $client->close(); } From 85630df661a0c5b28046dc1775c999c7391f7b1a Mon Sep 17 00:00:00 2001 From: Matej Baco Date: Mon, 24 Jan 2022 09:20:02 +0100 Subject: [PATCH 31/35] PR review changes --- app/controllers/api/database.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 00e951030f..a1fc91207d 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -177,12 +177,14 @@ App::post('/v1/database/collections') 'name' => $name, 'search' => implode(' ', [$collectionId, $name]), ])); + + $dbForProject->createCollection('collection_' . $collectionId); } catch (DuplicateException $th) { throw new Exception('Collection already exists', 409); + } catch (LimitException $th) { + throw new Exception('Collection limit exceeded', 400); } - $dbForProject->createCollection('collection_' . $collectionId); - $audits ->setParam('event', 'database.collections.create') ->setParam('resource', 'collection/'.$collectionId) From 2ac2c3dbd20e7a1edeaecc53f2d391794881a99e Mon Sep 17 00:00:00 2001 From: Vincent Ge Date: Mon, 24 Jan 2022 10:44:27 -0500 Subject: [PATCH 32/35] Adopted translation changes made by Yuqi --- README-CN.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README-CN.md b/README-CN.md index 1bf6db365f..8bef894c72 100644 --- a/README-CN.md +++ b/README-CN.md @@ -16,7 +16,7 @@ [![翻译](https://img.shields.io/badge/translate-f02e65?style=flat-square)](docs/tutorials/add-translations.md) [![周边商店](https://img.shields.io/badge/swag%20store-f02e65?style=flat-square)](https://store.appwrite.io) -Appwrite 是一个可应用于网页,移动,和后端开发的端到端后端平台, 以一系列 Docker 容器化的微服务形式包装发行。Appwrite 以高度抽象化的界面简化了从零编写 API 的繁琐过程,在保证软件安全的前提下给开发者一个高效的开发过程。 +Appwrite是一个基于dcoker的端到端开发者平台,其容器化的微服务库可应用于网页端,移动端,以及后端。Appwrite 通过视觉化界面极简了从零编写 API 的繁琐过程,在保证软件安全的前提下为开发者创造了一个高效的开发环境。 Appwrite 可以提供给开发者用户验证,外部授权,用户数据读写检索,文件储存, 图像处理,云函数计算,[等多种服务](https:/ /appwrite.io/docs)。 @@ -82,7 +82,7 @@ docker run -it --rm , appwrite/appwrite:0.12.1 ``` -运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。请注意,在非 Linux 本机主机上,安装完成后服务器可能需要几分钟才能启动。 +运行后,可以在浏览器上访问 http://localhost 找到 Appwrite 控制台。在非 Linux 的本机主机上完成安装后,服务器可能需要几分钟才能启动。 需要自定义容器构架,请查看我们的 Docker [环境变量](https://appwrite.io/docs/environment-variables) 文档。您还可以参考我们的 [docker-compose.yml](https://gist.github.com/eldadfux/977869ff6bdd7312adfd4e629ee15cc5#file-docker-compose-yml) 文件手动设置环境。 @@ -158,7 +158,7 @@ Appwrite API 界面层利用后台缓存和任务委派来提供极速的响应 ## 安全 -对于安全问题,请发送电子邮件至 [security@appwrite.io](mailto:security@appwrite.io),而不是在 GitHub 上发布公开问题。 +为了保护您的隐私,请避免在GitHub 上发布安全问题。发送问题至 security@appwrite.io,我们将为您做更细致的解答。 ## 订阅我们 From 7da87c0358069595e0ec9475b05cd40e1449f6e1 Mon Sep 17 00:00:00 2001 From: Vincent Ge Date: Mon, 24 Jan 2022 11:08:20 -0500 Subject: [PATCH 33/35] Translations button up top and lists available languages at bottom + link --- README-CN.md | 9 ++++++++- README.md | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README-CN.md b/README-CN.md index 8bef894c72..cdc5d90bfc 100644 --- a/README-CN.md +++ b/README-CN.md @@ -1,3 +1,6 @@ +

+ 🌍 其他语言 +


Appwrite Logo @@ -166,4 +169,8 @@ Appwrite API 界面层利用后台缓存和任务委派来提供极速的响应 ## 版权说明 -版权详情,访问 [BSD 3-Clause License](./LICENSE)。 \ No newline at end of file +版权详情,访问 [BSD 3-Clause License](./LICENSE)。 + +## 其他语言 +- [English](README.md) +- [简体中文](README-CN.md) \ No newline at end of file diff --git a/README.md b/README.md index 3670203487..71196afdc2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +

+ 🌍 Translations +


Appwrite Logo @@ -170,3 +173,7 @@ Join our growing community around the world! See our official [Blog](https://med ## License This repository is available under the [BSD 3-Clause License](./LICENSE). + +## Translations +- [English](README.md) +- [简体中文](README-CN.md) From 32b037d6aabf86519a79faddffd3973fcc83c6dc Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 24 Jan 2022 14:25:47 -0600 Subject: [PATCH 34/35] fix: update sdk to web-default for auth docs links from console --- app/config/auth.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/config/auth.php b/app/config/auth.php index 086ba9a7b2..aab6833b65 100644 --- a/app/config/auth.php +++ b/app/config/auth.php @@ -7,35 +7,35 @@ return [ 'name' => 'Email/Password', 'key' => 'emailPassword', 'icon' => '/images/users/email.png', - 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateSession', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web-default#accountCreateSession', 'enabled' => true, ], 'magic-url' => [ 'name' => 'Magic URL', 'key' => 'usersAuthMagicURL', 'icon' => '/images/users/magic-url.png', - 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateMagicURLSession', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web-default#accountCreateMagicURLSession', 'enabled' => true, ], 'anonymous' => [ 'name' => 'Anonymous', 'key' => 'anonymous', 'icon' => '/images/users/anonymous.png', - 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateAnonymousSession', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web-default#accountCreateAnonymousSession', 'enabled' => true, ], 'invites' => [ 'name' => 'Invites', 'key' => 'invites', 'icon' => '/images/users/invites.png', - 'docs' => 'https://appwrite.io/docs/client/teams?sdk=web#teamsCreateMembership', + 'docs' => 'https://appwrite.io/docs/client/teams?sdk=web-default#teamsCreateMembership', 'enabled' => true, ], 'jwt' => [ 'name' => 'JWT', 'key' => 'JWT', 'icon' => '/images/users/jwt.png', - 'docs' => 'https://appwrite.io/docs/client/account?sdk=web#accountCreateJWT', + 'docs' => 'https://appwrite.io/docs/client/account?sdk=web-default#accountCreateJWT', 'enabled' => true, ], 'phone' => [ From 5ae1da65e39db0022f31535e3d22fcc5acf48338 Mon Sep 17 00:00:00 2001 From: Vincent Ge Date: Tue, 25 Jan 2022 17:50:41 -0500 Subject: [PATCH 35/35] moved translation links to a more visible location --- README-CN.md | 11 +++-------- README.md | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/README-CN.md b/README-CN.md index cdc5d90bfc..5c4ce54433 100644 --- a/README-CN.md +++ b/README-CN.md @@ -1,6 +1,3 @@ -

- 🌍 其他语言 -


Appwrite Logo @@ -19,6 +16,8 @@ [![翻译](https://img.shields.io/badge/translate-f02e65?style=flat-square)](docs/tutorials/add-translations.md) [![周边商店](https://img.shields.io/badge/swag%20store-f02e65?style=flat-square)](https://store.appwrite.io) +[English](README.md) | 简体中文 + Appwrite是一个基于dcoker的端到端开发者平台,其容器化的微服务库可应用于网页端,移动端,以及后端。Appwrite 通过视觉化界面极简了从零编写 API 的繁琐过程,在保证软件安全的前提下为开发者创造了一个高效的开发环境。 Appwrite 可以提供给开发者用户验证,外部授权,用户数据读写检索,文件储存, 图像处理,云函数计算,[等多种服务](https:/ /appwrite.io/docs)。 @@ -169,8 +168,4 @@ Appwrite API 界面层利用后台缓存和任务委派来提供极速的响应 ## 版权说明 -版权详情,访问 [BSD 3-Clause License](./LICENSE)。 - -## 其他语言 -- [English](README.md) -- [简体中文](README-CN.md) \ No newline at end of file +版权详情,访问 [BSD 3-Clause License](./LICENSE)。 \ No newline at end of file diff --git a/README.md b/README.md index 71196afdc2..3d1a0db74f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -

- 🌍 Translations -


Appwrite Logo @@ -19,6 +16,8 @@ [![Translate](https://img.shields.io/badge/translate-f02e65?style=flat-square)](docs/tutorials/add-translations.md) [![Swag Store](https://img.shields.io/badge/swag%20store-f02e65?style=flat-square)](https://store.appwrite.io) +English | [简体中文](README-CN.md) + [**Appwrite 0.12 has been released! Learn what's new!**](https://dev.to/appwrite/its-here-announcing-the-release-of-appwrite-012-5c8b) Appwrite is an end-to-end backend server for Web, Mobile, Native, or Backend apps packaged as a set of Docker microservices. Appwrite abstracts the complexity and repetitiveness required to build a modern backend API from scratch and allows you to build secure apps faster. @@ -172,8 +171,4 @@ Join our growing community around the world! See our official [Blog](https://med ## License -This repository is available under the [BSD 3-Clause License](./LICENSE). - -## Translations -- [English](README.md) -- [简体中文](README-CN.md) +This repository is available under the [BSD 3-Clause License](./LICENSE). \ No newline at end of file