]> git.mxchange.org Git - friendica.git/commitdiff
Move OTYPE constants to own enum class
authornupplaPhil <admin+github@philipp.info>
Tue, 4 Feb 2020 21:01:55 +0000 (22:01 +0100)
committernupplaPhil <admin+github@philipp.info>
Wed, 5 Feb 2020 20:40:59 +0000 (21:40 +0100)
include/api.php
include/enotify.php
src/Model/Notify.php
src/Model/Notify/ObjectType.php [new file with mode: 0644]

index 6f5120691cffe56f9e9ea9de52c763635d40b2cc..dda4631ce1ba4f510fd259897526c8f350b78ca4 100644 (file)
@@ -5906,7 +5906,7 @@ function api_friendica_notification_seen($type)
                $notify = DI::notify()->getByID($id);
                DI::notify()->setSeen(true, $notify);
 
-               if ($notify->otype === Notify::OTYPE_ITEM) {
+               if ($notify->otype === Notify\ObjectType::ITEM) {
                        $item = Item::selectFirstForUser(api_user(), [], ['id' => $notify->iid, 'uid' => api_user()]);
                        if (DBA::isResult($item)) {
                                // we found the item, return it to the user
index 18f5dec8891ecbc22d0311515f0e88a5ac97aa78..9f18a472d247361c392243a1a18d49ad65c99dde 100644 (file)
@@ -134,7 +134,7 @@ function notification($params)
 
                // if it's a post figure out who's post it is.
                $item = null;
-               if ($params['otype'] === Notify::OTYPE_ITEM && $parent_id) {
+               if ($params['otype'] === Notify\ObjectType::ITEM && $parent_id) {
                        $item = Item::selectFirstForUser($params['uid'], Item::ITEM_FIELDLIST, ['id' => $parent_id, 'deleted' => false]);
                }
 
index 35d72384e89526cb94e362dbd1bbab159db67478..336b82537bcc9879c1e2719bfceed6ad200ab872 100644 (file)
@@ -31,10 +31,6 @@ use Psr\Log\LoggerInterface;
  */
 class Notify extends BaseModel
 {
-       const OTYPE_ITEM   = 'item';
-       const OTYPE_INTRO  = 'intro';
-       const OTYPE_MAIL   = 'mail';
-       const OTYPE_PERSON = 'person';
 
        /** @var \Friendica\Repository\Notify */
        private $repo;
diff --git a/src/Model/Notify/ObjectType.php b/src/Model/Notify/ObjectType.php
new file mode 100644 (file)
index 0000000..9fb279a
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+namespace Friendica\Model\Notify;
+
+/**
+ * Enum for different otypes of the Notify
+ */
+class ObjectType
+{
+       const PERSON = 'person';
+       const MAIL   = 'mail';
+       const ITEM   = 'item';
+       const INTRO  = 'intro';
+}