Move OTYPE constants to own enum class

This commit is contained in:
nupplaPhil 2020-02-04 22:01:55 +01:00
parent e42b843505
commit 97b6f6b3b3
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
4 changed files with 16 additions and 6 deletions

View file

@ -5906,7 +5906,7 @@ function api_friendica_notification_seen($type)
$notify = DI::notify()->getByID($id); $notify = DI::notify()->getByID($id);
DI::notify()->setSeen(true, $notify); 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()]); $item = Item::selectFirstForUser(api_user(), [], ['id' => $notify->iid, 'uid' => api_user()]);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
// we found the item, return it to the user // we found the item, return it to the user

View file

@ -134,7 +134,7 @@ function notification($params)
// if it's a post figure out who's post it is. // if it's a post figure out who's post it is.
$item = null; $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]); $item = Item::selectFirstForUser($params['uid'], Item::ITEM_FIELDLIST, ['id' => $parent_id, 'deleted' => false]);
} }

View file

@ -31,10 +31,6 @@ use Psr\Log\LoggerInterface;
*/ */
class Notify extends BaseModel class Notify extends BaseModel
{ {
const OTYPE_ITEM = 'item';
const OTYPE_INTRO = 'intro';
const OTYPE_MAIL = 'mail';
const OTYPE_PERSON = 'person';
/** @var \Friendica\Repository\Notify */ /** @var \Friendica\Repository\Notify */
private $repo; private $repo;

View file

@ -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';
}