1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00

Merge branch '0.9.x' into feat-get-session-by-id-endpoint

This commit is contained in:
Bradley Schofield 2021-06-17 11:07:33 +01:00 committed by GitHub
commit 3f386d485e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 636 additions and 281 deletions

View file

@ -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
- Added new endpoint to get a session based on it's ID (#1294)
## Bugs

View file

@ -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;
}
}
</style>
@ -220,15 +190,17 @@
<td class="wrapper">
<table role="presentation" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
{{content}}
</td>
<td>{{content}}</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- <div style="text-align: center; line-height: 25px; margin: 15px 0; font-size: 12px; color: #40404c;">
<a href="https://appwrite.io" style="text-decoration: none; color: #40404c;">Powered by <img src="https://appwrite.io/images/appwrite-footer-light.svg" height="15" style="margin: -3px 0" /></a>
</div> -->
</td>
<td>&nbsp;</td>
</tr>

View file

@ -109,19 +109,20 @@ return [
'gitUserName' => 'appwrite',
],
[
'key' => 'kotlin',
'name' => 'Kotlin',
'url' => '',
'package' => '',
'enabled' => false,
'beta' => false,
'key' => 'android',
'name' => 'Android',
'version' => '0.0.0-SNAPSHOT',
'url' => 'https://github.com/appwrite/sdk-for-android',
'package' => 'https://repo1.maven.org/maven2/io/appwrite/sdk-for-android/',
'enabled' => true,
'beta' => true,
'dev' => false,
'hidden' => false,
'family' => APP_PLATFORM_CLIENT,
'prism' => 'kotlin',
'source' => false,
'gitUrl' => 'git@github.com:appwrite/sdk-for-kotlin.git',
'gitRepoName' => 'sdk-for-kotlin',
'source' => \realpath(__DIR__ . '/../sdks/client-android'),
'gitUrl' => 'git@github.com:appwrite/sdk-for-android.git',
'gitRepoName' => 'sdk-for-android',
'gitUserName' => 'appwrite',
],
// [

View file

@ -1517,17 +1517,16 @@ App::post('/v1/account/recovery')
$cta = new Template(__DIR__.'/../../config/locale/templates/email-cta.tpl');
$body
->setParam('{{content}}', $content->render())
->setParam('{{content}}', $content->render(false))
->setParam('{{cta}}', $cta->render())
->setParam('{{title}}', $locale->getText('account.emails.recovery.title'))
->setParam('{{direction}}', $locale->getText('settings.direction'))
->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]']))
->setParam('{{name}}', $profile->getAttribute('name'))
->setParam('{{redirect}}', $url)
->setParam('{{bg-body}}', '#f6f6f6')
->setParam('{{bg-body}}', '#f7f7f7')
->setParam('{{bg-content}}', '#ffffff')
->setParam('{{bg-cta}}', '#3498db')
->setParam('{{bg-cta-hover}}', '#34495e')
->setParam('{{bg-cta}}', '#073b4c')
->setParam('{{text-content}}', '#000000')
->setParam('{{text-cta}}', '#ffffff')
;
@ -1720,17 +1719,16 @@ App::post('/v1/account/verification')
$cta = new Template(__DIR__.'/../../config/locale/templates/email-cta.tpl');
$body
->setParam('{{content}}', $content->render())
->setParam('{{content}}', $content->render(false))
->setParam('{{cta}}', $cta->render())
->setParam('{{title}}', $locale->getText('account.emails.verification.title'))
->setParam('{{direction}}', $locale->getText('settings.direction'))
->setParam('{{project}}', $project->getAttribute('name', ['[APP-NAME]']))
->setParam('{{name}}', $user->getAttribute('name'))
->setParam('{{redirect}}', $url)
->setParam('{{bg-body}}', '#f6f6f6')
->setParam('{{bg-body}}', '#f7f7f7')
->setParam('{{bg-content}}', '#ffffff')
->setParam('{{bg-cta}}', '#3498db')
->setParam('{{bg-cta-hover}}', '#34495e')
->setParam('{{bg-cta}}', '#073b4c')
->setParam('{{text-content}}', '#000000')
->setParam('{{text-cta}}', '#ffffff')
;

View file

@ -6,7 +6,6 @@ use Utopia\Storage\Device\Local;
use Utopia\Storage\Storage;
use Appwrite\ClamAV\Network;
use Appwrite\Event\Event;
use RuntimeException;
App::get('/v1/health')
->desc('Get HTTP')
@ -268,7 +267,7 @@ App::get('/v1/health/anti-virus')
'status' => (@$antiVirus->ping()) ? 'online' : 'offline',
'version' => @$antiVirus->version(),
]);
} catch( RuntimeException $e) {
} catch( \Exception $e) {
$response->json([
'status' => 'offline',
'version' => '',

View file

@ -242,6 +242,7 @@ App::get('/v1/storage/files/:fileId/preview')
->param('fileId', '', new UID(), 'File unique ID')
->param('width', 0, new Range(0, 4000), 'Resize preview image width, Pass an integer between 0 to 4000.', true)
->param('height', 0, new Range(0, 4000), 'Resize preview image height, Pass an integer between 0 to 4000.', true)
->param('gravity', Image::GRAVITY_CENTER, new WhiteList([Image::GRAVITY_CENTER, Image::GRAVITY_NORTH, Image::GRAVITY_NORTHWEST, Image::GRAVITY_NORTHEAST, Image::GRAVITY_WEST, Image::GRAVITY_EAST, Image::GRAVITY_SOUTHWEST, Image::GRAVITY_SOUTH, Image::GRAVITY_SOUTHEAST]), 'Image crop gravity', true)
->param('quality', 100, new Range(0, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to 100.', true)
->param('borderWidth', 0, new Range(0, 100), 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true)
->param('borderColor', '', new HexColor(), 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true)
@ -254,7 +255,7 @@ App::get('/v1/storage/files/:fileId/preview')
->inject('response')
->inject('project')
->inject('projectDB')
->action(function ($fileId, $width, $height, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output, $request, $response, $project, $projectDB) {
->action(function ($fileId, $width, $height, $gravity, $quality, $borderWidth, $borderColor, $borderRadius, $opacity, $rotation, $background, $output, $request, $response, $project, $projectDB) {
/** @var Utopia\Swoole\Request $request */
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Document $project */
@ -342,7 +343,7 @@ App::get('/v1/storage/files/:fileId/preview')
$image = new Image($source);
$image->crop((int) $width, (int) $height);
$image->crop((int) $width, (int) $height, $gravity);
if (!empty($opacity) || $opacity==0) {
$image->setOpacity($opacity);

View file

@ -212,7 +212,8 @@ App::delete('/v1/teams/:teamId')
->inject('response')
->inject('projectDB')
->inject('events')
->action(function ($teamId, $response, $projectDB, $events) {
->inject('deletes')
->action(function ($teamId, $response, $projectDB, $events, $deletes) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
/** @var Appwrite\Event\Event $events */
@ -223,25 +224,15 @@ App::delete('/v1/teams/:teamId')
throw new Exception('Team not found', 404);
}
$memberships = $projectDB->getCollection([
'limit' => 2000, // TODO add members limit
'offset' => 0,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS,
'teamId='.$teamId,
],
]);
foreach ($memberships as $member) {
if (!$projectDB->deleteDocument($member->getId())) {
throw new Exception('Failed to remove membership for team from DB', 500);
}
}
if (!$projectDB->deleteDocument($teamId)) {
throw new Exception('Failed to remove team from DB', 500);
}
$deletes
->setParam('type', DELETE_TYPE_DOCUMENT)
->setParam('document', $team)
;
$events
->setParam('eventData', $response->output($team, Response::MODEL_TEAM))
;
@ -434,7 +425,7 @@ App::post('/v1/teams/:teamId/memberships')
$title = \sprintf($locale->getText('account.emails.invitation.title'), $team->getAttribute('name', '[TEAM-NAME]'), $project->getAttribute('name', ['[APP-NAME]']));
$body
->setParam('{{content}}', $content->render())
->setParam('{{content}}', $content->render(false))
->setParam('{{cta}}', $cta->render())
->setParam('{{title}}', $title)
->setParam('{{direction}}', $locale->getText('settings.direction'))
@ -442,10 +433,9 @@ App::post('/v1/teams/:teamId/memberships')
->setParam('{{team}}', $team->getAttribute('name', '[TEAM-NAME]'))
->setParam('{{owner}}', $user->getAttribute('name', ''))
->setParam('{{redirect}}', $url)
->setParam('{{bg-body}}', '#f6f6f6')
->setParam('{{bg-body}}', '#f7f7f7')
->setParam('{{bg-content}}', '#ffffff')
->setParam('{{bg-cta}}', '#3498db')
->setParam('{{bg-cta-hover}}', '#34495e')
->setParam('{{bg-cta}}', '#073b4c')
->setParam('{{text-content}}', '#000000')
->setParam('{{text-cta}}', '#ffffff')
;

View file

@ -8,6 +8,7 @@ use Utopia\Validator\WhiteList;
use Appwrite\Network\Validator\Email;
use Utopia\Validator\Text;
use Utopia\Validator\Range;
use Utopia\Validator\Boolean;
use Utopia\Audit\Audit;
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
use Appwrite\Auth\Auth;
@ -369,6 +370,43 @@ App::patch('/v1/users/:userId/status')
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/verification')
->desc('Update Email Verification')
->groups(['api', 'users'])
->label('event', 'users.update.verification')
->label('scope', 'users.write')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'users')
->label('sdk.method', 'updateVerification')
->label('sdk.description', '/docs/references/users/update-user-verification.md')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_USER)
->param('userId', '', new UID(), 'User unique ID.')
->param('emailVerification', false, new Boolean(), 'User Email Verification Status.')
->inject('response')
->inject('projectDB')
->action(function ($userId, $emailVerification, $response, $projectDB) {
/** @var Appwrite\Utopia\Response $response */
/** @var Appwrite\Database\Database $projectDB */
$user = $projectDB->getDocument($userId);
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
$user = $projectDB->updateDocument(\array_merge($user->getArrayCopy(), [
'emailVerification' => $emailVerification,
]));
if (false === $user) {
throw new Exception('Failed saving user to DB', 500);
}
$response->dynamic($user, Response::MODEL_USER);
});
App::patch('/v1/users/:userId/prefs')
->desc('Update User Preferences')
->groups(['api', 'users'])

View file

@ -12,16 +12,6 @@ use Swoole\Http\Request as SwooleRequest;
use Swoole\Http\Response as SwooleResponse;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Config\Config;
use Utopia\Domains\Domain;
// xdebug_start_trace('/tmp/trace');
ini_set('memory_limit','512M');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('default_socket_timeout', -1);
error_reporting(E_ALL);
$http = new Server("0.0.0.0", App::getEnv('PORT', 80));
@ -68,7 +58,7 @@ Files::load(__DIR__ . '/../public');
include __DIR__ . '/controllers/general.php';
$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) {
$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) use ($register) {
$request = new Request($swooleRequest);
$response = new Response($swooleResponse);
@ -85,6 +75,17 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
return;
}
$db = $register->get('dbPool')->get();
$redis = $register->get('redisPool')->get();
$register->set('db', function () use (&$db) {
return $db;
});
$register->set('cache', function () use (&$redis) {
return $redis;
});
$app = new App('UTC');
try {
@ -104,6 +105,14 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
else {
$swooleResponse->end('500: Server Error');
}
} finally {
/** @var PDOPool $dbPool */
$dbPool = $register->get('dbPool');
$dbPool->put($db);
/** @var RedisPool $redisPool */
$redisPool = $register->get('redisPool');
$redisPool->put($redis);
}
});

View file

@ -11,6 +11,12 @@ if (\file_exists(__DIR__.'/../vendor/autoload.php')) {
require_once __DIR__.'/../vendor/autoload.php';
}
ini_set('memory_limit','512M');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('default_socket_timeout', -1);
error_reporting(E_ALL);
use Ahc\Jwt\JWT;
use Ahc\Jwt\JWTException;
use Appwrite\Auth\Auth;
@ -18,9 +24,10 @@ use Appwrite\Database\Database;
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Database\Document;
use Appwrite\Database\Pool\PDOPool;
use Appwrite\Database\Pool\RedisPool;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Event\Event;
use Appwrite\Extend\PDO;
use Appwrite\OpenSSL\OpenSSL;
use Utopia\App;
use Utopia\View;
@ -29,7 +36,6 @@ use Utopia\Locale\Locale;
use Utopia\Registry\Registry;
use MaxMind\Db\Reader;
use PHPMailer\PHPMailer\PHPMailer;
use PDO as PDONative;
const APP_NAME = 'Appwrite';
const APP_DOMAIN = 'appwrite.io';
@ -145,23 +151,32 @@ Database::addFilter('encrypt',
/*
* Registry
*/
$register->set('db', function () { // Register DB connection
$register->set('dbPool', function () { // Register DB connection
$dbHost = App::getEnv('_APP_DB_HOST', '');
$dbUser = App::getEnv('_APP_DB_USER', '');
$dbPass = App::getEnv('_APP_DB_PASS', '');
$dbScheme = App::getEnv('_APP_DB_SCHEMA', '');
$pool = new PDOPool(10, $dbHost, $dbScheme, $dbUser, $dbPass);
$pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array(
PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
PDONative::ATTR_TIMEOUT => 3, // Seconds
PDONative::ATTR_PERSISTENT => true
));
return $pool;
});
$register->set('redisPool', function () {
$redisHost = App::getEnv('_APP_REDIS_HOST', '');
$redisPort = App::getEnv('_APP_REDIS_PORT', '');
$redisUser = App::getEnv('_APP_REDIS_USER', '');
$redisPass = App::getEnv('_APP_REDIS_PASS', '');
$redisAuth = [];
// Connection settings
$pdo->setAttribute(PDONative::ATTR_DEFAULT_FETCH_MODE, PDONative::FETCH_ASSOC); // Return arrays
$pdo->setAttribute(PDONative::ATTR_ERRMODE, PDONative::ERRMODE_EXCEPTION); // Handle all errors with exceptions
if ($redisUser) {
$redisAuth[] = $redisUser;
}
if ($redisPass) {
$redisAuth[] = $redisPass;
}
return $pdo;
$pool = new RedisPool(10, $redisHost, $redisPort, $redisAuth);
return $pool;
});
$register->set('influxdb', function () { // Register DB connection
$host = App::getEnv('_APP_INFLUXDB_HOST', '');
@ -185,25 +200,6 @@ $register->set('statsd', function () { // Register DB connection
return $statsd;
});
$register->set('cache', function () { // Register cache connection
$redis = new Redis();
$redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', ''));
$user = App::getEnv('_APP_REDIS_USER','');
$pass = App::getEnv('_APP_REDIS_PASS','');
$auth = [];
if(!empty($user)) {
$auth["user"] = $user;
}
if(!empty($pass)) {
$auth["pass"] = $pass;
}
if(!empty($auth)) {
$redis->auth($auth);
}
$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);
return $redis;
});
$register->set('smtp', function () {
$mail = new PHPMailer(true);
@ -387,7 +383,7 @@ App::setResource('user', function($mode, $project, $console, $request, $response
/** @var Appwrite\Database\Document $project */
/** @var Appwrite\Database\Database $consoleDB */
/** @var Appwrite\Database\Database $projectDB */
/** @var bool $mode */
/** @var string $mode */
Authorization::setDefaultStatus(true);

View file

@ -15,7 +15,7 @@ use Appwrite\SDK\Language\Deno;
use Appwrite\SDK\Language\DotNet;
use Appwrite\SDK\Language\Flutter;
use Appwrite\SDK\Language\Go;
use Appwrite\SDK\Language\Java;
use Appwrite\SDK\Language\Kotlin;
use Appwrite\SDK\Language\Swift;
$cli
@ -134,9 +134,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
case 'go':
$config = new Go();
break;
case 'java':
$config = new Java();
break;
case 'swift':
$config = new Swift();
break;
@ -144,6 +141,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
$cover = '';
$config = new DotNet();
break;
case 'android':
$config = new Kotlin();
break;
default:
throw new Exception('Language "'.$language['key'].'" not supported');
break;
@ -155,9 +155,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
$sdk
->setName($language['name'])
->setDescription("Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
Use the {$language['name']} SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)")
->setNamespace('io appwrite')
->setDescription("Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the {$language['name']} SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)")
->setShortDescription('Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API')
->setLicense($license)
->setLicenseContent($licenseContent)

View file

@ -240,11 +240,11 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
<li>
<div class="link flutter-new"><img src="/images/clients/flutter.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="Flutter Platform Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Flutter App &nbsp;<span class="text-size-tiny">(beta)</span></div>
</li>
<li class="disabled">
<div class="link ios-new"><img src="/images/clients/ios.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="iOS Platform Logo" class="avatar xxs margin-end-small" loading="lazy" /> New iOS App <span class="text-fade text-size-small">(soon)</span></div>
<li>
<div class="link android-new"><img src="/images/clients/android.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="Android Platform Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Android App</div>
</li>
<li class="disabled">
<div class="link android-new"><img src="/images/clients/android.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="Android Platform Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Android App <span class="text-fade text-size-small">(soon)</span></div>
<div class="link ios-new"><img src="/images/clients/ios.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="iOS Platform Logo" class="avatar xxs margin-end-small" loading="lazy" /> New iOS App <span class="text-fade text-size-small">(soon)</span></div>
</li>
<li class="disabled">
<div class="link unity-new"><img src="/images/clients/unity.png?v=<?php echo APP_CACHE_BUSTER; ?>" alt="Unity Platform Logo" class="avatar xxs margin-end-small" loading="lazy" /> New Unity Game <span class="text-fade text-size-small">(soon)</span></div>
@ -329,6 +329,42 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
</form>
</script>
<div data-ui-modal class="modal box close" data-button-alias=".android-new">
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
<h1>Register your Android App</h1>
<form
data-analytics
data-analytics-activity
data-analytics-event="submit"
data-analytics-category="console"
data-analytics-label="Create Project Platform (Android)"
data-service="projects.createPlatform"
data-scope="console"
data-event="submit"
data-success="alert,trigger,reset"
data-success-param-alert-text="Registered new platform successfully"
data-success-param-trigger-events="projects.createPlatform"
data-failure="alert"
data-failure-param-alert-text="Failed to register platform"
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="type" data-ls-bind="android" />
<label for="name">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" name="name" required autocomplete="off" placeholder="My Android App" maxlength="128" />
<label for="key">Package Name <span class="tooltip large" data-tooltip="Your package name is generally the applicationId in your app-level build.gradle file."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" name="key" required autocomplete="off" placeholder="com.company.appname" />
<hr />
<button type="submit">Register</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Back</button>
</form>
</div>
<div data-ui-modal class="modal box close width-large" data-button-alias=".flutter-new">
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>

View file

@ -372,11 +372,14 @@ services:
- appwrite-influxdb:/var/lib/influxdb:rw
telegraf:
image: appwrite/telegraf:1.1.0
image: appwrite/telegraf:1.2.0
container_name: appwrite-telegraf
restart: unless-stopped
networks:
- appwrite
environment:
- _APP_INFLUXDB_HOST
- _APP_INFLUXDB_PORT
networks:
gateway:

32
app/workers.php Normal file
View file

@ -0,0 +1,32 @@
<?php
use Appwrite\Extend\PDO;
use Utopia\App;
/** @var Utopia\Registry\Registry $register */
require_once __DIR__.'/init.php';
$register->set('db', function () {
$dbHost = App::getEnv('_APP_DB_HOST', '');
$dbUser = App::getEnv('_APP_DB_USER', '');
$dbPass = App::getEnv('_APP_DB_PASS', '');
$dbScheme = App::getEnv('_APP_DB_SCHEMA', '');
$pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
PDO::ATTR_TIMEOUT => 3, // Seconds
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
));
return $pdo;
});
$register->set('cache', function () { // Register cache connection
$redis = new Redis();
$redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', ''));
$redis->setOption(Redis::OPT_READ_TIMEOUT, -1);
return $redis;
});

View file

@ -1,24 +1,24 @@
<?php
use Appwrite\Resque\Worker;
use Utopia\Audit\Audit;
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
use Utopia\CLI\Console;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Console::title('Audits V1 Worker');
Console::success(APP_NAME.' audits worker v1 has started');
class AuditsV1
class AuditsV1 extends Worker
{
public $args = [];
public function setUp(): void
public function init(): void
{
}
public function perform()
public function run(): void
{
global $register;
@ -39,8 +39,8 @@ class AuditsV1
$audit->log($userId, $event, $resource, $userAgent, $ip, '', $data);
}
public function tearDown(): void
public function shutdown(): void
{
// ... Remove environment for this job
}
}
}

View file

@ -1,30 +1,30 @@
<?php
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Config\Config;
use Utopia\Domains\Domain;
use Appwrite\Database\Database;
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Network\Validator\CNAME;
use Appwrite\Resque\Worker;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Config\Config;
use Utopia\Domains\Domain;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Console::title('Certificates V1 Worker');
Console::success(APP_NAME.' certificates worker v1 has started');
class CertificatesV1
class CertificatesV1 extends Worker
{
public $args = [];
public function setUp(): void
public function init(): void
{
}
public function perform()
public function run(): void
{
global $register;
@ -204,8 +204,7 @@ class CertificatesV1
Authorization::reset();
}
public function tearDown(): void
public function shutdown(): void
{
// ... Remove environment for this job
}
}
}

View file

@ -5,6 +5,7 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Database\Document;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Resque\Worker;
use Utopia\Storage\Device\Local;
use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\TimeLimit;
@ -13,26 +14,24 @@ use Utopia\Config\Config;
use Utopia\Audit\Audit;
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Console::title('Deletes V1 Worker');
Console::success(APP_NAME.' deletes worker v1 has started'."\n");
class DeletesV1
class DeletesV1 extends Worker
{
public $args = [];
protected $consoleDB = null;
public function setUp(): void
public function init(): void
{
}
public function perform()
{
$projectId = isset($this->args['projectId']) ? $this->args['projectId'] : '';
public function run(): void
{
$projectId = isset($this->args['projectId']) ? $this->args['projectId'] : '';
$type = $this->args['type'];
switch (strval($type)) {
@ -52,6 +51,9 @@ class DeletesV1
case Database::SYSTEM_COLLECTION_COLLECTIONS:
$this->deleteDocuments($document, $projectId);
break;
case Database::SYSTEM_COLLECTION_TEAMS:
$this->deleteMemberships($document, $projectId);
break;
default:
Console::error('No lazy delete operation available for document of type: '.$document->getCollection());
break;
@ -82,9 +84,8 @@ class DeletesV1
}
}
public function tearDown(): void
public function shutdown(): void
{
// ... Remove environment for this job
}
protected function deleteDocuments(Document $document, $projectId)
@ -97,6 +98,14 @@ class DeletesV1
], $this->getProjectDB($projectId));
}
protected function deleteMemberships(Document $document, $projectId) {
// Delete Memberships
$this->deleteByGroup([
'$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS,
'teamId='.$document->getId(),
], $this->getProjectDB($projectId));
}
protected function deleteProject(Document $document)
{
// Delete all DBs
@ -214,7 +223,7 @@ class DeletesV1
Console::success('Delete code tag: '.$document->getAttribute('path', ''));
}
else {
Console::error('Dailed to delete code tag: '.$document->getAttribute('path', ''));
Console::error('Failed to delete code tag: '.$document->getAttribute('path', ''));
}
});
@ -262,7 +271,6 @@ class DeletesV1
Authorization::disable();
$projects = $this->getConsoleDB()->getCollection([
'limit' => $limit,
'offset' => $count,
'orderType' => 'ASC',
'orderCast' => 'string',
'filters' => [
@ -305,7 +313,6 @@ class DeletesV1
$results = $database->getCollection([
'limit' => $limit,
'offset' => $count,
'orderField' => '$id',
'orderType' => 'ASC',
'orderCast' => 'string',

View file

@ -6,13 +6,14 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Event\Event;
use Appwrite\Resque\Worker;
use Cron\CronExpression;
use Swoole\Runtime;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Config\Config;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Runtime::enableCoroutine(0);
@ -125,17 +126,17 @@ Console::info(count($list)." functions listed in " . ($executionEnd - $execution
//TODO aviod scheduled execution if delay is bigger than X offest
class FunctionsV1
class FunctionsV1 extends Worker
{
public $args = [];
public $allowed = [];
public function setUp(): void
public function init(): void
{
}
public function perform()
public function run(): void
{
global $register;
@ -579,7 +580,7 @@ class FunctionsV1
return $output;
}
public function tearDown(): void
public function shutdown(): void
{
}
}
}

View file

@ -1,26 +1,26 @@
<?php
use Appwrite\Resque\Worker;
use Utopia\App;
use Utopia\CLI\Console;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Console::title('Mails V1 Worker');
Console::success(APP_NAME.' mails worker v1 has started'."\n");
class MailsV1
class MailsV1 extends Worker
{
/**
* @var array
*/
public $args = [];
public function setUp(): void
public function init(): void
{
}
public function perform()
public function run(): void
{
global $register;
@ -68,8 +68,7 @@ class MailsV1
}
}
public function tearDown(): void
public function shutdown(): void
{
// ... Remove environment for this job
}
}
}

View file

@ -1,32 +1,32 @@
<?php
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Config\Config;
use Appwrite\Database\Database;
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Resque\Worker;
use Cron\CronExpression;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Config\Config;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Console::title('Tasks V1 Worker');
Console::success(APP_NAME.' tasks worker v1 has started');
class TasksV1
class TasksV1 extends Worker
{
/**
* @var array
*/
public $args = [];
public function setUp(): void
public function init(): void
{
}
public function perform()
public function run(): void
{
global $register;
@ -73,11 +73,11 @@ class TasksV1
}
if ($task->getAttribute('updated') !== $updated) { // Task have already been rescheduled by owner
return false;
return;
}
if ($task->getAttribute('status') !== 'play') { // Skip task and don't schedule again
return false;
return;
}
// Reschedule
@ -202,11 +202,10 @@ class TasksV1
// Send alert if needed (use SMTP as default for now)
return true;
return;
}
public function tearDown(): void
public function shutdown(): void
{
// ... Remove environment for this job
}
}
}

View file

@ -1,29 +1,30 @@
<?php
use Appwrite\Resque\Worker;
use Utopia\App;
use Utopia\CLI\Console;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Console::title('Usage V1 Worker');
Console::success(APP_NAME.' usage worker v1 has started');
class UsageV1
class UsageV1 extends Worker
{
/**
* @var array
*/
public $args = [];
public function setUp(): void
public function init(): void
{
}
public function perform()
public function run(): void
{
global $register;
/** @var \Domnikl\Statsd\Client $statsd */
$statsd = $register->get('statsd', true);
$projectId = $this->args['projectId'] ?? '';
@ -36,12 +37,12 @@ class UsageV1
$httpMethod = $this->args['httpMethod'] ?? '';
$httpRequest = $this->args['httpRequest'] ?? 0;
$functionId = $this->args['functionId'];
$functionId = $this->args['functionId'] ?? '';
$functionExecution = $this->args['functionExecution'] ?? 0;
$functionExecutionTime = $this->args['functionExecutionTime'] ?? 0;
$functionStatus = $this->args['functionStatus'] ?? '';
$tags = ",project={$projectId},version=".App::getEnv('_APP_VERSION', 'UNKNOWN').'';
$tags = ",project={$projectId},version=".App::getEnv('_APP_VERSION', 'UNKNOWN');
// the global namespace is prepended to every key (optional)
$statsd->setNamespace('appwrite.usage');
@ -52,7 +53,6 @@ class UsageV1
if($functionExecution >= 1) {
$statsd->increment('executions.all'.$tags.',functionId='.$functionId.',functionStatus='.$functionStatus);
var_dump($tags.',functionId='.$functionId.',functionStatus='.$functionStatus);
$statsd->count('executions.time'.$tags.',functionId='.$functionId, $functionExecutionTime);
}
@ -65,8 +65,7 @@ class UsageV1
}
}
public function tearDown(): void
public function shutdown(): void
{
// ... Remove environment for this job
}
}
}

View file

@ -1,23 +1,23 @@
<?php
use Appwrite\Resque\Worker;
use Utopia\App;
use Utopia\CLI\Console;
require_once __DIR__.'/../init.php';
require_once __DIR__.'/../workers.php';
Console::title('Webhooks V1 Worker');
Console::success(APP_NAME.' webhooks worker v1 has started');
class WebhooksV1
class WebhooksV1 extends Worker
{
public $args = [];
public function setUp(): void
public function init(): void
{
}
public function perform()
public function run(): void
{
$errors = [];
@ -88,8 +88,7 @@ class WebhooksV1
}
}
public function tearDown(): void
public function shutdown(): void
{
// ... Remove environment for this job
}
}
}

View file

@ -46,12 +46,12 @@
"utopia-php/cli": "0.11.*",
"utopia-php/config": "0.2.*",
"utopia-php/locale": "0.3.*",
"utopia-php/registry": "0.4.*",
"utopia-php/registry": "0.5.*",
"utopia-php/preloader": "0.2.*",
"utopia-php/domains": "1.1.*",
"utopia-php/swoole": "0.2.*",
"utopia-php/storage": "0.5.*",
"utopia-php/image": "0.2.*",
"utopia-php/image": "0.3.*",
"resque/php-resque": "1.3.6",
"matomo/device-detector": "4.2.2",
"dragonmantank/cron-expression": "3.1.0",

40
composer.lock generated
View file

@ -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": "6704f7df5ffe0baac3633dc8e683ed78",
"content-hash": "399d2426ca92e04b6d6fb84a91c316c3",
"packages": [
{
"name": "adhocore/jwt",
@ -1742,16 +1742,16 @@
},
{
"name": "utopia-php/image",
"version": "0.2.1",
"version": "0.3.2",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/image.git",
"reference": "0754955a165483852184d1215cc3bf659432d23a"
"reference": "2044fdd44d87c4253cfe929cca975fd037461b00"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/image/zipball/0754955a165483852184d1215cc3bf659432d23a",
"reference": "0754955a165483852184d1215cc3bf659432d23a",
"url": "https://api.github.com/repos/utopia-php/image/zipball/2044fdd44d87c4253cfe929cca975fd037461b00",
"reference": "2044fdd44d87c4253cfe929cca975fd037461b00",
"shasum": ""
},
"require": {
@ -1789,9 +1789,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/image/issues",
"source": "https://github.com/utopia-php/image/tree/0.2.1"
"source": "https://github.com/utopia-php/image/tree/0.3.2"
},
"time": "2021-04-13T07:47:24+00:00"
"time": "2021-06-10T09:16:11+00:00"
},
{
"name": "utopia-php/locale",
@ -1899,16 +1899,16 @@
},
{
"name": "utopia-php/registry",
"version": "0.4.0",
"version": "0.5.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/registry.git",
"reference": "7aebbc6c5f3f04ff7a35ac3dad39fa91c9bd7c2d"
"reference": "bedc4ed54527b2803e6dfdccc39449f98522b70d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/registry/zipball/7aebbc6c5f3f04ff7a35ac3dad39fa91c9bd7c2d",
"reference": "7aebbc6c5f3f04ff7a35ac3dad39fa91c9bd7c2d",
"url": "https://api.github.com/repos/utopia-php/registry/zipball/bedc4ed54527b2803e6dfdccc39449f98522b70d",
"reference": "bedc4ed54527b2803e6dfdccc39449f98522b70d",
"shasum": ""
},
"require": {
@ -1945,9 +1945,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/registry/issues",
"source": "https://github.com/utopia-php/registry/tree/0.4.0"
"source": "https://github.com/utopia-php/registry/tree/0.5.0"
},
"time": "2021-03-10T06:50:09+00:00"
"time": "2021-03-10T10:45:22+00:00"
},
{
"name": "utopia-php/storage",
@ -4472,16 +4472,16 @@
},
{
"name": "sebastian/global-state",
"version": "5.0.2",
"version": "5.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "a90ccbddffa067b51f574dea6eb25d5680839455"
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/a90ccbddffa067b51f574dea6eb25d5680839455",
"reference": "a90ccbddffa067b51f574dea6eb25d5680839455",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49",
"shasum": ""
},
"require": {
@ -4524,7 +4524,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.2"
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3"
},
"funding": [
{
@ -4532,7 +4532,7 @@
"type": "github"
}
],
"time": "2020-10-26T15:55:19+00:00"
"time": "2021-06-11T13:31:12+00:00"
},
{
"name": "sebastian/lines-of-code",
@ -6025,5 +6025,5 @@
"platform-overrides": {
"php": "8.0"
},
"plugin-api-version": "2.0.0"
"plugin-api-version": "2.1.0"
}

View file

@ -430,10 +430,13 @@ services:
- appwrite-influxdb:/var/lib/influxdb:rw
telegraf:
image: appwrite/telegraf:1.1.0
image: appwrite/telegraf:1.2.0
container_name: appwrite-telegraf
networks:
- appwrite
environment:
- _APP_INFLUXDB_HOST
- _APP_INFLUXDB_PORT
# Dev Tools Start ------------------------------------------------------------------------------------------
#

View file

@ -0,0 +1 @@
Update the user email verification status by its unique ID.

View file

@ -0,0 +1 @@
# Change Log

View file

@ -0,0 +1,94 @@
## Getting Started
### Add your Android Platform
To initialize your SDK and start interacting with Appwrite services, you need to add a new Android platform to your project. To add a new platform, go to your Appwrite console, select your project (create one if you haven't already), and click the 'Add Platform' button on the project Dashboard.
From the options, choose to add a new **Android** platform and add your app credentials.
Add your app <u>name</u> and <u>package name</u>. Your package name is generally the applicationId in your app-level `build.gradle` file. By registering a new platform, you are allowing your app to communicate with the Appwrite API.
### Registering additional activities
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-android/blob/master/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
<manifest>
<application>
<activity android:name="io.appwrite.views.CallbackActivity" >
<intent-filter android:label="android_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="appwrite-callback-[PROJECT_ID]" />
</intent-filter>
</activity>
</application>
</manifest>
```
### Init your SDK
<p>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
<p>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)

View file

@ -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);

View file

@ -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
<manifest>
@ -48,7 +48,7 @@ While running Flutter Web, make sure your Appwrite server and your Flutter clien
### Init your SDK
<p>Initialize your SDK code with your project ID, which can be found in your project settings page.
<p>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
<p>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.
<p>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

View file

@ -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);

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,20 @@
<?php
namespace Appwrite\Database;
abstract class Pool
{
protected $available = true;
protected $pool;
protected $size = 5;
abstract public function get();
public function destruct()
{
$this->available = false;
while (!$this->pool->isEmpty()) {
$this->pool->pop();
}
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace Appwrite\Database\Pool;
use Appwrite\Database\Pool;
use Appwrite\Extend\PDO;
use SplQueue;
class PDOPool extends Pool
{
public function __construct(int $size, string $host = 'localhost', string $schema = 'appwrite', string $user = '', string $pass = '', string $charset = 'utf8mb4')
{
$this->pool = new SplQueue;
$this->size = $size;
for ($i = 0; $i < $this->size; $i++) {
$pdo = new PDO(
"mysql:" .
"host={$host};" .
"dbname={$schema};" .
"charset={$charset}",
$user,
$pass,
[
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
PDO::ATTR_TIMEOUT => 3, // Seconds
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
]
);
$this->pool->enqueue($pdo);
}
}
public function put(PDO $pdo)
{
$this->pool->enqueue($pdo);
}
public function get(): PDO
{
if ($this->available && count($this->pool) > 0) {
return $this->pool->dequeue();
}
sleep(0.01);
return $this->get();
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace Appwrite\Database\Pool;
use Appwrite\Database\Pool;
use SplQueue;
use Redis;
class RedisPool extends Pool
{
public function __construct(int $size, string $host, int $port, array $auth = [])
{
$this->pool = new SplQueue;
$this->size = $size;
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);
}
$this->pool->enqueue($redis);
}
}
public function put(Redis $redis)
{
$this->pool->enqueue($redis);
}
public function get(): Redis
{
if ($this->available && !$this->pool->isEmpty()) {
return $this->pool->dequeue();
}
sleep(0.1);
return $this->get();
}
}

View file

@ -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

View file

@ -0,0 +1,29 @@
<?php
namespace Appwrite\Resque;
abstract class Worker
{
public $args = [];
abstract public function init(): void;
abstract public function run(): void;
abstract public function shutdown(): void;
public function setUp(): void
{
$this->init();
}
public function perform()
{
$this->run();
}
public function tearDown(): void
{
$this->shutdown();
}
}

View file

@ -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:

View file

@ -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']);
}
}
}

View file

@ -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
*/