From 46c65b79be24746a4b6699d0e6065a1efa5ef982 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 19 Mar 2024 22:28:30 -0400 Subject: [PATCH] [advancedcontentfilter] Improve error handling - Add Logger to Slim application to log to Friendica log file - Show more specific error message when rule syntax check fails - Align editorconfig with Composer style - Add minimum PHP version to composer.json --- .editorconfig | 3 ++ .../advancedcontentfilter.js | 4 +- advancedcontentfilter/composer.json | 47 ++++++++++--------- advancedcontentfilter/src/middlewares.php | 2 +- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8565b274..ef6e90b2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -27,3 +27,6 @@ indent_size = 2 [*.json] indent_style = space indent_size = 2 + +[composer.json] +indent_size = 4 diff --git a/advancedcontentfilter/advancedcontentfilter.js b/advancedcontentfilter/advancedcontentfilter.js index fcf7b096..a8fc1c65 100644 --- a/advancedcontentfilter/advancedcontentfilter.js +++ b/advancedcontentfilter/advancedcontentfilter.js @@ -54,7 +54,7 @@ new Vue({ self.rules.push(responseJSON.rule); self.resetForm(); }, function (response) { - self.errorMessage = response.responseJSON.message; + self.errorMessage = response.responseJSON.exception[0].message; }); } }, @@ -74,7 +74,7 @@ new Vue({ self.rules[self.editedIndex] = rule; self.resetForm(); }, function (response) { - self.errorMessage = response.responseJSON.message; + self.errorMessage = response.responseJSON.exception[0].message; }); }, diff --git a/advancedcontentfilter/composer.json b/advancedcontentfilter/composer.json index ceb152e7..b9ab1900 100644 --- a/advancedcontentfilter/composer.json +++ b/advancedcontentfilter/composer.json @@ -1,24 +1,27 @@ { - "name": "friendica-addons/advancedcontentfilter", - "description": "Advanced Content Filter addon for Friendica", - "type": "friendica-addon", - "authors": [ - { - "name": "Hypolite Petovan", - "email": "hypolite@mrpetovan.com", - "homepage": "https://friendica.mrpetovan.com/profile/hypolite", - "role": "Developer" - } - ], - "require": { - "slim/slim": "^4", - "symfony/expression-language": "^3.4" - }, - "license": "3-clause BSD license", - "minimum-stability": "stable", - "config": { - "optimize-autoloader": true, - "autoloader-suffix": "AdvancedContentFilterAddon", - "preferred-install": "dist" - } + "name": "friendica-addons/advancedcontentfilter", + "description": "Advanced Content Filter addon for Friendica", + "type": "friendica-addon", + "authors": [ + { + "name": "Hypolite Petovan", + "email": "hypolite@mrpetovan.com", + "homepage": "https://friendica.mrpetovan.com/profile/hypolite", + "role": "Developer" + } + ], + "require": { + "slim/slim": "^4", + "symfony/expression-language": "^3.4" + }, + "license": "3-clause BSD license", + "minimum-stability": "stable", + "config": { + "platform": { + "php": "7.4" + }, + "optimize-autoloader": true, + "autoloader-suffix": "AdvancedContentFilterAddon", + "preferred-install": "dist" + } } diff --git a/advancedcontentfilter/src/middlewares.php b/advancedcontentfilter/src/middlewares.php index 84dd6ed8..2b831473 100644 --- a/advancedcontentfilter/src/middlewares.php +++ b/advancedcontentfilter/src/middlewares.php @@ -29,4 +29,4 @@ use Friendica\DI; */ $slim->addRoutingMiddleware(); -$errorMiddleware = $slim->addErrorMiddleware(true, true, true); +$errorMiddleware = $slim->addErrorMiddleware(true, true, true, DI::logger());