From 7b1bad0a622a3045de7938f7b31128f4a53fdf39 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 5 Jan 2021 14:22:20 +0200 Subject: [PATCH 01/38] Reordered some code --- app/controllers/general.php | 111 +-------------------------------- app/controllers/shared/api.php | 106 ++++++++++++++++++++++++++++++- app/controllers/shared/web.php | 1 + 3 files changed, 108 insertions(+), 110 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index d77b3d5607..f577f7459e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -14,27 +14,19 @@ use Appwrite\Database\Database; use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; use Appwrite\Network\Validator\Origin; -use Appwrite\Storage\Device\Local; -use Appwrite\Storage\Storage; use Utopia\CLI\Console; Config::setParam('domainVerification', false); Config::setParam('cookieDomain', 'localhost'); Config::setParam('cookieSamesite', Response::COOKIE_SAMESITE_NONE); -App::init(function ($utopia, $request, $response, $console, $project, $user, $locale, $events, $audits, $usage, $deletes, $clients) { +App::init(function ($utopia, $request, $response, $console, $project, $user, $locale, $clients) { /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $console */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Locale\Locale $locale */ - /** @var Appwrite\Event\Event $events */ - /** @var Appwrite\Event\Event $audits */ - /** @var Appwrite\Event\Event $usage */ - /** @var Appwrite\Event\Event $deletes */ - /** @var Appwrite\Event\Event $functions */ - /** @var bool $mode */ /** @var array $clients */ @@ -91,9 +83,6 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo : '.'.$request->getHostname() ); - Storage::setDevice('files', new Local(APP_STORAGE_UPLOADS.'/app-'.$project->getId())); - Storage::setDevice('functions', new Local(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId())); - /* * Security Headers * @@ -110,8 +99,6 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo $response ->addHeader('Server', 'Appwrite') - ->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url='.\urlencode($request->getURI())) - //->addHeader('X-Frame-Options', ($refDomain == 'http://localhost') ? 'SAMEORIGIN' : 'ALLOW-FROM ' . $refDomain) ->addHeader('X-Content-Type-Options', 'nosniff') ->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE') ->addHeader('Access-Control-Allow-Headers', 'Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-SDK-Version, Cache-Control, Expires, Pragma') @@ -123,7 +110,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo /* * Validate Client Domain - Check to avoid CSRF attack * Adding Appwrite API domains to allow XDOMAIN communication - * Skip this check for non-web platforms which are not requiredto send an origin header + * Skip this check for non-web platforms which are not required to send an origin header */ $origin = $request->getOrigin($request->getReferer('')); $originValidator = new Origin(\array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', []))); @@ -219,99 +206,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo throw new Exception('Password reset is required', 412); } - /* - * Background Jobs - */ - - $events - ->setParam('projectId', $project->getId()) - ->setParam('userId', $user->getId()) - ->setParam('event', $route->getLabel('event', '')) - ->setParam('payload', []) - ->setParam('functionId', null) - ->setParam('executionId', null) - ->setParam('trigger', 'event') - ; - - $audits - ->setParam('projectId', $project->getId()) - ->setParam('userId', $user->getId()) - ->setParam('event', '') - ->setParam('resource', '') - ->setParam('userAgent', $request->getUserAgent('')) - ->setParam('ip', $request->getIP()) - ->setParam('data', []) - ; - - $usage - ->setParam('projectId', $project->getId()) - ->setParam('httpRequest', 1) - ->setParam('httpUrl', $request->getHostname().$request->getURI()) - ->setParam('httpMethod', $request->getMethod()) - ->setParam('networkRequestSize', 0) - ->setParam('networkResponseSize', 0) - ->setParam('storage', 0) - ; - - $deletes - ->setParam('projectId', $project->getId()) - ; - -}, ['utopia', 'request', 'response', 'console', 'project', 'user', 'locale', 'events', 'audits', 'usage', 'deletes', 'clients']); - -App::shutdown(function ($utopia, $request, $response, $project, $events, $audits, $usage, $deletes, $mode) { - /** @var Utopia\App $utopia */ - /** @var Utopia\Swoole\Request $request */ - /** @var Appwrite\Utopia\Response $response */ - /** @var Appwrite\Database\Document $project */ - /** @var Appwrite\Event\Event $events */ - /** @var Appwrite\Event\Event $audits */ - /** @var Appwrite\Event\Event $usage */ - /** @var Appwrite\Event\Event $deletes */ - /** @var Appwrite\Event\Event $functions */ - /** @var bool $mode */ - - if (!empty($events->getParam('event'))) { - if(empty($events->getParam('payload'))) { - $events->setParam('payload', $response->getPayload()); - } - - $webhooks = clone $events; - $functions = clone $events; - - $webhooks - ->setQueue('v1-webhooks') - ->setClass('WebhooksV1') - ->trigger(); - - $functions - ->setQueue('v1-functions') - ->setClass('FunctionsV1') - ->trigger(); - } - - if (!empty($audits->getParam('event'))) { - $audits->trigger(); - } - - if (!empty($deletes->getParam('type')) && !empty($deletes->getParam('document'))) { - $deletes->trigger(); - } - - $route = $utopia->match($request); - - if ($project->getId() - && $mode !== APP_MODE_ADMIN //TODO: add check to make sure user is admin - && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage on admin mode - - $usage - ->setParam('networkRequestSize', $request->getSize() + $usage->getParam('storage')) - ->setParam('networkResponseSize', $response->getSize()) - ->trigger() - ; - } - -}, ['utopia', 'request', 'response', 'project', 'events', 'audits', 'usage', 'deletes', 'mode']); +}, ['utopia', 'request', 'response', 'console', 'project', 'user', 'locale', 'clients']); App::options(function ($request, $response) { /** @var Utopia\Swoole\Request $request */ diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index d64c46a2cd..0dcd3bc414 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -4,14 +4,24 @@ use Utopia\App; use Utopia\Exception; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; +use Appwrite\Storage\Device\Local; +use Appwrite\Storage\Storage; -App::init(function ($utopia, $request, $response, $project, $user, $register) { +App::init(function ($utopia, $request, $response, $project, $user, $register, $events, $audits, $usage, $deletes) { /** @var Utopia\App $utopia */ /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Registry\Registry $register */ + /** @var Appwrite\Event\Event $events */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $usage */ + /** @var Appwrite\Event\Event $deletes */ + /** @var Appwrite\Event\Event $functions */ + + Storage::setDevice('files', new Local(APP_STORAGE_UPLOADS.'/app-'.$project->getId())); + Storage::setDevice('functions', new Local(APP_STORAGE_FUNCTIONS.'/app-'.$project->getId())); $route = $utopia->match($request); @@ -52,4 +62,96 @@ App::init(function ($utopia, $request, $response, $project, $user, $register) { if ($abuse->check() && App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') { throw new Exception('Too many requests', 429); } -}, ['utopia', 'request', 'response', 'project', 'user', 'register'], 'api'); \ No newline at end of file + + /* + * Background Jobs + */ + $events + ->setParam('projectId', $project->getId()) + ->setParam('userId', $user->getId()) + ->setParam('event', $route->getLabel('event', '')) + ->setParam('payload', []) + ->setParam('functionId', null) + ->setParam('executionId', null) + ->setParam('trigger', 'event') + ; + + $audits + ->setParam('projectId', $project->getId()) + ->setParam('userId', $user->getId()) + ->setParam('event', '') + ->setParam('resource', '') + ->setParam('userAgent', $request->getUserAgent('')) + ->setParam('ip', $request->getIP()) + ->setParam('data', []) + ; + + $usage + ->setParam('projectId', $project->getId()) + ->setParam('httpRequest', 1) + ->setParam('httpUrl', $request->getHostname().$request->getURI()) + ->setParam('httpMethod', $request->getMethod()) + ->setParam('networkRequestSize', 0) + ->setParam('networkResponseSize', 0) + ->setParam('storage', 0) + ; + + $deletes + ->setParam('projectId', $project->getId()) + ; + +}, ['utopia', 'request', 'response', 'project', 'user', 'register', 'events', 'audits', 'usage', 'deletes'], 'api'); + +App::shutdown(function ($utopia, $request, $response, $project, $events, $audits, $usage, $deletes, $mode) { + /** @var Utopia\App $utopia */ + /** @var Utopia\Swoole\Request $request */ + /** @var Appwrite\Utopia\Response $response */ + /** @var Appwrite\Database\Document $project */ + /** @var Appwrite\Event\Event $events */ + /** @var Appwrite\Event\Event $audits */ + /** @var Appwrite\Event\Event $usage */ + /** @var Appwrite\Event\Event $deletes */ + /** @var Appwrite\Event\Event $functions */ + /** @var bool $mode */ + + if (!empty($events->getParam('event'))) { + if(empty($events->getParam('payload'))) { + $events->setParam('payload', $response->getPayload()); + } + + $webhooks = clone $events; + $functions = clone $events; + + $webhooks + ->setQueue('v1-webhooks') + ->setClass('WebhooksV1') + ->trigger(); + + $functions + ->setQueue('v1-functions') + ->setClass('FunctionsV1') + ->trigger(); + } + + if (!empty($audits->getParam('event'))) { + $audits->trigger(); + } + + if (!empty($deletes->getParam('type')) && !empty($deletes->getParam('document'))) { + $deletes->trigger(); + } + + $route = $utopia->match($request); + + if ($project->getId() + && $mode !== APP_MODE_ADMIN //TODO: add check to make sure user is admin + && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage on admin mode + + $usage + ->setParam('networkRequestSize', $request->getSize() + $usage->getParam('storage')) + ->setParam('networkResponseSize', $response->getSize()) + ->trigger() + ; + } + +}, ['utopia', 'request', 'response', 'project', 'events', 'audits', 'usage', 'deletes', 'mode'], 'api'); diff --git a/app/controllers/shared/web.php b/app/controllers/shared/web.php index 42d2a18c55..43eaf74d09 100644 --- a/app/controllers/shared/web.php +++ b/app/controllers/shared/web.php @@ -37,6 +37,7 @@ App::init(function ($utopia, $request, $response, $layout) { ->addHeader('Cache-Control', 'public, max-age='.$time) ->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache ->addHeader('X-Frame-Options', 'SAMEORIGIN') // Avoid console and homepage from showing in iframes + ->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url='.\urlencode($request->getURI())) ->addHeader('X-UA-Compatible', 'IE=Edge') // Deny IE browsers from going into quirks mode ; From 3d9060bdab47248b9bf97083a319ac1d051aa14a Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 5 Jan 2021 14:58:16 +0200 Subject: [PATCH 02/38] Changed constants --- app/config/roles.php | 21 +++++++-------------- src/Appwrite/Auth/Auth.php | 1 + 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/config/roles.php b/app/config/roles.php index 8dfaf78eb4..506b2403c6 100644 --- a/app/config/roles.php +++ b/app/config/roles.php @@ -1,13 +1,6 @@ [ + Auth::USER_ROLE_GUEST => [ 'label' => 'Guest', 'scopes' => [ 'public', @@ -71,23 +64,23 @@ return [ 'execution.write', ], ], - ROLE_MEMBER => [ + Auth::USER_ROLE_MEMBER => [ 'label' => 'Member', 'scopes' => \array_merge($logged, []), ], - ROLE_ADMIN => [ + Auth::USER_ROLE_ADMIN => [ 'label' => 'Admin', 'scopes' => \array_merge($admins, []), ], - ROLE_DEVELOPER => [ + Auth::USER_ROLE_DEVELOPER => [ 'label' => 'Developer', 'scopes' => \array_merge($admins, []), ], - ROLE_OWNER => [ + Auth::USER_ROLE_OWNER => [ 'label' => 'Owner', 'scopes' => \array_merge($logged, $admins, []), ], - ROLE_APP => [ + Auth::USER_ROLE_APP => [ 'label' => 'Application', 'scopes' => ['health.read'], ], diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index 88eb11299d..e43ab78bff 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -23,6 +23,7 @@ class Auth const USER_ROLE_OWNER = 4; const USER_ROLE_APP = 5; const USER_ROLE_SYSTEM = 6; + const USER_ROLE_ALL = '*'; /** * Token Types. From 901db844a9a066b6feacc9f5a5546f94985aaa77 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 10 Jan 2021 14:49:18 +0200 Subject: [PATCH 03/38] Fixed bug --- app/views/console/keys/index.phtml | 2 +- public/dist/scripts/app-all.js | 4 ++-- public/dist/scripts/app.js | 4 ++-- public/scripts/views/forms/select-all.js | 6 ++++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/views/console/keys/index.phtml b/app/views/console/keys/index.phtml index cb605e406d..c0c7f1216f 100644 --- a/app/views/console/keys/index.phtml +++ b/app/views/console/keys/index.phtml @@ -57,7 +57,7 @@ $scopes = $this->getParam('scopes', []);
$scope) : ?>
-   +  
diff --git a/public/dist/scripts/app-all.js b/public/dist/scripts/app-all.js index 7f9841bb91..6db3918c64 100644 --- a/public/dist/scripts/app-all.js +++ b/public/dist/scripts/app-all.js @@ -2330,8 +2330,8 @@ var variations={digits:/\d/.test(password),lower:/[a-z]/.test(password),upper:/[ score+=(variationCount-1)*10;return parseInt(score);};var callback=function(){var score=calc(this.value);if(""===this.value)return(meter.className="password-meter");if(score>60)return(meter.className="password-meter strong");if(score>30)return(meter.className="password-meter medium");if(score>=0)return(meter.className="password-meter weak");};var meter=window.document.createElement("div");meter.className="password-meter";element.parentNode.insertBefore(meter,element.nextSibling);element.addEventListener("change",callback);element.addEventListener("keypress",callback);element.addEventListener("keyup",callback);element.addEventListener("keydown",callback);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-pell",controller:function(element,window,document,markdown,rtl){var div=document.createElement("div");element.className="pell hide";div.className="input pell";element.parentNode.insertBefore(div,element);element.tabIndex=-1;var turndownService=new TurndownService();turndownService.addRule("underline",{filter:["u"],replacement:function(content){return"__"+content+"__";}});var editor=window.pell.init({element:div,onChange:function onChange(html){alignText();element.value=turndownService.turndown(html);},defaultParagraphSeparator:"p",actions:[{name:"bold",icon:''},{name:"underline",icon:''},{name:"italic",icon:''},{name:"olist",icon:''},{name:"ulist",icon:''},{name:"link",icon:''}]});var clean=function(e){e.stopPropagation();e.preventDefault();var clipboardData=e.clipboardData||window.clipboardData;console.log(clipboardData.getData("Text"));window.pell.exec("insertText",clipboardData.getData("Text"));return true;};var alignText=function(){let paragraphs=editor.content.querySelectorAll('p,li');let last='';for(let paragraph of paragraphs){var content=paragraph.textContent;if(content.trim()===''){content=last.textContent;} if(rtl.isRTL(content)){paragraph.style.direction='rtl';paragraph.style.textAlign='right';} else{paragraph.style.direction='ltr';paragraph.style.textAlign='left';} -last=paragraph;}};var santize=function(e){clean(e);alignText(e);};element.addEventListener("change",function(){editor.content.innerHTML=markdown.render(element.value);alignText();});editor.content.setAttribute("placeholder",element.placeholder);editor.content.innerHTML=markdown.render(element.value);editor.content.tabIndex=0;alignText();editor.content.onkeydown=function preventTab(event){if(event.which===9){event.preventDefault();if(document.activeElement){var focussable=Array.prototype.filter.call(document.querySelectorAll('a:not([disabled]), button:not([disabled]), select:not([disabled]), input[type=text]:not([disabled]), input[type=checkbox]:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])'),function(element){return(element.offsetWidth>0||element.offsetHeight>0||element===document.activeElement);});var index=focussable.indexOf(document.activeElement);if(index>-1){if(event.shiftKey){var prevElement=focussable[index-1]||focussable[focussable.length-1];prevElement.focus();}else{var nextElement=focussable[index+1]||focussable[0];nextElement.focus();}}}}};div.addEventListener("paste",santize);div.addEventListener("drop",santize);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-remove",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-remove]")).map(function(obj){obj.addEventListener("click",function(){element.parentNode.removeChild(element);});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-run",repeat:false,controller:function(element,expression,container){let action=expression.parse(element.dataset["formsRun"]||'');element.addEventListener('click',function(){return container.path(action)();});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-select-all",controller:function(element){let select=document.createElement("button");let unselect=document.createElement("button");select.textContent='Select All';unselect.textContent='Unselect All';select.classList.add('link');select.classList.add('margin-top-tiny');select.classList.add('margin-start-small');select.classList.add('text-size-small');select.classList.add('pull-end');unselect.classList.add('link');unselect.classList.add('margin-top-tiny');unselect.classList.add('margin-start-small');unselect.classList.add('text-size-small');unselect.classList.add('pull-end');select.type='button';unselect.type='button';element.parentNode.insertBefore(select,element);element.parentNode.insertBefore(unselect,element);select.addEventListener('click',function(){let checkboxes=document.querySelectorAll("input[type='checkbox']");for(var i=0;i0||element.offsetHeight>0||element===document.activeElement);});var index=focussable.indexOf(document.activeElement);if(index>-1){if(event.shiftKey){var prevElement=focussable[index-1]||focussable[focussable.length-1];prevElement.focus();}else{var nextElement=focussable[index+1]||focussable[0];nextElement.focus();}}}}};div.addEventListener("paste",santize);div.addEventListener("drop",santize);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-remove",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-remove]")).map(function(obj){obj.addEventListener("click",function(){element.parentNode.removeChild(element);});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-run",repeat:false,controller:function(element,expression,container){let action=expression.parse(element.dataset["formsRun"]||'');element.addEventListener('click',function(){return container.path(action)();});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-select-all",controller:function(element){let select=document.createElement("button");let unselect=document.createElement("button");select.textContent='Select All';unselect.textContent='Unselect All';select.classList.add('link');select.classList.add('margin-top-tiny');select.classList.add('margin-start-small');select.classList.add('text-size-small');select.classList.add('pull-end');unselect.classList.add('link');unselect.classList.add('margin-top-tiny');unselect.classList.add('margin-start-small');unselect.classList.add('text-size-small');unselect.classList.add('pull-end');select.type='button';unselect.type='button';element.parentNode.insertBefore(select,element);element.parentNode.insertBefore(unselect,element);select.addEventListener('click',function(){let checkboxes=element.querySelectorAll("input[type='checkbox']");for(var i=0;i0){array.push(add.value);add.value="";element.value=JSON.stringify(array);check();if(event.key!=="Tab"){event.preventDefault();}} if((event.key==="Backspace"||event.key==="Delete")&&add.value===""){array.splice(-1,1);element.value=JSON.stringify(array);check();} diff --git a/public/dist/scripts/app.js b/public/dist/scripts/app.js index aaf4d119b9..93dad8c00d 100644 --- a/public/dist/scripts/app.js +++ b/public/dist/scripts/app.js @@ -375,8 +375,8 @@ var variations={digits:/\d/.test(password),lower:/[a-z]/.test(password),upper:/[ score+=(variationCount-1)*10;return parseInt(score);};var callback=function(){var score=calc(this.value);if(""===this.value)return(meter.className="password-meter");if(score>60)return(meter.className="password-meter strong");if(score>30)return(meter.className="password-meter medium");if(score>=0)return(meter.className="password-meter weak");};var meter=window.document.createElement("div");meter.className="password-meter";element.parentNode.insertBefore(meter,element.nextSibling);element.addEventListener("change",callback);element.addEventListener("keypress",callback);element.addEventListener("keyup",callback);element.addEventListener("keydown",callback);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-pell",controller:function(element,window,document,markdown,rtl){var div=document.createElement("div");element.className="pell hide";div.className="input pell";element.parentNode.insertBefore(div,element);element.tabIndex=-1;var turndownService=new TurndownService();turndownService.addRule("underline",{filter:["u"],replacement:function(content){return"__"+content+"__";}});var editor=window.pell.init({element:div,onChange:function onChange(html){alignText();element.value=turndownService.turndown(html);},defaultParagraphSeparator:"p",actions:[{name:"bold",icon:''},{name:"underline",icon:''},{name:"italic",icon:''},{name:"olist",icon:''},{name:"ulist",icon:''},{name:"link",icon:''}]});var clean=function(e){e.stopPropagation();e.preventDefault();var clipboardData=e.clipboardData||window.clipboardData;console.log(clipboardData.getData("Text"));window.pell.exec("insertText",clipboardData.getData("Text"));return true;};var alignText=function(){let paragraphs=editor.content.querySelectorAll('p,li');let last='';for(let paragraph of paragraphs){var content=paragraph.textContent;if(content.trim()===''){content=last.textContent;} if(rtl.isRTL(content)){paragraph.style.direction='rtl';paragraph.style.textAlign='right';} else{paragraph.style.direction='ltr';paragraph.style.textAlign='left';} -last=paragraph;}};var santize=function(e){clean(e);alignText(e);};element.addEventListener("change",function(){editor.content.innerHTML=markdown.render(element.value);alignText();});editor.content.setAttribute("placeholder",element.placeholder);editor.content.innerHTML=markdown.render(element.value);editor.content.tabIndex=0;alignText();editor.content.onkeydown=function preventTab(event){if(event.which===9){event.preventDefault();if(document.activeElement){var focussable=Array.prototype.filter.call(document.querySelectorAll('a:not([disabled]), button:not([disabled]), select:not([disabled]), input[type=text]:not([disabled]), input[type=checkbox]:not([disabled]), [tabindex]:not([disabled]):not([tabindex="-1"])'),function(element){return(element.offsetWidth>0||element.offsetHeight>0||element===document.activeElement);});var index=focussable.indexOf(document.activeElement);if(index>-1){if(event.shiftKey){var prevElement=focussable[index-1]||focussable[focussable.length-1];prevElement.focus();}else{var nextElement=focussable[index+1]||focussable[0];nextElement.focus();}}}}};div.addEventListener("paste",santize);div.addEventListener("drop",santize);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-remove",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-remove]")).map(function(obj){obj.addEventListener("click",function(){element.parentNode.removeChild(element);});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-run",repeat:false,controller:function(element,expression,container){let action=expression.parse(element.dataset["formsRun"]||'');element.addEventListener('click',function(){return container.path(action)();});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-select-all",controller:function(element){let select=document.createElement("button");let unselect=document.createElement("button");select.textContent='Select All';unselect.textContent='Unselect All';select.classList.add('link');select.classList.add('margin-top-tiny');select.classList.add('margin-start-small');select.classList.add('text-size-small');select.classList.add('pull-end');unselect.classList.add('link');unselect.classList.add('margin-top-tiny');unselect.classList.add('margin-start-small');unselect.classList.add('text-size-small');unselect.classList.add('pull-end');select.type='button';unselect.type='button';element.parentNode.insertBefore(select,element);element.parentNode.insertBefore(unselect,element);select.addEventListener('click',function(){let checkboxes=document.querySelectorAll("input[type='checkbox']");for(var i=0;i0||element.offsetHeight>0||element===document.activeElement);});var index=focussable.indexOf(document.activeElement);if(index>-1){if(event.shiftKey){var prevElement=focussable[index-1]||focussable[focussable.length-1];prevElement.focus();}else{var nextElement=focussable[index+1]||focussable[0];nextElement.focus();}}}}};div.addEventListener("paste",santize);div.addEventListener("drop",santize);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-remove",controller:function(element){Array.prototype.slice.call(element.querySelectorAll("[data-remove]")).map(function(obj){obj.addEventListener("click",function(){element.parentNode.removeChild(element);});});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-run",repeat:false,controller:function(element,expression,container){let action=expression.parse(element.dataset["formsRun"]||'');element.addEventListener('click',function(){return container.path(action)();});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-select-all",controller:function(element){let select=document.createElement("button");let unselect=document.createElement("button");select.textContent='Select All';unselect.textContent='Unselect All';select.classList.add('link');select.classList.add('margin-top-tiny');select.classList.add('margin-start-small');select.classList.add('text-size-small');select.classList.add('pull-end');unselect.classList.add('link');unselect.classList.add('margin-top-tiny');unselect.classList.add('margin-start-small');unselect.classList.add('text-size-small');unselect.classList.add('pull-end');select.type='button';unselect.type='button';element.parentNode.insertBefore(select,element);element.parentNode.insertBefore(unselect,element);select.addEventListener('click',function(){let checkboxes=element.querySelectorAll("input[type='checkbox']");for(var i=0;i0){array.push(add.value);add.value="";element.value=JSON.stringify(array);check();if(event.key!=="Tab"){event.preventDefault();}} if((event.key==="Backspace"||event.key==="Delete")&&add.value===""){array.splice(-1,1);element.value=JSON.stringify(array);check();} diff --git a/public/scripts/views/forms/select-all.js b/public/scripts/views/forms/select-all.js index 57263f2dcd..256b6dc931 100644 --- a/public/scripts/views/forms/select-all.js +++ b/public/scripts/views/forms/select-all.js @@ -31,18 +31,20 @@ element.parentNode.insertBefore(unselect, element); select.addEventListener('click', function () { - let checkboxes = document.querySelectorAll("input[type='checkbox']"); + let checkboxes = element.querySelectorAll("input[type='checkbox']"); for(var i = 0; i < checkboxes.length; i++) { checkboxes[i].checked = true; + checkboxes[i].dispatchEvent(new Event('change')); } }) unselect.addEventListener('click', function () { - let checkboxes = document.querySelectorAll("input[type='checkbox']"); + let checkboxes = element.querySelectorAll("input[type='checkbox']"); for(var i = 0; i < checkboxes.length; i++) { checkboxes[i].checked = false; + checkboxes[i].dispatchEvent(new Event('change')); } }) From e03748e74aedd97896b7f248b924c0508791bf9a Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 11 Jan 2021 19:18:01 +0530 Subject: [PATCH 04/38] fix: output of parse was not being used --- src/Appwrite/Utopia/Response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index ce22df225e..7e49df9197 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -257,7 +257,7 @@ class Response extends SwooleResponse $item = self::getFilter()->parse($output, $model); } - $this->json($output); + $this->json($item); } From dde064665bef3c8855243efe0c6277461ccb894e Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 11 Jan 2021 19:20:54 +0530 Subject: [PATCH 05/38] fix: output of parse was not being used --- src/Appwrite/Utopia/Response.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 7e49df9197..23a878046c 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -252,12 +252,12 @@ class Response extends SwooleResponse { $output = $this->output($document, $model); - // If filter is set, parse the item + // If filter is set, parse the output if(self::isFilter()){ - $item = self::getFilter()->parse($output, $model); + $output = self::getFilter()->parse($output, $model); } - $this->json($item); + $this->json($output); } From 432901dfbba9e6f3e7c7dc234a66a8a56daaf3d7 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 11 Jan 2021 22:18:08 +0530 Subject: [PATCH 06/38] feat: added e2e test for response filters --- tests/e2e/General/HTTPTest.php | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/e2e/General/HTTPTest.php b/tests/e2e/General/HTTPTest.php index 46672c1a71..1282a9e480 100644 --- a/tests/e2e/General/HTTPTest.php +++ b/tests/e2e/General/HTTPTest.php @@ -149,4 +149,41 @@ class HTTPTest extends Scope unlink(realpath(__DIR__ . '/../../resources/open-api3.json')); } + + public function testResponseHeader() { + + /** + * Test without header + */ + $response = $this->client->call(Client::METHOD_GET, '/locale/continents', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + ], $this->getHeaders())); + + $body = $response['body']; + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals($body['sum'], 7); + $this->assertEquals($body['continents'][0]['name'], 'Africa'); + $this->assertEquals($body['continents'][0]['code'], 'AF'); + $this->assertEquals($body['continents'][1]['name'], 'Antarctica'); + $this->assertEquals($body['continents'][1]['code'], 'AN'); + $this->assertEquals($body['continents'][2]['name'], 'Asia'); + $this->assertEquals($body['continents'][2]['code'], 'AS'); + + /** + * Test with header + */ + $response = $this->client->call(Client::METHOD_GET, '/locale/continents', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'x-appwrite-response-format' => '0.6.2' + ], $this->getHeaders())); + + $body = $response['body']; + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals($body['sum'], 7); + $this->assertEquals($body['continents']['AF'], 'Africa'); + $this->assertEquals($body['continents']['AN'], 'Antarctica'); + $this->assertEquals($body['continents']['AS'], 'Asia'); + } } \ No newline at end of file From 1d80281ef712efec47de013e968486385815c9f6 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Mon, 11 Jan 2021 23:52:05 +0200 Subject: [PATCH 07/38] Disable ratelimits --- app/controllers/shared/api.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index d64c46a2cd..4dc69b7850 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -1,5 +1,7 @@ check() && App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') { + $isPreviliggedUser = Auth::isPreviliggedUser(Authorization::$roles); + $isAppUser = Auth::isAppUser(Authorization::$roles); + + if (($abuse->check() // Route is rate-limited + && App::getEnv('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') // Abuse is not diabled + && (!$isAppUser && !$isPreviliggedUser)) // User is not an admin or API key + { throw new Exception('Too many requests', 429); } }, ['utopia', 'request', 'response', 'project', 'user', 'register'], 'api'); \ No newline at end of file From 62aea5205982a274e1aa5977f5ffd9323a2c25d2 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 00:01:45 +0200 Subject: [PATCH 08/38] Added docker login --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1eb92182f8..c395a2d73c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,12 @@ before_install: - mkdir -p $HOME/.docker - echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json - sudo service docker start + - > + if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then + set +x + echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin + set -x + fi install: - docker --version From 5b0343276eb9b071db1be9a14b65571bff4a6709 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 00:20:29 +0200 Subject: [PATCH 09/38] Removed server abuse limits --- app/controllers/api/users.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 9b124e0a90..76e20aad98 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -418,7 +418,6 @@ App::delete('/v1/users/:userId/sessions/:sessionId') ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_NONE) - ->label('abuse-limit', 100) ->param('userId', '', new UID(), 'User unique ID.') ->param('sessionId', null, new UID(), 'User unique session ID.') ->inject('response') @@ -465,7 +464,6 @@ App::delete('/v1/users/:userId/sessions') ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_NONE) - ->label('abuse-limit', 100) ->param('userId', '', new UID(), 'User unique ID.') ->inject('response') ->inject('projectDB') @@ -509,7 +507,6 @@ App::delete('/v1/users/:userId') ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_NONE) - ->label('abuse-limit', 100) ->param('userId', '', function () {return new UID();}, 'User unique ID.') ->inject('response') ->inject('projectDB') From ac8410d22b9b9b9d40b03484a45f39fa3779a09d Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 00:21:56 +0200 Subject: [PATCH 10/38] Added functions execution abuse limit --- app/controllers/api/functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 1a21dfb02c..35a807f949 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -629,6 +629,8 @@ App::post('/v1/functions/:functionId/executions') ->label('sdk.response.code', Response::STATUS_CODE_CREATED) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_EXECUTION) + ->label('abuse-limit', 60) + ->label('abuse-time', 60) ->param('functionId', '', new UID(), 'Function unique ID.') // ->param('async', 1, new Range(0, 1), 'Execute code asynchronously. Pass 1 for true, 0 for false. Default value is 1.', true) ->inject('response') From 86d43a32ef97655bd75141d87ec6b53c09acd3d8 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 00:22:20 +0200 Subject: [PATCH 11/38] Added sleep time to execution test --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 21539ace52..52d7e86445 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -530,6 +530,8 @@ class FunctionsCustomServerTest extends Scope ], ]; + sleep(20); + foreach ($envs as $key => $env) { $language = $env['language'] ?? ''; $version = $env['version'] ?? ''; From 798c902e0727b2bae0c23835c5acc85d4468b83d Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 00:45:01 +0200 Subject: [PATCH 12/38] Changed sleep time --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 52d7e86445..342568c2e5 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -530,8 +530,6 @@ class FunctionsCustomServerTest extends Scope ], ]; - sleep(20); - foreach ($envs as $key => $env) { $language = $env['language'] ?? ''; $version = $env['version'] ?? ''; @@ -593,7 +591,7 @@ class FunctionsCustomServerTest extends Scope $executionId = $execution['body']['$id'] ?? ''; $this->assertEquals(201, $execution['headers']['status-code']); - sleep(20); + sleep(30); $executions = $this->client->call(Client::METHOD_GET, '/functions/'.$functionId.'/executions', array_merge([ 'content-type' => 'application/json', From 3c3a2258289b22b09e0a9bfb5ec66ea02e2e6a4a Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 01:03:00 +0200 Subject: [PATCH 13/38] Debug failure --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 342568c2e5..0af53ae0d9 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -601,6 +601,11 @@ class FunctionsCustomServerTest extends Scope if($executions['body']['executions'][0]['status'] !== 'completed') { var_dump($env); var_dump($executions['body']['executions'][0]); + $stdout = ''; + $stderr = ''; + Console::execute('docker logs appwrite-worker-functions', '', $stdout, $stderr); + var_dump($stdout); + var_dump($stderr); } $this->assertEquals($executions['headers']['status-code'], 200); From 71e64e65bbe7d99bc88f1030e4e40fa5547a9bd3 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 01:46:12 +0200 Subject: [PATCH 14/38] Added long sleep --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 0af53ae0d9..377d728e11 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -455,6 +455,7 @@ class FunctionsCustomServerTest extends Scope public function testENVS():array { + sleep(120); /** * Test for SUCCESS */ From 73f2bb025ad38a1ac338d39a56cb80876367ae78 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 12 Jan 2021 17:41:40 +0545 Subject: [PATCH 15/38] introducing new temp environment variable --- .env | 3 ++- Dockerfile | 1 + app/config/variables.php | 8 ++++++++ app/views/install/compose.phtml | 1 + docker-compose.yml | 1 + tests/resources/docker/docker-compose.yml | 1 + 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.env b/.env index ce43bfd853..edaf39e425 100644 --- a/.env +++ b/.env @@ -34,4 +34,5 @@ _APP_FUNCTIONS_CPUS=1 _APP_FUNCTIONS_MEMORY=128 _APP_FUNCTIONS_MEMORY_SWAP=128 _APP_MAINTENANCE_INTERVAL=86400 -_APP_SYSTEM_RESPONSE_FORMAT= \ No newline at end of file +_APP_SYSTEM_RESPONSE_FORMAT= +_APP_USAGE_STATS= \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 37ad125ee1..0017d68dcb 100755 --- a/Dockerfile +++ b/Dockerfile @@ -99,6 +99,7 @@ ENV _APP_SERVER=swoole \ _APP_FUNCTIONS_MEMORY_SWAP=128 \ _APP_SETUP=self-hosted \ _APP_VERSION=$VERSION \ + _APP_USAGE_STATS=enabled \ # 1 Day = 86400 s _APP_MAINTENANCE_INTERVAL=86400 #ENV _APP_SMTP_SECURE '' diff --git a/app/config/variables.php b/app/config/variables.php index 80dd6fdb82..eb4fb63e31 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -93,6 +93,14 @@ return [ 'required' => false, 'question' => '', ], + [ + 'name' => '_APP_USAGE_STATS', + 'description' => 'This variable allows you to disable the collection and displaying of usage stats. This value is set to \'enabled\' by default, to disable the usage stats set the value to \'disabled\'. When disabled, it\'s recommended to turn off the Worker Usage, influxdb and telegraf containers for better resource usage.', + 'introduction' => '0.7.0', + 'default' => 'enabled', + 'required' => false, + 'question' => '', + ], ], ], [ diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 5d74fd8ef9..f06999ff10 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -76,6 +76,7 @@ services: - _APP_SMTP_SECURE - _APP_SMTP_USERNAME - _APP_SMTP_PASSWORD + - _APP_USAGE_STATS - _APP_INFLUXDB_HOST - _APP_INFLUXDB_PORT - _APP_STORAGE_LIMIT diff --git a/docker-compose.yml b/docker-compose.yml index 2acd6d3ed2..4fe2361881 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -100,6 +100,7 @@ services: - _APP_SMTP_SECURE - _APP_SMTP_USERNAME - _APP_SMTP_PASSWORD + - _APP_USAGE_STATS - _APP_INFLUXDB_HOST - _APP_INFLUXDB_PORT - _APP_STORAGE_LIMIT diff --git a/tests/resources/docker/docker-compose.yml b/tests/resources/docker/docker-compose.yml index c300ece0a6..9f4074c540 100644 --- a/tests/resources/docker/docker-compose.yml +++ b/tests/resources/docker/docker-compose.yml @@ -78,6 +78,7 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS + - _APP_USAGE_STATS - _APP_INFLUXDB_HOST - _APP_INFLUXDB_PORT - _APP_STORAGE_LIMIT From dc7e7d448a1d0a79ecd5b3349e51c16cc7c6bacb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 12 Jan 2021 19:20:17 +0545 Subject: [PATCH 16/38] disable project stats from influxdb if usage stats is disabled --- app/controllers/api/projects.php | 137 ++++++++++++++++--------------- 1 file changed, 73 insertions(+), 64 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 74a26dd48a..1b66127421 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -176,74 +176,83 @@ App::get('/v1/projects/:projectId/usage') throw new Exception('Project not found', 404); } - $period = [ - '24h' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), - 'end' => DateTime::createFromFormat('U', \strtotime('+1 hour')), - 'group' => '30m', - ], - '7d' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-7 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('now')), - 'group' => '1d', - ], - '30d' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-30 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('now')), - 'group' => '1d', - ], - '90d' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-90 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('now')), - 'group' => '1d', - ], - ]; + $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; + if($appUsageStatsEnabled) { - $client = $register->get('influxdb'); - - $requests = []; - $network = []; - $functions = []; - - if ($client) { - $start = $period[$range]['start']->format(DateTime::RFC3339); - $end = $period[$range]['end']->format(DateTime::RFC3339); - $database = $client->selectDB('telegraf'); - - // Requests - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $requests[] = [ - 'value' => (!empty($point['value'])) ? $point['value'] : 0, - 'date' => \strtotime($point['time']), - ]; - } - - // Network - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $network[] = [ - 'value' => (!empty($point['value'])) ? $point['value'] : 0, - 'date' => \strtotime($point['time']), - ]; - } - - // Functions - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $functions[] = [ - 'value' => (!empty($point['value'])) ? $point['value'] : 0, - 'date' => \strtotime($point['time']), - ]; + $period = [ + '24h' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), + 'end' => DateTime::createFromFormat('U', \strtotime('+1 hour')), + 'group' => '30m', + ], + '7d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-7 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '30d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-30 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '90d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-90 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + ]; + + $client = $register->get('influxdb'); + + $requests = []; + $network = []; + $functions = []; + + if ($client) { + $start = $period[$range]['start']->format(DateTime::RFC3339); + $end = $period[$range]['end']->format(DateTime::RFC3339); + $database = $client->selectDB('telegraf'); + + // Requests + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $requests[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } + + // Network + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $network[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } + + // Functions + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $functions[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } } + } else { + $requests = []; + $network = []; + $functions = []; } + // Users $projectDB->getCollection([ From 8ea9ee67c5aa175a78e24852bda8ee71d425cd2e Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 12 Jan 2021 18:36:21 +0200 Subject: [PATCH 17/38] Fix for console custom domain --- app/controllers/general.php | 7 ------- app/init.php | 11 +++++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 5d29e0d43c..81b90ba29a 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -51,13 +51,6 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo throw new Exception('Missing or unknown project ID', 400); } - $console->setAttribute('platforms', [ // Allways allow current host - '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, - 'name' => 'Current Host', - 'type' => 'web', - 'hostname' => $request->getHostname(), - ], Document::SET_TYPE_APPEND); - $referrer = $request->getReferer(); $origin = \parse_url($request->getOrigin($referrer), PHP_URL_HOST); $protocol = \parse_url($request->getOrigin($referrer), PHP_URL_SCHEME); diff --git a/app/init.php b/app/init.php index 887cac9b23..592b8ab7a3 100644 --- a/app/init.php +++ b/app/init.php @@ -319,7 +319,14 @@ App::setResource('deletes', function($register) { }, ['register']); // Test Mock -App::setResource('clients', function($console, $project) { +App::setResource('clients', function($request, $console, $project) { + $console->setAttribute('platforms', [ // Allways allow current host + '$collection' => Database::SYSTEM_COLLECTION_PLATFORMS, + 'name' => 'Current Host', + 'type' => 'web', + 'hostname' => $request->getHostname(), + ], Document::SET_TYPE_APPEND); + /** * Get All verified client URLs for both console and current projects * + Filter for duplicated entries @@ -345,7 +352,7 @@ App::setResource('clients', function($console, $project) { })))); return $clients; -}, ['console', 'project']); +}, ['request', 'console', 'project']); App::setResource('user', function($mode, $project, $console, $request, $response, $projectDB, $consoleDB) { /** @var Utopia\Swoole\Request $request */ From 0d7bfad8a7ed2fd2584c8e2d4b63f677b657ba73 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 06:32:36 +0545 Subject: [PATCH 18/38] usage stats env default value --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index edaf39e425..1cc5b84a31 100644 --- a/.env +++ b/.env @@ -35,4 +35,4 @@ _APP_FUNCTIONS_MEMORY=128 _APP_FUNCTIONS_MEMORY_SWAP=128 _APP_MAINTENANCE_INTERVAL=86400 _APP_SYSTEM_RESPONSE_FORMAT= -_APP_USAGE_STATS= \ No newline at end of file +_APP_USAGE_STATS=enabled \ No newline at end of file From 4534064afe61db9b1e45804ff7714efff7410566 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 06:33:02 +0545 Subject: [PATCH 19/38] Typo fix --- app/config/variables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/variables.php b/app/config/variables.php index eb4fb63e31..d713acd5bf 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -95,7 +95,7 @@ return [ ], [ 'name' => '_APP_USAGE_STATS', - 'description' => 'This variable allows you to disable the collection and displaying of usage stats. This value is set to \'enabled\' by default, to disable the usage stats set the value to \'disabled\'. When disabled, it\'s recommended to turn off the Worker Usage, influxdb and telegraf containers for better resource usage.', + 'description' => 'This variable allows you to disable the collection and displaying of usage stats. This value is set to \'enabled\' by default, to disable the usage stats set the value to \'disabled\'. When disabled, it\'s recommended to turn off the Worker Usage, Influxdb and Telegraf containers for better resource usage.', 'introduction' => '0.7.0', 'default' => 'enabled', 'required' => false, From 1fcd575f565af8d20490ad770ce43dcc49ea00aa Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 06:50:27 +0545 Subject: [PATCH 20/38] disable displaying project usage stats if usage stats disabled --- app/controllers/web/console.php | 2 +- app/views/console/home/index.phtml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index bddc8ea8bb..f11479fe88 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -122,7 +122,7 @@ App::get('/console/home') /** @var Utopia\View $layout */ $page = new View(__DIR__.'/../../views/console/home/index.phtml'); - + $page->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); $layout ->setParam('title', APP_NAME.' - Console') ->setParam('body', $page); diff --git a/app/views/console/home/index.phtml b/app/views/console/home/index.phtml index 173336728e..368b852d50 100644 --- a/app/views/console/home/index.phtml +++ b/app/views/console/home/index.phtml @@ -1,5 +1,6 @@ getParam('graph', false); +$usageStatsEnabled = $this->getParam('usageStatsEnabled',true); ?>
@@ -68,7 +69,7 @@ $graph = $this->getParam('graph', false); data-param-project-id="{{router.params.project}}" data-param-range="30d"> - +
From 8da252366d0a2007a4711195a4c7ce103ab59d46 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 06:55:52 +0545 Subject: [PATCH 21/38] Skip functions usage getting from influx if usage stats disabled --- app/controllers/api/functions.php | 181 +++++++++++++++--------------- 1 file changed, 93 insertions(+), 88 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 1a21dfb02c..27dd759312 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -156,96 +156,101 @@ App::get('/v1/functions/:functionId/usage') if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { throw new Exception('Function not found', 404); } - - $period = [ - '24h' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), - 'end' => DateTime::createFromFormat('U', \strtotime('+1 hour')), - 'group' => '30m', - ], - '7d' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-7 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('now')), - 'group' => '1d', - ], - '30d' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-30 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('now')), - 'group' => '1d', - ], - '90d' => [ - 'start' => DateTime::createFromFormat('U', \strtotime('-90 days')), - 'end' => DateTime::createFromFormat('U', \strtotime('now')), - 'group' => '1d', - ], - ]; - - $client = $register->get('influxdb'); - - $executions = []; - $failures = []; - $compute = []; - - if ($client) { - $start = $period[$range]['start']->format(DateTime::RFC3339); - $end = $period[$range]['end']->format(DateTime::RFC3339); - $database = $client->selectDB('telegraf'); - - // Executions - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $executions[] = [ - 'value' => (!empty($point['value'])) ? $point['value'] : 0, - 'date' => \strtotime($point['time']), - ]; - } - - // Failures - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' AND "functionStatus"=\'failed\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $failures[] = [ - 'value' => (!empty($point['value'])) ? $point['value'] : 0, - 'date' => \strtotime($point['time']), - ]; - } - - // Compute - $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_time" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); - $points = $result->getPoints(); - - foreach ($points as $point) { - $compute[] = [ - 'value' => round((!empty($point['value'])) ? $point['value'] / 1000 : 0, 2), // minutes - 'date' => \strtotime($point['time']), - ]; + //check if stats is disabled + $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; + if($appUsageStatsEnabled) { + $period = [ + '24h' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), + 'end' => DateTime::createFromFormat('U', \strtotime('+1 hour')), + 'group' => '30m', + ], + '7d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-7 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '30d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-30 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + '90d' => [ + 'start' => DateTime::createFromFormat('U', \strtotime('-90 days')), + 'end' => DateTime::createFromFormat('U', \strtotime('now')), + 'group' => '1d', + ], + ]; + + $client = $register->get('influxdb'); + + $executions = []; + $failures = []; + $compute = []; + + if ($client) { + $start = $period[$range]['start']->format(DateTime::RFC3339); + $end = $period[$range]['end']->format(DateTime::RFC3339); + $database = $client->selectDB('telegraf'); + + // Executions + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $executions[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } + + // Failures + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' AND "functionStatus"=\'failed\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $failures[] = [ + 'value' => (!empty($point['value'])) ? $point['value'] : 0, + 'date' => \strtotime($point['time']), + ]; + } + + // Compute + $result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_executions_time" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' AND "functionId"=\''.$function->getId().'\' GROUP BY time('.$period[$range]['group'].') FILL(null)'); + $points = $result->getPoints(); + + foreach ($points as $point) { + $compute[] = [ + 'value' => round((!empty($point['value'])) ? $point['value'] / 1000 : 0, 2), // minutes + 'date' => \strtotime($point['time']), + ]; + } } + + $response->json([ + 'range' => $range, + 'executions' => [ + 'data' => $executions, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $executions)), + ], + 'failures' => [ + 'data' => $failures, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $failures)), + ], + 'compute' => [ + 'data' => $compute, + 'total' => \array_sum(\array_map(function ($item) { + return $item['value']; + }, $compute)), + ], + ]); + } else { + $response->json([]); } - - $response->json([ - 'range' => $range, - 'executions' => [ - 'data' => $executions, - 'total' => \array_sum(\array_map(function ($item) { - return $item['value']; - }, $executions)), - ], - 'failures' => [ - 'data' => $failures, - 'total' => \array_sum(\array_map(function ($item) { - return $item['value']; - }, $failures)), - ], - 'compute' => [ - 'data' => $compute, - 'total' => \array_sum(\array_map(function ($item) { - return $item['value']; - }, $compute)), - ], - ]); }); App::put('/v1/functions/:functionId') From 075dd222ac6dd54c77e3958309bf16dba40712b0 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 07:25:23 +0545 Subject: [PATCH 22/38] Function monitor view, hide stats graphs if stats disabled --- app/controllers/web/console.php | 1 + app/views/console/functions/function.phtml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index f11479fe88..dadda3ec13 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -390,6 +390,7 @@ App::get('/console/functions/function') ->setParam('fileLimit', App::getEnv('_APP_STORAGE_LIMIT', 0)) ->setParam('fileLimitHuman', Storage::human(App::getEnv('_APP_STORAGE_LIMIT', 0))) ->setParam('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)) + ->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); ; $layout diff --git a/app/views/console/functions/function.phtml b/app/views/console/functions/function.phtml index 2c262c5bed..e31e3eab65 100644 --- a/app/views/console/functions/function.phtml +++ b/app/views/console/functions/function.phtml @@ -3,6 +3,7 @@ $fileLimit = $this->getParam('fileLimit', 0); $fileLimitHuman = $this->getParam('fileLimitHuman', 0); $events = array_keys($this->getParam('events', [])); $timeout = $this->getParam('timeout', 900); +$usageStatsEnabled = $this->getParam('usageStatsEnabled',true); ?>
getParam('timeout', 900); data-event="load" data-name="usage" data-param-function-id="{{router.params.id}}"> +
@@ -316,6 +318,9 @@ $timeout = $this->getParam('timeout', 900);
  • Errors
+ +

Usage stats is disabled.

+
  • From f06e92436eb5afbdbd81356a42069d5d504d7b30 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 07:44:42 +0545 Subject: [PATCH 23/38] app shutdown disable stats collection --- app/controllers/general.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 5d29e0d43c..501662e938 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -316,16 +316,18 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits } $route = $utopia->match($request); - - if ($project->getId() - && $mode !== APP_MODE_ADMIN //TODO: add check to make sure user is admin - && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage on admin mode - - $usage - ->setParam('networkRequestSize', $request->getSize() + $usage->getParam('storage')) - ->setParam('networkResponseSize', $response->getSize()) - ->trigger() - ; + $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; + if($appUsageStatsEnabled) { + if ($project->getId() + && $mode !== APP_MODE_ADMIN //TODO: add check to make sure user is admin + && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage on admin mode + + $usage + ->setParam('networkRequestSize', $request->getSize() + $usage->getParam('storage')) + ->setParam('networkResponseSize', $response->getSize()) + ->trigger() + ; + } } }, ['utopia', 'request', 'response', 'project', 'events', 'audits', 'usage', 'deletes', 'mode']); From 1cbca0a6a60ba08a92729d95dfb54f39f7cf1ef0 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 11:42:15 +0545 Subject: [PATCH 24/38] disable functions stats collection if usage stats disabled --- app/views/install/compose.phtml | 1 + app/workers/functions.php | 6 ++++-- docker-compose.yml | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index f06999ff10..9a2141a5c1 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -240,6 +240,7 @@ services: - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY - _APP_FUNCTIONS_MEMORY_SWAP + - _APP_USAGE_STATS appwrite-worker-mails: image: appwrite/appwrite: diff --git a/app/workers/functions.php b/app/workers/functions.php index ab43914078..51a18865ec 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -470,8 +470,10 @@ class FunctionsV1 ->setParam('networkRequestSize', 0) ->setParam('networkResponseSize', 0) ; - - $usage->trigger(); + $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; + if($appUsageStatsEnabled) { + $usage->trigger(); + } $this->cleanup(); } diff --git a/docker-compose.yml b/docker-compose.yml index 4fe2361881..83024b8296 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -293,6 +293,7 @@ services: - _APP_FUNCTIONS_CPUS - _APP_FUNCTIONS_MEMORY - _APP_FUNCTIONS_MEMORY_SWAP + - _APP_USAGE_STATS appwrite-worker-mails: entrypoint: worker-mails From 68593f55b7f67ee130c1663866cc4b42a7081910 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 11:57:57 +0545 Subject: [PATCH 25/38] remove extra space --- app/views/console/functions/function.phtml | 2 +- app/views/console/home/index.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/console/functions/function.phtml b/app/views/console/functions/function.phtml index e31e3eab65..dab40a4d91 100644 --- a/app/views/console/functions/function.phtml +++ b/app/views/console/functions/function.phtml @@ -282,7 +282,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true); data-event="load" data-name="usage" data-param-function-id="{{router.params.id}}"> - +
    diff --git a/app/views/console/home/index.phtml b/app/views/console/home/index.phtml index 368b852d50..0fc6838eb6 100644 --- a/app/views/console/home/index.phtml +++ b/app/views/console/home/index.phtml @@ -69,7 +69,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true); data-param-project-id="{{router.params.project}}" data-param-range="30d"> - +
    From f812437dae884d06dbc86f9a1cc5add400cddaa3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 11:59:25 +0545 Subject: [PATCH 26/38] refactoring to use existing conditional --- app/controllers/general.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 501662e938..7e053afb74 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -316,18 +316,16 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits } $route = $utopia->match($request); - $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; - if($appUsageStatsEnabled) { - if ($project->getId() - && $mode !== APP_MODE_ADMIN //TODO: add check to make sure user is admin - && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage on admin mode - - $usage - ->setParam('networkRequestSize', $request->getSize() + $usage->getParam('storage')) - ->setParam('networkResponseSize', $response->getSize()) - ->trigger() - ; - } + if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled' + && $project->getId() + && $mode !== APP_MODE_ADMIN //TODO: add check to make sure user is admin + && !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage on admin mode + + $usage + ->setParam('networkRequestSize', $request->getSize() + $usage->getParam('storage')) + ->setParam('networkResponseSize', $response->getSize()) + ->trigger() + ; } }, ['utopia', 'request', 'response', 'project', 'events', 'audits', 'usage', 'deletes', 'mode']); From d345aac92fd1d15c0805f7fb58a51d42a8fe3a70 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 12:00:32 +0545 Subject: [PATCH 27/38] disabling monitors tab completely --- app/views/console/functions/function.phtml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/console/functions/function.phtml b/app/views/console/functions/function.phtml index dab40a4d91..e1203dd027 100644 --- a/app/views/console/functions/function.phtml +++ b/app/views/console/functions/function.phtml @@ -241,6 +241,7 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
  • +
  • getParam('usageStatsEnabled',true); data-event="load" data-name="usage" data-param-function-id="{{router.params.id}}"> -
    @@ -318,11 +318,9 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
    • Errors
    - -

    Usage stats is disabled.

    -
  • +
  • From 379ce3abceb3e026b1e6267b063f3a6a9247970a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 12:10:43 +0545 Subject: [PATCH 28/38] refactoring with suggested updates --- app/controllers/api/functions.php | 5 ++--- app/controllers/api/projects.php | 3 +-- app/controllers/web/console.php | 3 ++- app/workers/functions.php | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 27dd759312..bad97b3971 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -156,9 +156,8 @@ App::get('/v1/functions/:functionId/usage') if (empty($function->getId()) || Database::SYSTEM_COLLECTION_FUNCTIONS != $function->getCollection()) { throw new Exception('Function not found', 404); } - //check if stats is disabled - $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; - if($appUsageStatsEnabled) { + + if($App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $period = [ '24h' => [ 'start' => DateTime::createFromFormat('U', \strtotime('-24 hours')), diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 1b66127421..1d8e18d00c 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -176,8 +176,7 @@ App::get('/v1/projects/:projectId/usage') throw new Exception('Project not found', 404); } - $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; - if($appUsageStatsEnabled) { + if($App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $period = [ '24h' => [ diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index dadda3ec13..b8fc5a621e 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -122,7 +122,8 @@ App::get('/console/home') /** @var Utopia\View $layout */ $page = new View(__DIR__.'/../../views/console/home/index.phtml'); - $page->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); + $page + ->setParam('usageStatsEnabled',App::getEnv('_APP_USAGE_STATS','enabled') == 'enabled'); $layout ->setParam('title', APP_NAME.' - Console') ->setParam('body', $page); diff --git a/app/workers/functions.php b/app/workers/functions.php index 51a18865ec..bb74bb0e60 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -470,8 +470,8 @@ class FunctionsV1 ->setParam('networkRequestSize', 0) ->setParam('networkResponseSize', 0) ; - $appUsageStatsEnabled = App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled'; - if($appUsageStatsEnabled) { + + if($App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $usage->trigger(); } From 671f794403d8bfc522e75a93c1724c06d4b6ffc6 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Jan 2021 12:52:28 +0545 Subject: [PATCH 29/38] Fix typo causing error --- app/controllers/api/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 1d8e18d00c..0b22e40614 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -176,7 +176,7 @@ App::get('/v1/projects/:projectId/usage') throw new Exception('Project not found', 404); } - if($App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { + if(App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') { $period = [ '24h' => [ From 5ed2eea208b71fe206338ff69be31b2a16ef8702 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 13 Jan 2021 16:11:07 +0200 Subject: [PATCH 30/38] Changed role names --- src/Appwrite/Auth/Auth.php | 14 +++++++------- tests/e2e/Services/Database/DatabaseBase.php | 4 ++-- .../Services/Database/DatabaseCustomServerTest.php | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index 88eb11299d..e1a933ee76 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -16,13 +16,13 @@ class Auth /** * User Roles. */ - const USER_ROLE_GUEST = 0; - const USER_ROLE_MEMBER = 1; - const USER_ROLE_ADMIN = 2; - const USER_ROLE_DEVELOPER = 3; - const USER_ROLE_OWNER = 4; - const USER_ROLE_APP = 5; - const USER_ROLE_SYSTEM = 6; + const USER_ROLE_GUEST = 'guest'; + const USER_ROLE_MEMBER = 'member'; + const USER_ROLE_ADMIN = 'admin'; + const USER_ROLE_DEVELOPER = 'developer'; + const USER_ROLE_OWNER = 'owner'; + const USER_ROLE_APP = 'app'; + const USER_ROLE_SYSTEM = 'system'; /** * Token Types. diff --git a/tests/e2e/Services/Database/DatabaseBase.php b/tests/e2e/Services/Database/DatabaseBase.php index f769184827..8285cb2076 100644 --- a/tests/e2e/Services/Database/DatabaseBase.php +++ b/tests/e2e/Services/Database/DatabaseBase.php @@ -18,7 +18,7 @@ trait DatabaseBase ]), [ 'name' => 'Actors', 'read' => ['*'], - 'write' => ['role:1', 'role:2'], + 'write' => ['role:member', 'role:admin'], 'rules' => [ [ 'label' => 'First Name', @@ -55,7 +55,7 @@ trait DatabaseBase ]), [ 'name' => 'Movies', 'read' => ['*'], - 'write' => ['role:1', 'role:2'], + 'write' => ['role:member', 'role:admin'], 'rules' => [ [ 'label' => 'Name', diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 2f0bdfc766..3bb9c3e82d 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -27,7 +27,7 @@ class DatabaseCustomServerTest extends Scope ]), [ 'name' => 'Actors', 'read' => ['*'], - 'write' => ['role:1', 'role:2'], + 'write' => ['role:member', 'role:admin'], 'rules' => [ [ 'label' => 'First Name', From 764672e15e8c3a4c0c3891d620d293e1ead9045c Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 13 Jan 2021 17:06:36 +0200 Subject: [PATCH 31/38] Updated default values --- src/Appwrite/Utopia/Response/Model/Collection.php | 5 +++++ src/Appwrite/Utopia/Response/Model/Continent.php | 2 ++ src/Appwrite/Utopia/Response/Model/Country.php | 2 ++ src/Appwrite/Utopia/Response/Model/Currency.php | 7 +++++++ src/Appwrite/Utopia/Response/Model/Domain.php | 5 +++++ src/Appwrite/Utopia/Response/Model/Error.php | 3 +++ src/Appwrite/Utopia/Response/Model/ErrorDev.php | 3 +++ src/Appwrite/Utopia/Response/Model/Execution.php | 9 +++++++++ src/Appwrite/Utopia/Response/Model/File.php | 7 +++++++ src/Appwrite/Utopia/Response/Model/Func.php | 11 +++++++++-- src/Appwrite/Utopia/Response/Model/Key.php | 3 +++ src/Appwrite/Utopia/Response/Model/Language.php | 3 +++ src/Appwrite/Utopia/Response/Model/Locale.php | 6 ++++++ src/Appwrite/Utopia/Response/Model/Log.php | 3 +++ src/Appwrite/Utopia/Response/Model/Membership.php | 6 ++++++ src/Appwrite/Utopia/Response/Model/Permissions.php | 2 ++ src/Appwrite/Utopia/Response/Model/Phone.php | 3 +++ src/Appwrite/Utopia/Response/Model/Platform.php | 5 +++++ src/Appwrite/Utopia/Response/Model/Project.php | 2 ++ src/Appwrite/Utopia/Response/Model/Rule.php | 8 +++++++- src/Appwrite/Utopia/Response/Model/Session.php | 1 + src/Appwrite/Utopia/Response/Model/Tag.php | 5 +++++ src/Appwrite/Utopia/Response/Model/Task.php | 7 +++++++ src/Appwrite/Utopia/Response/Model/Team.php | 3 +++ src/Appwrite/Utopia/Response/Model/Token.php | 4 +++- src/Appwrite/Utopia/Response/Model/User.php | 5 +++++ src/Appwrite/Utopia/Response/Model/Webhook.php | 4 ++++ 27 files changed, 120 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/Collection.php b/src/Appwrite/Utopia/Response/Model/Collection.php index 1fce01bbbe..9b1f184b97 100644 --- a/src/Appwrite/Utopia/Response/Model/Collection.php +++ b/src/Appwrite/Utopia/Response/Model/Collection.php @@ -13,27 +13,32 @@ class Collection extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Collection ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('$permissions', [ 'type' => Response::MODEL_PERMISSIONS, 'description' => 'Collection permissions.', + 'default' => new \stdClass, 'example' => new \stdClass, 'array' => false, ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Collection name.', + 'default' => '', 'example' => 'Movies', ]) ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'Collection creation date in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('dateUpdated', [ 'type' => self::TYPE_INTEGER, 'description' => 'Collection creation date in Unix timestamp.', + 'default' => 0, 'example' => 1592981550, ]) ->addRule('rules', [ diff --git a/src/Appwrite/Utopia/Response/Model/Continent.php b/src/Appwrite/Utopia/Response/Model/Continent.php index faae10c141..82948b646a 100644 --- a/src/Appwrite/Utopia/Response/Model/Continent.php +++ b/src/Appwrite/Utopia/Response/Model/Continent.php @@ -13,11 +13,13 @@ class Continent extends Model ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Continent name.', + 'default' => '', 'example' => 'Europe', ]) ->addRule('code', [ 'type' => self::TYPE_STRING, 'description' => 'Continent two letter code.', + 'default' => '', 'example' => 'EU', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Country.php b/src/Appwrite/Utopia/Response/Model/Country.php index f9b5ae8784..85ed0a2d5d 100644 --- a/src/Appwrite/Utopia/Response/Model/Country.php +++ b/src/Appwrite/Utopia/Response/Model/Country.php @@ -13,11 +13,13 @@ class Country extends Model ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Country name.', + 'default' => '', 'example' => 'United States', ]) ->addRule('code', [ 'type' => self::TYPE_STRING, 'description' => 'Country two-character ISO 3166-1 alpha code.', + 'default' => '', 'example' => 'US', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Currency.php b/src/Appwrite/Utopia/Response/Model/Currency.php index e912f2ab4d..ac5cb9d060 100644 --- a/src/Appwrite/Utopia/Response/Model/Currency.php +++ b/src/Appwrite/Utopia/Response/Model/Currency.php @@ -13,36 +13,43 @@ class Currency extends Model ->addRule('symbol', [ 'type' => self::TYPE_STRING, 'description' => 'Currency symbol.', + 'default' => '', 'example' => '$', ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Currency name.', + 'default' => '', 'example' => 'US dollar', ]) ->addRule('symbolNative', [ 'type' => self::TYPE_STRING, 'description' => 'Currency native symbol.', + 'default' => '', 'example' => '$', ]) ->addRule('decimalDigits', [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of decimal digits.', + 'default' => 0, 'example' => 2, ]) ->addRule('rounding', [ 'type' => self::TYPE_FLOAT, 'description' => 'Currency digit rounding.', + 'default' => 0, 'example' => 0, ]) ->addRule('code', [ 'type' => self::TYPE_STRING, 'description' => 'Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format.', + 'default' => '', 'example' => 'USD', ]) ->addRule('namePlural', [ 'type' => self::TYPE_STRING, 'description' => 'Currency plural name', + 'default' => '', 'example' => 'US dollars', ]) // ->addRule('locations', [ diff --git a/src/Appwrite/Utopia/Response/Model/Domain.php b/src/Appwrite/Utopia/Response/Model/Domain.php index 2e58a3053f..46aff1a567 100644 --- a/src/Appwrite/Utopia/Response/Model/Domain.php +++ b/src/Appwrite/Utopia/Response/Model/Domain.php @@ -18,26 +18,31 @@ class Domain extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Domain ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('domain', [ 'type' => self::TYPE_STRING, 'description' => 'Domain name.', + 'default' => '', 'example' => 'appwrite.company.com', ]) ->addRule('registerable', [ 'type' => self::TYPE_STRING, 'description' => 'Registerable domain name.', + 'default' => '', 'example' => 'company.com', ]) ->addRule('tld', [ 'type' => self::TYPE_STRING, 'description' => 'TLD name.', + 'default' => '', 'example' => 'com', ]) ->addRule('verification', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Verification process status.', + 'default' => false, 'example' => true, ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Error.php b/src/Appwrite/Utopia/Response/Model/Error.php index 3ce03bc671..48e30cd817 100644 --- a/src/Appwrite/Utopia/Response/Model/Error.php +++ b/src/Appwrite/Utopia/Response/Model/Error.php @@ -13,16 +13,19 @@ class Error extends Model ->addRule('message', [ 'type' => self::TYPE_STRING, 'description' => 'Error message.', + 'default' => '', 'example' => 'Not found', ]) ->addRule('code', [ 'type' => self::TYPE_STRING, 'description' => 'Error code.', + 'default' => '', 'example' => '404', ]) ->addRule('version', [ 'type' => self::TYPE_STRING, 'description' => 'Server version number.', + 'default' => '', 'example' => '1.0', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/ErrorDev.php b/src/Appwrite/Utopia/Response/Model/ErrorDev.php index d4a667529d..9fa0c4095a 100644 --- a/src/Appwrite/Utopia/Response/Model/ErrorDev.php +++ b/src/Appwrite/Utopia/Response/Model/ErrorDev.php @@ -19,16 +19,19 @@ class ErrorDev extends Error ->addRule('file', [ 'type' => self::TYPE_STRING, 'description' => 'File path.', + 'default' => '', 'example' => '/usr/code/vendor/utopia-php/framework/src/App.php', ]) ->addRule('line', [ 'type' => self::TYPE_INTEGER, 'description' => 'Line number.', + 'default' => 0, 'example' => 209, ]) ->addRule('trace', [ 'type' => self::TYPE_STRING, 'description' => 'Error trace.', + 'default' => [], 'example' => [ '' ], diff --git a/src/Appwrite/Utopia/Response/Model/Execution.php b/src/Appwrite/Utopia/Response/Model/Execution.php index c1183d6b24..a5ad4cc75d 100644 --- a/src/Appwrite/Utopia/Response/Model/Execution.php +++ b/src/Appwrite/Utopia/Response/Model/Execution.php @@ -13,46 +13,55 @@ class Execution extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Execution ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('functionId', [ 'type' => self::TYPE_STRING, 'description' => 'Function ID.', + 'default' => '', 'example' => '5e5ea6g16897e', ]) ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'The execution creation date in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('trigger', [ 'type' => self::TYPE_STRING, 'description' => 'The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.', + 'default' => '', 'example' => 'http', ]) ->addRule('status', [ 'type' => self::TYPE_STRING, 'description' => 'The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.', + 'default' => '', 'example' => 'processing', ]) ->addRule('exitCode', [ 'type' => self::TYPE_INTEGER, 'description' => 'The script exit code.', + 'default' => 0, 'example' => 0, ]) ->addRule('stdout', [ 'type' => self::TYPE_STRING, 'description' => 'The script stdout output string.', + 'default' => '', 'example' => '', ]) ->addRule('stderr', [ 'type' => self::TYPE_STRING, 'description' => 'The script stderr output string.', + 'default' => '', 'example' => '', ]) ->addRule('time', [ 'type' => self::TYPE_FLOAT, 'description' => 'The script execution time in seconds.', + 'default' => '', 'example' => 0.400, ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/File.php b/src/Appwrite/Utopia/Response/Model/File.php index a7ad05e1e4..a731baddf9 100644 --- a/src/Appwrite/Utopia/Response/Model/File.php +++ b/src/Appwrite/Utopia/Response/Model/File.php @@ -13,37 +13,44 @@ class File extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'File ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('$permissions', [ 'type' => Response::MODEL_PERMISSIONS, 'description' => 'File permissions.', + 'default' => '', 'example' => new \stdClass, 'array' => false, ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'File name.', + 'default' => '', 'example' => 'Pink.png', ]) ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'File creation date in Unix timestamp.', + 'default' => '', 'example' => 1592981250, ]) ->addRule('signature', [ 'type' => self::TYPE_STRING, 'description' => 'File MD5 signature.', + 'default' => '', 'example' => '5d529fd02b544198ae075bd57c1762bb', ]) ->addRule('mimeType', [ 'type' => self::TYPE_STRING, 'description' => 'File mime type.', + 'default' => '', 'example' => 'image/png', ]) ->addRule('sizeOriginal', [ 'type' => self::TYPE_INTEGER, 'description' => 'File original size in bytes.', + 'default' => '', 'example' => 17890, ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index 8802c56dec..067a4741d7 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -13,37 +13,44 @@ class Func extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Function ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('$permissions', [ 'type' => Response::MODEL_PERMISSIONS, 'description' => 'Function permissions.', + 'default' => new \stdClass, 'example' => new \stdClass, 'array' => false, ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Function name.', + 'default' => '', 'example' => 'My Function', ]) ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'Function creation date in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('dateUpdated', [ 'type' => self::TYPE_INTEGER, 'description' => 'Function update date in Unix timestamp.', + 'default' => 0, 'example' => 1592981257, ]) ->addRule('status', [ 'type' => self::TYPE_STRING, 'description' => 'Function status. Possible values: disabled, enabled', + 'default' => '', 'example' => 'enabled', ]) ->addRule('env', [ 'type' => self::TYPE_STRING, 'description' => 'Function execution environment.', + 'default' => '', 'example' => 'python-3.8', ]) ->addRule('tag', [ @@ -74,14 +81,14 @@ class Func extends Model ->addRule('scheduleNext', [ 'type' => self::TYPE_INTEGER, 'description' => 'Function next scheduled execution date in Unix timestamp.', - 'example' => 1592981292, 'default' => 0, + 'example' => 1592981292, ]) ->addRule('schedulePrevious', [ 'type' => self::TYPE_INTEGER, 'description' => 'Function next scheduled execution date in Unix timestamp.', - 'example' => 1592981237, 'default' => 0, + 'example' => 1592981237, ]) ->addRule('timeout', [ 'type' => self::TYPE_INTEGER, diff --git a/src/Appwrite/Utopia/Response/Model/Key.php b/src/Appwrite/Utopia/Response/Model/Key.php index 28be3adbf5..c939382cc2 100644 --- a/src/Appwrite/Utopia/Response/Model/Key.php +++ b/src/Appwrite/Utopia/Response/Model/Key.php @@ -18,11 +18,13 @@ class Key extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Key ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Key name.', + 'default' => '', 'example' => 'My API Key', ]) ->addRule('scopes', [ @@ -35,6 +37,7 @@ class Key extends Model ->addRule('secret', [ 'type' => self::TYPE_STRING, 'description' => 'Secret key.', + 'default' => '', 'example' => '919c2d18fb5d4...a2ae413da83346ad2', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Language.php b/src/Appwrite/Utopia/Response/Model/Language.php index e2dd8d638f..8819b520bb 100644 --- a/src/Appwrite/Utopia/Response/Model/Language.php +++ b/src/Appwrite/Utopia/Response/Model/Language.php @@ -13,16 +13,19 @@ class Language extends Model ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Language name.', + 'default' => '', 'example' => 'Italian', ]) ->addRule('code', [ 'type' => self::TYPE_STRING, 'description' => 'Language two-character ISO 639-1 codes.', + 'default' => '', 'example' => 'it', ]) ->addRule('nativeName', [ 'type' => self::TYPE_STRING, 'description' => 'Language native name.', + 'default' => '', 'example' => 'Italiano', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Locale.php b/src/Appwrite/Utopia/Response/Model/Locale.php index d67470a39e..7f430d8072 100644 --- a/src/Appwrite/Utopia/Response/Model/Locale.php +++ b/src/Appwrite/Utopia/Response/Model/Locale.php @@ -13,26 +13,31 @@ class Locale extends Model ->addRule('ip', [ 'type' => self::TYPE_STRING, 'description' => 'User IP address.', + 'default' => '', 'example' => '127.0.0.1', ]) ->addRule('countryCode', [ 'type' => self::TYPE_STRING, 'description' => 'Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format', + 'default' => '', 'example' => 'US', ]) ->addRule('country', [ 'type' => self::TYPE_STRING, 'description' => 'Country name. This field support localization.', + 'default' => '', 'example' => 'United States', ]) ->addRule('continentCode', [ 'type' => self::TYPE_STRING, 'description' => 'Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America.', + 'default' => '', 'example' => 'NA', ]) ->addRule('continent', [ 'type' => self::TYPE_STRING, 'description' => 'Continent name. This field support localization.', + 'default' => '', 'example' => 'North America', ]) ->addRule('eu', [ @@ -44,6 +49,7 @@ class Locale extends Model ->addRule('currency', [ 'type' => self::TYPE_STRING, 'description' => 'Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format', + 'default' => '', 'example' => 'USD', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Log.php b/src/Appwrite/Utopia/Response/Model/Log.php index dc3bb6955e..baf2f83347 100644 --- a/src/Appwrite/Utopia/Response/Model/Log.php +++ b/src/Appwrite/Utopia/Response/Model/Log.php @@ -13,16 +13,19 @@ class Log extends Model ->addRule('event', [ 'type' => self::TYPE_STRING, 'description' => 'Event name.', + 'default' => '', 'example' => 'account.sessions.create', ]) ->addRule('ip', [ 'type' => self::TYPE_STRING, 'description' => 'IP session in use when the session was created.', + 'default' => '', 'example' => '127.0.0.1', ]) ->addRule('time', [ 'type' => self::TYPE_INTEGER, 'description' => 'Log creation time in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('osCode', [ diff --git a/src/Appwrite/Utopia/Response/Model/Membership.php b/src/Appwrite/Utopia/Response/Model/Membership.php index 34f60a72b8..e5be5d3d1d 100644 --- a/src/Appwrite/Utopia/Response/Model/Membership.php +++ b/src/Appwrite/Utopia/Response/Model/Membership.php @@ -13,16 +13,19 @@ class Membership extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Membership ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('userId', [ 'type' => self::TYPE_STRING, 'description' => 'User ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('teamId', [ 'type' => self::TYPE_STRING, 'description' => 'Team ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ @@ -40,16 +43,19 @@ class Membership extends Model ->addRule('invited', [ 'type' => self::TYPE_INTEGER, 'description' => 'Date, the user has been invited to join the team in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('joined', [ 'type' => self::TYPE_INTEGER, 'description' => 'Date, the user has accepted the invitation to join the team in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('confirm', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'User confirmation status, true if the user has joined the team or false otherwise.', + 'default' => false, 'example' => false, ]) ->addRule('roles', [ diff --git a/src/Appwrite/Utopia/Response/Model/Permissions.php b/src/Appwrite/Utopia/Response/Model/Permissions.php index 3847bd9387..0377d2e1f8 100644 --- a/src/Appwrite/Utopia/Response/Model/Permissions.php +++ b/src/Appwrite/Utopia/Response/Model/Permissions.php @@ -13,12 +13,14 @@ class Permissions extends Model ->addRule('read', [ 'type' => self::TYPE_STRING, 'description' => 'Read permissions.', + 'default' => [], 'example' => ['*', 'user:5e5ea5c16897e'], 'array' => true, ]) ->addRule('write', [ 'type' => self::TYPE_STRING, 'description' => 'Write permissions.', + 'default' => [], 'example' => ['*', 'user:5e5ea5c16897e'], 'array' => true, ]) diff --git a/src/Appwrite/Utopia/Response/Model/Phone.php b/src/Appwrite/Utopia/Response/Model/Phone.php index 0d47ebb867..e077193e8d 100644 --- a/src/Appwrite/Utopia/Response/Model/Phone.php +++ b/src/Appwrite/Utopia/Response/Model/Phone.php @@ -13,16 +13,19 @@ class Phone extends Model ->addRule('code', [ 'type' => self::TYPE_STRING, 'description' => 'Phone code.', + 'default' => '', 'example' => '+1', ]) ->addRule('countryCode', [ 'type' => self::TYPE_STRING, 'description' => 'Country two-character ISO 3166-1 alpha code.', + 'default' => '', 'example' => 'US', ]) ->addRule('countryName', [ 'type' => self::TYPE_STRING, 'description' => 'Country name.', + 'default' => '', 'example' => 'United States', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Platform.php b/src/Appwrite/Utopia/Response/Model/Platform.php index 06c61d3e1b..207b4fe81f 100644 --- a/src/Appwrite/Utopia/Response/Model/Platform.php +++ b/src/Appwrite/Utopia/Response/Model/Platform.php @@ -18,21 +18,25 @@ class Platform extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Platform ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Platform name.', + 'default' => '', 'example' => 'My Web App', ]) ->addRule('type', [ 'type' => self::TYPE_STRING, 'description' => 'Platform type. Possible values are: web, flutter-ios, flutter-android, ios, android, and unity.', + 'default' => '', 'example' => 'My Web App', ]) ->addRule('key', [ 'type' => self::TYPE_STRING, 'description' => 'Platform Key. iOS bundle ID or Android package name. Empty string for other platforms.', + 'default' => '', 'example' => 'com.company.appname', ]) // ->addRule('store', [ @@ -43,6 +47,7 @@ class Platform extends Model ->addRule('hostname', [ 'type' => self::TYPE_STRING, 'description' => 'Web app hostname. Empty string for other platforms.', + 'default' => '', 'example' => true, ]) ->addRule('httpUser', [ diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index e481631898..9ff5817583 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -19,6 +19,7 @@ class Project extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Project ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ @@ -36,6 +37,7 @@ class Project extends Model ->addRule('teamId', [ 'type' => self::TYPE_STRING, 'description' => 'Project team ID.', + 'default' => '', 'example' => '1592981250', ]) ->addRule('logo', [ diff --git a/src/Appwrite/Utopia/Response/Model/Rule.php b/src/Appwrite/Utopia/Response/Model/Rule.php index cb075c8a7f..178dd90d7c 100644 --- a/src/Appwrite/Utopia/Response/Model/Rule.php +++ b/src/Appwrite/Utopia/Response/Model/Rule.php @@ -13,6 +13,7 @@ class Rule extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Rule ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('$collection', [ // TODO remove this from public response @@ -23,32 +24,37 @@ class Rule extends Model ->addRule('type', [ 'type' => self::TYPE_STRING, 'description' => 'Rule type. Possible values: ', + 'default' => '', 'example' => 'title', ]) ->addRule('key', [ 'type' => self::TYPE_STRING, 'description' => 'Rule key.', + 'default' => '', 'example' => 'title', ]) ->addRule('label', [ 'type' => self::TYPE_STRING, 'description' => 'Rule label.', + 'default' => '', 'example' => 'Title', ]) ->addRule('default', [ // TODO should be of mixed types 'type' => self::TYPE_STRING, 'description' => 'Rule default value.', - 'example' => 'Movie Name', 'default' => '', + 'example' => 'Movie Name', ]) ->addRule('array', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Is array?', + 'default' => false, 'example' => false, ]) ->addRule('required', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Is required?', + 'default' => false, 'example' => true, ]) ->addRule('list', [ diff --git a/src/Appwrite/Utopia/Response/Model/Session.php b/src/Appwrite/Utopia/Response/Model/Session.php index a0edfbb4b6..4bc23ab79a 100644 --- a/src/Appwrite/Utopia/Response/Model/Session.php +++ b/src/Appwrite/Utopia/Response/Model/Session.php @@ -13,6 +13,7 @@ class Session extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Session ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('userId', [ diff --git a/src/Appwrite/Utopia/Response/Model/Tag.php b/src/Appwrite/Utopia/Response/Model/Tag.php index a3a403187f..b48e157291 100644 --- a/src/Appwrite/Utopia/Response/Model/Tag.php +++ b/src/Appwrite/Utopia/Response/Model/Tag.php @@ -13,26 +13,31 @@ class Tag extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Tag ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('functionId', [ 'type' => self::TYPE_STRING, 'description' => 'Function ID.', + 'default' => '', 'example' => '5e5ea6g16897e', ]) ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'The tag creation date in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('command', [ 'type' => self::TYPE_STRING, 'description' => 'The entrypoint command in use to execute the tag code.', + 'default' => '', 'example' => 'enabled', ]) ->addRule('size', [ 'type' => self::TYPE_STRING, 'description' => 'The code size in bytes.', + 'default' => '', 'example' => 'python-3.8', ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Task.php b/src/Appwrite/Utopia/Response/Model/Task.php index 53ec1474e6..6843eba9a0 100644 --- a/src/Appwrite/Utopia/Response/Model/Task.php +++ b/src/Appwrite/Utopia/Response/Model/Task.php @@ -18,26 +18,31 @@ class Task extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Task ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Task name.', + 'default' => '', 'example' => 'My Task', ]) ->addRule('security', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Indicated if SSL / TLS Certificate verification is enabled.', + 'default' => true, 'example' => true, ]) ->addRule('httpMethod', [ 'type' => self::TYPE_STRING, 'description' => 'Task HTTP Method.', + 'default' => '', 'example' => 'POST', ]) ->addRule('httpUrl', [ 'type' => self::TYPE_STRING, 'description' => 'Task HTTP URL.', + 'default' => '', 'example' => 'https://example.com/task', ]) ->addRule('httpHeaders', [ @@ -80,11 +85,13 @@ class Task extends Model ->addRule('schedule', [ 'type' => self::TYPE_STRING, 'description' => 'Task schedule in CRON syntax.', + 'default' => '', 'example' => '* * * * *', ]) ->addRule('status', [ 'type' => self::TYPE_STRING, 'description' => 'Task status. Possible values: play, pause', // TODO - change to enabled disabled + 'default' => '', 'example' => 'enabled', ]) ->addRule('updated', [ diff --git a/src/Appwrite/Utopia/Response/Model/Team.php b/src/Appwrite/Utopia/Response/Model/Team.php index 67442dade5..b5f7482a19 100644 --- a/src/Appwrite/Utopia/Response/Model/Team.php +++ b/src/Appwrite/Utopia/Response/Model/Team.php @@ -13,6 +13,7 @@ class Team extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Team ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ @@ -24,11 +25,13 @@ class Team extends Model ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'Team creation date in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('sum', [ // TODO change key name? 'type' => self::TYPE_INTEGER, 'description' => 'Total sum of team members.', + 'default' => 0, 'example' => 7, ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/Token.php b/src/Appwrite/Utopia/Response/Model/Token.php index 9d00fe6f91..fb34f01fd7 100644 --- a/src/Appwrite/Utopia/Response/Model/Token.php +++ b/src/Appwrite/Utopia/Response/Model/Token.php @@ -13,17 +13,19 @@ class Token extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Token ID.', + 'default' => '', 'example' => 'bb8ea5c16897e', ]) ->addRule('userId', [ 'type' => self::TYPE_STRING, 'description' => 'User ID.', + 'default' => '', 'example' => '5e5ea5c168bb8', ]) ->addRule('secret', [ 'type' => self::TYPE_STRING, 'description' => 'Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.', - 'default' => 0, + 'default' => '', 'example' => '', ]) ->addRule('expire', [ diff --git a/src/Appwrite/Utopia/Response/Model/User.php b/src/Appwrite/Utopia/Response/Model/User.php index e11d49ed8f..b917a14a0d 100644 --- a/src/Appwrite/Utopia/Response/Model/User.php +++ b/src/Appwrite/Utopia/Response/Model/User.php @@ -13,26 +13,31 @@ class User extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'User ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'User name.', + 'default' => '', 'example' => 'John Doe', ]) ->addRule('registration', [ 'type' => self::TYPE_INTEGER, 'description' => 'User registration date in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('status', [ 'type' => self::TYPE_INTEGER, 'description' => 'User status. 0 for Unactivated, 1 for active and 2 is blocked.', + 'default' => 0, 'example' => 0, ]) ->addRule('email', [ 'type' => self::TYPE_STRING, 'description' => 'User email address.', + 'default' => '', 'example' => 'john@appwrite.io', ]) ->addRule('emailVerification', [ diff --git a/src/Appwrite/Utopia/Response/Model/Webhook.php b/src/Appwrite/Utopia/Response/Model/Webhook.php index f8b8ac7432..0ad9ce6ab8 100644 --- a/src/Appwrite/Utopia/Response/Model/Webhook.php +++ b/src/Appwrite/Utopia/Response/Model/Webhook.php @@ -18,16 +18,19 @@ class Webhook extends Model ->addRule('$id', [ 'type' => self::TYPE_STRING, 'description' => 'Webhook ID.', + 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('name', [ 'type' => self::TYPE_STRING, 'description' => 'Webhook name.', + 'default' => '', 'example' => 'My Webhook', ]) ->addRule('url', [ 'type' => self::TYPE_STRING, 'description' => 'Webhook URL endpoint.', + 'default' => '', 'example' => 'https://example.com/webhook', ]) ->addRule('events', [ @@ -40,6 +43,7 @@ class Webhook extends Model ->addRule('security', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Indicated if SSL / TLS Certificate verification is enabled.', + 'default' => true, 'example' => true, ]) ->addRule('httpUser', [ From 56de47073d00c25f555c29d1c090b216dca64796 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 13 Jan 2021 18:10:42 +0200 Subject: [PATCH 32/38] Fixed file default value --- src/Appwrite/Utopia/Response/Model/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Response/Model/File.php b/src/Appwrite/Utopia/Response/Model/File.php index a731baddf9..ffd8f5ce47 100644 --- a/src/Appwrite/Utopia/Response/Model/File.php +++ b/src/Appwrite/Utopia/Response/Model/File.php @@ -50,7 +50,7 @@ class File extends Model ->addRule('sizeOriginal', [ 'type' => self::TYPE_INTEGER, 'description' => 'File original size in bytes.', - 'default' => '', + 'default' => 0, 'example' => 17890, ]) ; From 589169803467b687db7250db71c4462cee0f0030 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 13 Jan 2021 18:11:56 +0200 Subject: [PATCH 33/38] Fixed wrong default values --- src/Appwrite/Utopia/Response/Model/Execution.php | 2 +- src/Appwrite/Utopia/Response/Model/File.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/Execution.php b/src/Appwrite/Utopia/Response/Model/Execution.php index a5ad4cc75d..22c7710ec6 100644 --- a/src/Appwrite/Utopia/Response/Model/Execution.php +++ b/src/Appwrite/Utopia/Response/Model/Execution.php @@ -61,7 +61,7 @@ class Execution extends Model ->addRule('time', [ 'type' => self::TYPE_FLOAT, 'description' => 'The script execution time in seconds.', - 'default' => '', + 'default' => 0, 'example' => 0.400, ]) ; diff --git a/src/Appwrite/Utopia/Response/Model/File.php b/src/Appwrite/Utopia/Response/Model/File.php index ffd8f5ce47..9c88e2f99d 100644 --- a/src/Appwrite/Utopia/Response/Model/File.php +++ b/src/Appwrite/Utopia/Response/Model/File.php @@ -19,7 +19,7 @@ class File extends Model ->addRule('$permissions', [ 'type' => Response::MODEL_PERMISSIONS, 'description' => 'File permissions.', - 'default' => '', + 'default' => new \stdClass, 'example' => new \stdClass, 'array' => false, ]) From 2fd86c809a8c989d27ddd0914d1a714206e868c6 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 13 Jan 2021 18:17:28 +0200 Subject: [PATCH 34/38] Last fix ? --- src/Appwrite/Utopia/Response/Model/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Response/Model/File.php b/src/Appwrite/Utopia/Response/Model/File.php index 9c88e2f99d..5d0d511539 100644 --- a/src/Appwrite/Utopia/Response/Model/File.php +++ b/src/Appwrite/Utopia/Response/Model/File.php @@ -32,7 +32,7 @@ class File extends Model ->addRule('dateCreated', [ 'type' => self::TYPE_INTEGER, 'description' => 'File creation date in Unix timestamp.', - 'default' => '', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('signature', [ From 00ee2735c466460c1611e759c54c405bb571417d Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 14 Jan 2021 08:09:52 +0200 Subject: [PATCH 35/38] Updated changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index d9ec45dd6c..ee147b9cbf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,7 @@ - Added new environment variables for ClamAV hostname and port ([#780](https://github.com/appwrite/appwrite/pull/780)) - New OAuth adapter for Box.com (@armino-dev - [#420](https://github.com/appwrite/appwrite/issues/410)) - New OAuth adapter for PayPal sandbox (@armino-dev - [#420](https://github.com/appwrite/appwrite/issues/410)) +- Introducing new permssion types: role:guest, role:member, role:app. ### User Interface - Updated grid for OAuth2 providers list in the console ([#413](https://github.com/appwrite/appwrite/issues/413)) From 5fb533ed6aac99a5d60caa3d3c1b926858b8dff6 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 14 Jan 2021 13:11:10 +0200 Subject: [PATCH 36/38] Removed unsed volume --- app/views/install/compose.phtml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 9a2141a5c1..098d4d4070 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -372,5 +372,4 @@ volumes: appwrite-certificates: appwrite-functions: appwrite-influxdb: - appwrite-chronograf: appwrite-config: From 54c31fe890ae90ccbe5a2ddff60ed62c02435221 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 14 Jan 2021 21:30:16 +0200 Subject: [PATCH 37/38] Updated changelog --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index ee147b9cbf..cc6a5c633b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,7 +37,8 @@ - Added new environment variables for ClamAV hostname and port ([#780](https://github.com/appwrite/appwrite/pull/780)) - New OAuth adapter for Box.com (@armino-dev - [#420](https://github.com/appwrite/appwrite/issues/410)) - New OAuth adapter for PayPal sandbox (@armino-dev - [#420](https://github.com/appwrite/appwrite/issues/410)) -- Introducing new permssion types: role:guest, role:member, role:app. +- Introducing new permssion types: role:guest, role:member, role:app +- Disabled rate-limits on server side integrations ### User Interface - Updated grid for OAuth2 providers list in the console ([#413](https://github.com/appwrite/appwrite/issues/413)) From a8c23630873e5af1df02620d388baa522a9d45dc Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Fri, 15 Jan 2021 00:16:09 +0200 Subject: [PATCH 38/38] Added space --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index cc6a5c633b..1418fb4532 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,6 +41,7 @@ - Disabled rate-limits on server side integrations ### User Interface + - Updated grid for OAuth2 providers list in the console ([#413](https://github.com/appwrite/appwrite/issues/413)) - Added Google Fonts to Appwrite for offline availability - Added option to delete user from the console (@PineappleIOnic - [#538](https://github.com/appwrite/appwrite/issues/538)) @@ -55,6 +56,7 @@ - Added toggle to hide/show secret keys and passwords inside the dashboard (@kodumbeats, [#535](https://github.com/appwrite/appwrite/issues/535)) ### Upgrades + - Upgraded QR codes generator library (@PedroCisnerosSantana - [#475](https://github.com/appwrite/appwrite/issues/475)) - Upgraded Traefik image to version 2.3 - Upgraded MariaDB to version 10.5.5 @@ -65,6 +67,7 @@ - Upgraded device detctor to version 3.12.6 ## Breaking Changes (Read before upgrading!) + - **Deprecated** `first` and `last` query params for documents list route in the database API - **Deprecated** Deprectaed Pubjabi Translations ('pn') - **Deprecated** `PATCH /account/prefs` is now updating the prefs payload and not just merging it @@ -102,6 +105,7 @@ - Fixed OAuth redirect when using the self-hosted instance default success URL ([#454](https://github.com/appwrite/appwrite/issues/454)) - Fixed bug denying authentication with Github OAuth provider - Fixed a bug making read permission overwrite write permission in some cases + ## Security - Access to Health API now requires authentication with an API Key with access to `health.read` scope allowed