Rename classes
- Repository/Model Notification => Notify - Factory/Object Notification => Notification
This commit is contained in:
parent
b85511b00d
commit
0840938dff
12 changed files with 45 additions and 45 deletions
|
@ -23,7 +23,7 @@ use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Mail;
|
use Friendica\Model\Mail;
|
||||||
use Friendica\Model\Notification;
|
use Friendica\Model\Notify;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -5907,7 +5907,7 @@ function api_friendica_notification($type)
|
||||||
throw new BadRequestException("Invalid argument count");
|
throw new BadRequestException("Invalid argument count");
|
||||||
}
|
}
|
||||||
|
|
||||||
$notifications = DI::notification()->select(['uid' => api_user()], ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50]);
|
$notifications = DI::notify()->select(['uid' => api_user()], ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50]);
|
||||||
|
|
||||||
if ($type == "xml") {
|
if ($type == "xml") {
|
||||||
$xmlnotes = false;
|
$xmlnotes = false;
|
||||||
|
@ -5955,10 +5955,10 @@ function api_friendica_notification_seen($type)
|
||||||
$id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
|
$id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$notification = DI::notification()->getByID($id);
|
$notification = DI::notify()->getByID($id);
|
||||||
$notification->setSeen();
|
$notification->setSeen();
|
||||||
|
|
||||||
if ($notification->otype === Notification::OTYPE_ITEM) {
|
if ($notification->otype === Notify::OTYPE_ITEM) {
|
||||||
$item = Item::selectFirstForUser(api_user(), [], ['id' => $notification->iid, 'uid' => api_user()]);
|
$item = Item::selectFirstForUser(api_user(), [], ['id' => $notification->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
|
||||||
|
|
|
@ -12,7 +12,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\ItemContent;
|
use Friendica\Model\ItemContent;
|
||||||
use Friendica\Model\Notification;
|
use Friendica\Model\Notify;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Model\UserItem;
|
use Friendica\Model\UserItem;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
|
@ -161,7 +161,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'] === Notification::OTYPE_ITEM && $parent_id) {
|
if ($params['otype'] === Notify::OTYPE_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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ function notification($params)
|
||||||
$notify_id = 0;
|
$notify_id = 0;
|
||||||
|
|
||||||
if ($show_in_notification_page) {
|
if ($show_in_notification_page) {
|
||||||
$notification = DI::notification()->insert([
|
$notification = DI::notify()->insert([
|
||||||
'name' => $params['source_name'],
|
'name' => $params['source_name'],
|
||||||
'url' => $params['source_link'],
|
'url' => $params['source_link'],
|
||||||
'photo' => $params['source_photo'],
|
'photo' => $params['source_photo'],
|
||||||
|
@ -498,7 +498,7 @@ function notification($params)
|
||||||
$notification->link = DI::baseUrl() . '/notification/view/' . $notification->id;
|
$notification->link = DI::baseUrl() . '/notification/view/' . $notification->id;
|
||||||
$notification->msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $notification->link]);
|
$notification->msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $notification->link]);
|
||||||
|
|
||||||
DI::notification()->update($notification);
|
DI::notify()->update($notification);
|
||||||
|
|
||||||
$itemlink = $notification->link;
|
$itemlink = $notification->link;
|
||||||
$notify_id = $notification->id;
|
$notify_id = $notification->id;
|
||||||
|
|
|
@ -433,7 +433,7 @@ function ping_get_notifications($uid)
|
||||||
$notification["message"] = $notification["msg_cache"];
|
$notification["message"] = $notification["msg_cache"];
|
||||||
} else {
|
} else {
|
||||||
$notification["name"] = strip_tags(BBCode::convert($notification["name"]));
|
$notification["name"] = strip_tags(BBCode::convert($notification["name"]));
|
||||||
$notification["message"] = Friendica\Model\Notification::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"])));
|
$notification["message"] = Friendica\Model\Notify::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"])));
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d",
|
"UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d",
|
||||||
|
|
|
@ -5,10 +5,10 @@ namespace Friendica\Collection;
|
||||||
use Friendica\BaseCollection;
|
use Friendica\BaseCollection;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
|
|
||||||
class Notifications extends BaseCollection
|
class Notifies extends BaseCollection
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return Model\Notification
|
* @return Model\Notify
|
||||||
*/
|
*/
|
||||||
public function current()
|
public function current()
|
||||||
{
|
{
|
18
src/DI.php
18
src/DI.php
|
@ -245,19 +245,19 @@ abstract class DI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Friendica\Factory\Notification\NotificationFactory
|
* @return \Friendica\Factory\Notification\Notification
|
||||||
*/
|
*/
|
||||||
public static function factNotification()
|
public static function notification()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Factory\Notification\NotificationFactory::class);
|
return self::$dice->create(Factory\Notification\Notification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Friendica\Factory\Notification\IntroductionFactory
|
* @return \Friendica\Factory\Notification\Introduction
|
||||||
*/
|
*/
|
||||||
public static function factNotIntro()
|
public static function notificationIntro()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Factory\Notification\IntroductionFactory::class);
|
return self::$dice->create(Factory\Notification\Introduction::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -273,11 +273,11 @@ abstract class DI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Repository\Notification
|
* @return Repository\Notify
|
||||||
*/
|
*/
|
||||||
public static function notification()
|
public static function notify()
|
||||||
{
|
{
|
||||||
return self::$dice->create(Repository\Notification::class);
|
return self::$dice->create(Repository\Notify::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,7 @@ use Friendica\Database\Database;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Module\BaseNotifications;
|
use Friendica\Module\BaseNotifications;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Object\Notification\Introduction;
|
use Friendica\Object;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ use Psr\Log\LoggerInterface;
|
||||||
* - Friend suggestion
|
* - Friend suggestion
|
||||||
* - Friend/Follower request
|
* - Friend/Follower request
|
||||||
*/
|
*/
|
||||||
class IntroductionFactory extends BaseFactory
|
class Introduction extends BaseFactory
|
||||||
{
|
{
|
||||||
/** @var Database */
|
/** @var Database */
|
||||||
private $dba;
|
private $dba;
|
||||||
|
@ -61,7 +61,7 @@ class IntroductionFactory extends BaseFactory
|
||||||
* @param int $limit Maximum number of query results
|
* @param int $limit Maximum number of query results
|
||||||
* @param int $id When set, only the introduction with this id is displayed
|
* @param int $id When set, only the introduction with this id is displayed
|
||||||
*
|
*
|
||||||
* @return Introduction[]
|
* @return Object\Notification\Introduction[]
|
||||||
*/
|
*/
|
||||||
public function getList(bool $all = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT, int $id = 0)
|
public function getList(bool $all = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT, int $id = 0)
|
||||||
{
|
{
|
|
@ -16,7 +16,7 @@ use Friendica\Model\Item;
|
||||||
use Friendica\Module\BaseNotifications;
|
use Friendica\Module\BaseNotifications;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Repository\Notification;
|
use Friendica\Repository;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
|
@ -31,11 +31,11 @@ use Psr\Log\LoggerInterface;
|
||||||
* - home
|
* - home
|
||||||
* - personal
|
* - personal
|
||||||
*/
|
*/
|
||||||
class NotificationFactory extends BaseFactory
|
class Notification extends BaseFactory
|
||||||
{
|
{
|
||||||
/** @var Database */
|
/** @var Database */
|
||||||
private $dba;
|
private $dba;
|
||||||
/** @var Notification */
|
/** @var Repository\Notify */
|
||||||
private $notification;
|
private $notification;
|
||||||
/** @var BaseURL */
|
/** @var BaseURL */
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
|
@ -44,7 +44,7 @@ class NotificationFactory extends BaseFactory
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $nurl;
|
private $nurl;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, Database $dba, Notification $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
|
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
|
@ -42,17 +42,17 @@ use Psr\Log\LoggerInterface;
|
||||||
* @property-read string $msg_html
|
* @property-read string $msg_html
|
||||||
* @property-read string $msg_plain
|
* @property-read string $msg_plain
|
||||||
*/
|
*/
|
||||||
class Notification extends BaseModel
|
class Notify extends BaseModel
|
||||||
{
|
{
|
||||||
const OTYPE_ITEM = 'item';
|
const OTYPE_ITEM = 'item';
|
||||||
const OTYPE_INTRO = 'intro';
|
const OTYPE_INTRO = 'intro';
|
||||||
const OTYPE_MAIL = 'mail';
|
const OTYPE_MAIL = 'mail';
|
||||||
const OTYPE_PERSON = 'person';
|
const OTYPE_PERSON = 'person';
|
||||||
|
|
||||||
/** @var \Friendica\Repository\Notification */
|
/** @var \Friendica\Repository\Notify */
|
||||||
private $repo;
|
private $repo;
|
||||||
|
|
||||||
public function __construct(Database $dba, LoggerInterface $logger, \Friendica\Repository\Notification $repo, array $data = [])
|
public function __construct(Database $dba, LoggerInterface $logger, \Friendica\Repository\Notify $repo, array $data = [])
|
||||||
{
|
{
|
||||||
parent::__construct($dba, $logger, $data);
|
parent::__construct($dba, $logger, $data);
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Introductions extends BaseNotifications
|
||||||
|
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => 'introductions',
|
'ident' => 'introductions',
|
||||||
'notifications' => DI::factNotIntro()->getList($all, self::$firstItemNum, self::ITEMS_PER_PAGE, $id),
|
'notifications' => DI::notificationIntro()->getList($all, self::$firstItemNum, self::ITEMS_PER_PAGE, $id),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Notification extends BaseModule
|
||||||
// @TODO: Replace with parameter from router
|
// @TODO: Replace with parameter from router
|
||||||
if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') {
|
if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') {
|
||||||
try {
|
try {
|
||||||
$success = DI::notification()->setAllSeen();
|
$success = DI::notify()->setAllSeen();
|
||||||
}catch (\Exception $e) {
|
}catch (\Exception $e) {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class Notification extends BaseModule
|
||||||
// @TODO: Replace with parameter from router
|
// @TODO: Replace with parameter from router
|
||||||
if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) {
|
if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) {
|
||||||
try {
|
try {
|
||||||
$notification = DI::notification()->getByID(DI::args()->get(2));
|
$notification = DI::notify()->getByID(DI::args()->get(2));
|
||||||
$notification->setSeen();
|
$notification->setSeen();
|
||||||
|
|
||||||
if (!empty($notification->link)) {
|
if (!empty($notification->link)) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Notifications extends BaseNotifications
|
||||||
$notificationHeader = DI::l10n()->t('Network Notifications');
|
$notificationHeader = DI::l10n()->t('Network Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => Notification::NETWORK,
|
'ident' => Notification::NETWORK,
|
||||||
'notifications' => DI::factNotification()->getNetworkList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => DI::notification()->getNetworkList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Get the system notifications
|
// Get the system notifications
|
||||||
|
@ -39,7 +39,7 @@ class Notifications extends BaseNotifications
|
||||||
$notificationHeader = DI::l10n()->t('System Notifications');
|
$notificationHeader = DI::l10n()->t('System Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => Notification::SYSTEM,
|
'ident' => Notification::SYSTEM,
|
||||||
'notifications' => DI::factNotification()->getSystemList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => DI::notification()->getSystemList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Get the personal notifications
|
// Get the personal notifications
|
||||||
|
@ -47,7 +47,7 @@ class Notifications extends BaseNotifications
|
||||||
$notificationHeader = DI::l10n()->t('Personal Notifications');
|
$notificationHeader = DI::l10n()->t('Personal Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => Notification::PERSONAL,
|
'ident' => Notification::PERSONAL,
|
||||||
'notifications' => DI::factNotification()->getPersonalList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => DI::notification()->getPersonalList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Get the home notifications
|
// Get the home notifications
|
||||||
|
@ -55,7 +55,7 @@ class Notifications extends BaseNotifications
|
||||||
$notificationHeader = DI::l10n()->t('Home Notifications');
|
$notificationHeader = DI::l10n()->t('Home Notifications');
|
||||||
$notifications = [
|
$notifications = [
|
||||||
'ident' => Notification::HOME,
|
'ident' => Notification::HOME,
|
||||||
'notifications' => DI::factNotification()->getHomeList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
'notifications' => DI::notification()->getHomeList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE),
|
||||||
];
|
];
|
||||||
// fallback - redirect to main page
|
// fallback - redirect to main page
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,28 +10,28 @@ use Friendica\Collection;
|
||||||
use Friendica\Network\HTTPException\NotFoundException;
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
class Notification extends BaseRepository
|
class Notify extends BaseRepository
|
||||||
{
|
{
|
||||||
protected static $table_name = 'notify';
|
protected static $table_name = 'notify';
|
||||||
|
|
||||||
protected static $model_class = Model\Notification::class;
|
protected static $model_class = Model\Notify::class;
|
||||||
|
|
||||||
protected static $collection_class = Collection\Notifications::class;
|
protected static $collection_class = Collection\Notifies::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @return Model\Notification
|
* @return Model\Notify
|
||||||
*/
|
*/
|
||||||
protected function create(array $data)
|
protected function create(array $data)
|
||||||
{
|
{
|
||||||
return new Model\Notification($this->dba, $this->logger, $this, $data);
|
return new Model\Notify($this->dba, $this->logger, $this, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @return Collection\Notifications
|
* @return Collection\Notifies
|
||||||
*/
|
*/
|
||||||
public function select(array $condition = [], array $params = [])
|
public function select(array $condition = [], array $params = [])
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ class Notification extends BaseRepository
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @return Model\Notification
|
* @return Model\Notify
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function getByID(int $id)
|
public function getByID(int $id)
|
||||||
|
@ -67,7 +67,7 @@ class Notification extends BaseRepository
|
||||||
/**
|
/**
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
*
|
*
|
||||||
* @return Model\Notification
|
* @return Model\Notify
|
||||||
*
|
*
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws Exception
|
* @throws Exception
|
Loading…
Reference in a new issue