From 8ffe6101c2982d4450734d43b5ea01f80bd5858a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 10 Dec 2021 09:22:05 +0100 Subject: [PATCH 1/2] Fix handling existing values with no page information Closes #11 Signed-off-by: Thomas Citharel --- lib/Listeners/InjectNote.php | 5 +---- lib/Model/Note.php | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/Listeners/InjectNote.php b/lib/Listeners/InjectNote.php index 8351a25..42c3925 100644 --- a/lib/Listeners/InjectNote.php +++ b/lib/Listeners/InjectNote.php @@ -79,10 +79,7 @@ class InjectNote implements IEventListener { $match = $this->matches($url); if ($match !== false) { $notes = array_values(array_filter($this->manager->getNotes(), static function (Note $note) use ($match) { - $pages = $note->getPagesEnabled(); - if (!$pages) { - return false; - } + $pages = ($note->getPagesEnabled() ?? '{"login":true}'); /** @var array $pagesArray */ $pagesArray = json_decode($pages, true, 512, JSON_THROW_ON_ERROR); return isset($pagesArray[$match]) && $pagesArray[$match] === true; diff --git a/lib/Model/Note.php b/lib/Model/Note.php index f34a0b2..993feb7 100644 --- a/lib/Model/Note.php +++ b/lib/Model/Note.php @@ -36,8 +36,8 @@ use OCP\AppFramework\Db\Entity; * @method string getRawText() * @method void setCreatedAt(int $time) * @method int getCreatedAt() - * @method void setPagesEnabled(string $pages) - * @method string getPagesEnabled() + * @method void setPagesEnabled(string|null $pages) + * @method string|null getPagesEnabled() * * @package OCA\LoginNotes\Model */ @@ -52,7 +52,7 @@ class Note extends Entity implements \JsonSerializable { /** @var int */ public $createdAt; - /** @var string */ + /** @var string|null */ public $pagesEnabled; public function __construct() { @@ -68,7 +68,7 @@ class Note extends Entity implements \JsonSerializable { 'text' => $this->text, 'rawText' => $this->rawText, 'createdAt' => $this->createdAt, - 'pagesEnabled' => json_decode($this->pagesEnabled, true, 512, JSON_THROW_ON_ERROR), + 'pagesEnabled' => json_decode(($this->pagesEnabled ?? '{"login":true}'), true, 512, JSON_THROW_ON_ERROR), ]; } } -- GitLab From 6024fccef4de74e674ec0860b1dbc62fac563420 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 10 Dec 2021 09:22:44 +0100 Subject: [PATCH 2/2] Bump version to 1.0.1 Signed-off-by: Thomas Citharel --- CHANGELOG.md | 6 ++++++ appinfo/info.xml | 2 +- composer.json | 2 +- package.json | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2987723..90920b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.0.1 - 2021-12-10 + +### Fixed + +- Handle existing values with no page information properly + ## 1.0.0 - 2021-12-07 ### Added diff --git a/appinfo/info.xml b/appinfo/info.xml index fc45097..1a575f5 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -7,7 +7,7 @@ Afficher des notes sur la page de connexion This app will show admin defined notes the log-in page Cette application affichera des notes définies par l'administrateur sur la page de connexion - 1.0.0 + 1.0.1 agpl Thomas Citharel LoginNotes diff --git a/composer.json b/composer.json index 5f05ecc..820fc4d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "framasoft/login_notes", - "version": "1.0.0", + "version": "1.0.1", "licence": "AGPL-3.0-or-later", "description": "This app will show admin defined notes the log-in page", "config": { diff --git a/package.json b/package.json index e3547fa..c2af589 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "login_notes", - "version": "1.0.0", + "version": "1.0.1", "description": "This app will show admin defined notes the log-in page", "main": "index.js", "private": true, -- GitLab