]> git.mxchange.org Git - friendica.git/commitdiff
Fixes "Incorrect integer value: 'true'"
authorMichael <heluecht@pirati.ca>
Tue, 30 Jul 2024 15:00:35 +0000 (15:00 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 30 Jul 2024 15:00:35 +0000 (15:00 +0000)
src/Module/Api/Mastodon/PushSubscription.php

index 8e997e0758c4fec3ed629c0d0c046b40c16b2f82..b2fd102f29c20a7994bf5a3ba933d6ce978f9699 100644 (file)
@@ -98,13 +98,13 @@ class PushSubscription extends BaseApi
                }
 
                $fields = [
-                       Notification::TYPE_FOLLOW       => $request['data']['alerts'][Notification::TYPE_FOLLOW] ?? false,
-                       Notification::TYPE_LIKE         => $request['data']['alerts'][Notification::TYPE_LIKE] ?? false,
-                       Notification::TYPE_RESHARE      => $request['data']['alerts'][Notification::TYPE_RESHARE] ?? false,
-                       Notification::TYPE_MENTION      => $request['data']['alerts'][Notification::TYPE_MENTION] ?? false,
-                       Notification::TYPE_POLL         => $request['data']['alerts'][Notification::TYPE_POLL] ?? false,
-                       Notification::TYPE_INTRODUCTION => $request['data']['alerts'][Notification::TYPE_INTRODUCTION] ?? false,
-                       Notification::TYPE_POST         => $request['data']['alerts'][Notification::TYPE_POST] ?? false,
+                       Notification::TYPE_FOLLOW       => $this->setBoolean($request['data']['alerts'][Notification::TYPE_FOLLOW] ?? false),
+                       Notification::TYPE_LIKE         => $this->setBoolean($request['data']['alerts'][Notification::TYPE_LIKE] ?? false),
+                       Notification::TYPE_RESHARE      => $this->setBoolean($request['data']['alerts'][Notification::TYPE_RESHARE] ?? false),
+                       Notification::TYPE_MENTION      => $this->setBoolean($request['data']['alerts'][Notification::TYPE_MENTION] ?? false),
+                       Notification::TYPE_POLL         => $this->setBoolean($request['data']['alerts'][Notification::TYPE_POLL] ?? false),
+                       Notification::TYPE_INTRODUCTION => $this->setBoolean($request['data']['alerts'][Notification::TYPE_INTRODUCTION] ?? false),
+                       Notification::TYPE_POST         => $this->setBoolean($request['data']['alerts'][Notification::TYPE_POST] ?? false),
                ];
 
                $ret = Subscription::update($application['id'], $uid, $fields);
@@ -120,6 +120,14 @@ class PushSubscription extends BaseApi
                $this->response->addJsonContent($subscriptionObj->toArray());
        }
 
+       private function setBoolean($input): bool
+       {
+               if (is_bool($input)) {
+                       return $input;
+               }
+               return strtolower($input) == 'true';
+       }
+
        protected function delete(array $request = []): void
        {
                $this->checkAllowedScope(self::SCOPE_PUSH);