From c40dcbac2b746b6347a837204f93cf2f53504350 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Fri, 28 Mar 2025 17:30:17 -0700 Subject: [PATCH] fix(ApiHandler.php): handle PATCH requests in fetchFromPostgREST --- api/Classes/ApiHandler.php | 4 +++- api/mastodon.php | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/Classes/ApiHandler.php b/api/Classes/ApiHandler.php index 9f42b30..170bc49 100644 --- a/api/Classes/ApiHandler.php +++ b/api/Classes/ApiHandler.php @@ -50,7 +50,9 @@ abstract class ApiHandler ], ]; - if ($method === "POST" && $body) $options["json"] = $body; + if (in_array($method, ["POST", "PATCH"]) && $body) { + $options["json"] = $body; + } $response = (new Client())->request($method, $url, $options); diff --git a/api/mastodon.php b/api/mastodon.php index 06959bd..33b6b9a 100644 --- a/api/mastodon.php +++ b/api/mastodon.php @@ -215,7 +215,7 @@ class MastodonPostHandler extends ApiHandler ): void { $data = ["mastodon_url" => $mastodonPostUrl]; - $this->fetchFromPostgREST("posts", "slug=eq.{$slug}&mastodon_url=is.null", "PATCH", $data); + $this->fetchFromPostgREST("posts", "slug=eq.{urlencode($slug)}&mastodon_url=is.null", "PATCH", $data); } private function truncateContent( diff --git a/package-lock.json b/package-lock.json index 924b88f..a9605c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "1.1.2", + "version": "1.1.3", "license": "MIT", "dependencies": { "minisearch": "^7.1.2", diff --git a/package.json b/package.json index 240b622..2d012fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "1.1.2", + "version": "1.1.3", "description": "The source for my personal site. Built using 11ty (and other tools).", "type": "module", "engines": {