use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\Notify;
+use Friendica\Model\Notification;
use Friendica\Util\BasePath;
use Friendica\Util\DateTimeFormat;
define('MAX_LIKERS', 75);
/**
- * @name Notify
+ * @name Notification
*
* Email notification options
* @{
*/
-/** @deprecated since 2020.03, use Notify\Type::INTRO instead */
-define('NOTIFY_INTRO', Notify\Type::INTRO);
-/** @deprecated since 2020.03, use Notify\Type::CONFIRM instead */
-define('NOTIFY_CONFIRM', Notify\Type::CONFIRM);
-/** @deprecated since 2020.03, use Notify\Type::WALL instead */
-define('NOTIFY_WALL', Notify\Type::WALL);
-/** @deprecated since 2020.03, use Notify\Type::COMMENT instead */
-define('NOTIFY_COMMENT', Notify\Type::COMMENT);
-/** @deprecated since 2020.03, use Notify\Type::MAIL instead */
-define('NOTIFY_MAIL', Notify\Type::MAIL);
-/** @deprecated since 2020.03, use Notify\Type::SUGGEST instead */
-define('NOTIFY_SUGGEST', Notify\Type::SUGGEST);
-/** @deprecated since 2020.03, use Notify\Type::PROFILE instead */
-define('NOTIFY_PROFILE', Notify\Type::PROFILE);
-/** @deprecated since 2020.03, use Notify\Type::TAG_SELF instead */
-define('NOTIFY_TAGSELF', Notify\Type::TAG_SELF);
-/** @deprecated since 2020.03, use Notify\Type::TAG_SHARE instead */
-define('NOTIFY_TAGSHARE', Notify\Type::TAG_SHARE);
-/** @deprecated since 2020.03, use Notify\Type::POKE instead */
-define('NOTIFY_POKE', Notify\Type::POKE);
-/** @deprecated since 2020.03, use Notify\Type::SHARE instead */
-define('NOTIFY_SHARE', Notify\Type::SHARE);
-
-/** @deprecated since 2020.12, use Notify\Type::SYSTEM instead */
-define('NOTIFY_SYSTEM', Notify\Type::SYSTEM);
+/** @deprecated since 2020.03, use Notification\Type::INTRO instead */
+define('NOTIFY_INTRO', Notification\Type::INTRO);
+/** @deprecated since 2020.03, use Notification\Type::CONFIRM instead */
+define('NOTIFY_CONFIRM', Notification\Type::CONFIRM);
+/** @deprecated since 2020.03, use Notification\Type::WALL instead */
+define('NOTIFY_WALL', Notification\Type::WALL);
+/** @deprecated since 2020.03, use Notification\Type::COMMENT instead */
+define('NOTIFY_COMMENT', Notification\Type::COMMENT);
+/** @deprecated since 2020.03, use Notification\Type::MAIL instead */
+define('NOTIFY_MAIL', Notification\Type::MAIL);
+/** @deprecated since 2020.03, use Notification\Type::SUGGEST instead */
+define('NOTIFY_SUGGEST', Notification\Type::SUGGEST);
+/** @deprecated since 2020.03, use Notification\Type::PROFILE instead */
+define('NOTIFY_PROFILE', Notification\Type::PROFILE);
+/** @deprecated since 2020.03, use Notification\Type::TAG_SELF instead */
+define('NOTIFY_TAGSELF', Notification\Type::TAG_SELF);
+/** @deprecated since 2020.03, use Notification\Type::TAG_SHARE instead */
+define('NOTIFY_TAGSHARE', Notification\Type::TAG_SHARE);
+/** @deprecated since 2020.03, use Notification\Type::POKE instead */
+define('NOTIFY_POKE', Notification\Type::POKE);
+/** @deprecated since 2020.03, use Notification\Type::SHARE instead */
+define('NOTIFY_SHARE', Notification\Type::SHARE);
+
+/** @deprecated since 2020.12, use Notification\Type::SYSTEM instead */
+define('NOTIFY_SYSTEM', Notification\Type::SYSTEM);
/* @}*/
/**
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Mail;
-use Friendica\Model\Notify;
+use Friendica\Model\Notification;
use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Model\UserItem;
use Friendica\Model\Verb;
-use Friendica\Security\FKOAuth1;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Network\HTTPException\ExpectationFailedException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\MethodNotAllowedException;
use Friendica\Network\HTTPException\NotFoundException;
-use Friendica\Network\HTTPException\NotImplementedException;
use Friendica\Network\HTTPException\TooManyRequestsException;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
use Friendica\Protocol\Diaspora;
+use Friendica\Security\FKOAuth1;
use Friendica\Security\OAuth1\OAuthRequest;
use Friendica\Security\OAuth1\OAuthUtil;
use Friendica\Util\DateTimeFormat;
$notify = DI::notify()->getByID($id, api_user());
DI::notify()->setSeen(true, $notify);
- if ($notify->otype === Notify\ObjectType::ITEM) {
+ if ($notify->otype === Notification\ObjectType::ITEM) {
$item = Post::selectFirstForUser(api_user(), [], ['id' => $notify->iid, 'uid' => api_user()]);
if (DBA::isResult($item)) {
// we found the item, return it to the user
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\ItemContent;
-use Friendica\Model\Notify;
+use Friendica\Model\Notification;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Model\UserItem;
$hsitelink = '';
$itemlink = '';
- if ($params['type'] == Notify\Type::MAIL) {
+ if ($params['type'] == Notification\Type::MAIL) {
$itemlink = $params['link'];
$subject = $l10n->t('%s New mail received at %s', $subjectPrefix, $sitename);
$show_in_notification_page = false;
}
- if ($params['type'] == Notify\Type::COMMENT || $params['type'] == Notify\Type::TAG_SELF) {
+ if ($params['type'] == Notification\Type::COMMENT || $params['type'] == Notification\Type::TAG_SELF) {
$thread = Post::selectFirstThreadForUser($params['uid'], ['ignored'], ['iid' => $parent_id, 'deleted' => false]);
if (DBA::isResult($thread) && $thread['ignored']) {
Logger::log('Thread ' . $parent_id . ' will be ignored', Logger::DEBUG);
// Check to see if there was already a tag notify or comment notify for this post.
// If so don't create a second notification
/// @todo In the future we should store the notification with the highest "value" and replace notifications
- $condition = ['type' => [Notify\Type::TAG_SELF, Notify\Type::COMMENT, Notify\Type::SHARE],
+ $condition = ['type' => [Notification\Type::TAG_SELF, Notification\Type::COMMENT, Notification\Type::SHARE],
'link' => $params['link'], 'uid' => $params['uid']];
if (DBA::exists('notify', $condition)) {
return false;
// if it's a post figure out who's post it is.
$item = null;
- if ($params['otype'] === Notify\ObjectType::ITEM && $parent_id) {
+ if ($params['otype'] === Notification\ObjectType::ITEM && $parent_id) {
$item = Post::selectFirstForUser($params['uid'], Item::ITEM_FIELDLIST, ['id' => $parent_id, 'deleted' => false]);
}
$itemlink = $params['link'];
}
- if ($params['type'] == Notify\Type::WALL) {
+ if ($params['type'] == Notification\Type::WALL) {
$subject = $l10n->t('%s %s posted to your profile wall', $subjectPrefix, $params['source_name']);
$preamble = $l10n->t('%1$s posted to your profile wall at %2$s', $params['source_name'], $sitename);
$itemlink = $params['link'];
}
- if ($params['type'] == Notify\Type::SHARE) {
+ if ($params['type'] == Notification\Type::SHARE) {
if ($params['origin_link'] == $params['source_link']) {
$subject = $l10n->t('%s %s shared a new post', $subjectPrefix, $params['source_name']);
$itemlink = $params['link'];
}
- if ($params['type'] == Notify\Type::POKE) {
+ if ($params['type'] == Notification\Type::POKE) {
$subject = $l10n->t('%1$s %2$s poked you', $subjectPrefix, $params['source_name']);
$preamble = $l10n->t('%1$s poked you at %2$s', $params['source_name'], $sitename);
$itemlink = $params['link'];
}
- if ($params['type'] == Notify\Type::TAG_SHARE) {
+ if ($params['type'] == Notification\Type::TAG_SHARE) {
$itemlink = $params['link'];
$subject = $l10n->t('%s %s tagged your post', $subjectPrefix, $params['source_name']);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
}
- if ($params['type'] == Notify\Type::INTRO) {
+ if ($params['type'] == Notification\Type::INTRO) {
$itemlink = $params['link'];
$subject = $l10n->t('%s Introduction received', $subjectPrefix);
}
}
- if ($params['type'] == Notify\Type::SUGGEST) {
+ if ($params['type'] == Notification\Type::SUGGEST) {
$itemlink = $params['link'];
$subject = $l10n->t('%s Friend suggestion received', $subjectPrefix);
$hsitelink = sprintf($sitelink, '<a href="'.$siteurl.'">'.$sitename.'</a>');
}
- if ($params['type'] == Notify\Type::CONFIRM) {
+ if ($params['type'] == Notification\Type::CONFIRM) {
if ($params['verb'] == Activity::FRIEND) { // mutual connection
$itemlink = $params['link'];
$subject = $l10n->t('%s Connection accepted', $subjectPrefix);
}
}
- if ($params['type'] == Notify\Type::SYSTEM) {
+ if ($params['type'] == Notification\Type::SYSTEM) {
switch($params['event']) {
case "SYSTEM_REGISTER_REQUEST":
$itemlink = $params['link'];
// send email notification if notification preferences permit
if ((intval($params['notify_flags']) & intval($params['type']))
- || $params['type'] == Notify\Type::SYSTEM) {
+ || $params['type'] == Notification\Type::SYSTEM) {
Logger::log('sending notification email');
// Generate the notification array
$params = [];
- $params['otype'] = Notify\ObjectType::ITEM;
+ $params['otype'] = Notification\ObjectType::ITEM;
$params['uid'] = $uid;
$params['origin_cid'] = $params['cid'] = $item['author-id'];
$params['item'] = $item;
}
if ($notification_type & UserItem::NOTIF_SHARED) {
- $params['type'] = Notify\Type::SHARE;
+ $params['type'] = Notification\Type::SHARE;
$params['verb'] = Activity::POST;
// Special treatment for posts that had been shared via "announce"
}
}
} elseif ($notification_type & UserItem::NOTIF_EXPLICIT_TAGGED) {
- $params['type'] = Notify\Type::TAG_SELF;
+ $params['type'] = Notification\Type::TAG_SELF;
$params['verb'] = Activity::TAG;
} elseif ($notification_type & UserItem::NOTIF_IMPLICIT_TAGGED) {
- $params['type'] = Notify\Type::COMMENT;
+ $params['type'] = Notification\Type::COMMENT;
$params['verb'] = Activity::POST;
} elseif ($notification_type & UserItem::NOTIF_THREAD_COMMENT) {
- $params['type'] = Notify\Type::COMMENT;
+ $params['type'] = Notification\Type::COMMENT;
$params['verb'] = Activity::POST;
} elseif ($notification_type & UserItem::NOTIF_DIRECT_COMMENT) {
- $params['type'] = Notify\Type::COMMENT;
+ $params['type'] = Notification\Type::COMMENT;
$params['verb'] = Activity::POST;
} elseif ($notification_type & UserItem::NOTIF_COMMENT_PARTICIPATION) {
- $params['type'] = Notify\Type::COMMENT;
+ $params['type'] = Notification\Type::COMMENT;
$params['verb'] = Activity::POST;
} elseif ($notification_type & UserItem::NOTIF_ACTIVITY_PARTICIPATION) {
- $params['type'] = Notify\Type::COMMENT;
+ $params['type'] = Notification\Type::COMMENT;
$params['verb'] = Activity::POST;
} else {
return false;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
-use Friendica\Model\Notify;
-use Friendica\Model\Notify\Type;
+use Friendica\Model\Notification;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Util\Crypto;
if (DBA::isResult($r)) {
$combined = $r[0];
- if ($combined['notify-flags'] & Type::CONFIRM) {
+ if ($combined['notify-flags'] & Notification\Type::CONFIRM) {
$mutual = ($new_relation == Contact::FRIEND);
notification([
- 'type' => Type::CONFIRM,
- 'otype' => Notify\ObjectType::INTRO,
+ 'type' => Notification\Type::CONFIRM,
+ 'otype' => Notification\ObjectType::INTRO,
'verb' => ($mutual ? Activity::FRIEND : Activity::FOLLOW),
'uid' => $combined['uid'],
'cid' => $combined['id'],
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
-use Friendica\Model\Notify;
-use Friendica\Model\Notify\Type;
+use Friendica\Model\Notification;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Module\Security\Login;
if (!$auto_confirm) {
notification([
- 'type' => Type::INTRO,
- 'otype' => Notify\ObjectType::INTRO,
+ 'type' => Notification\Type::INTRO,
+ 'otype' => Notification\ObjectType::INTRO,
'verb' => Activity::REQ_FRIEND,
'uid' => $r[0]['uid'],
'cid' => $r[0]['id'],
use Friendica\Model\Conversation;
use Friendica\Model\FileTag;
use Friendica\Model\Item;
-use Friendica\Model\Notify;
-use Friendica\Model\Notify\Type;
+use Friendica\Model\Notification;
use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Object\EMail\ItemCCEMail;
use Friendica\Protocol\Activity;
use Friendica\Protocol\Diaspora;
-use Friendica\Util\DateTimeFormat;
use Friendica\Security\Security;
+use Friendica\Util\DateTimeFormat;
use Friendica\Worker\Delivery;
function item_post(App $a) {
if ($contact_record != $author) {
if ($toplevel_item_id) {
notification([
- 'type' => Type::COMMENT,
- 'otype' => Notify\ObjectType::ITEM,
+ 'type' => Notification\Type::COMMENT,
+ 'otype' => Notification\ObjectType::ITEM,
'verb' => Activity::POST,
'uid' => $profile_uid,
'cid' => $datarray['author-id'],
]);
} elseif (empty($forum_contact)) {
notification([
- 'type' => Type::WALL,
- 'otype' => Notify\ObjectType::ITEM,
+ 'type' => Notification\Type::WALL,
+ 'otype' => Notification\ObjectType::ITEM,
'verb' => Activity::POST,
'uid' => $profile_uid,
'cid' => $datarray['author-id'],
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Mail;
-use Friendica\Model\Notify\Type;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
-use Friendica\Model\Notify\Type;
+use Friendica\Model\Notification;
use Friendica\Model\Post;
use Friendica\Model\Verb;
use Friendica\Protocol\Activity;
AND NOT (`notify`.`type` IN (%d, %d))
AND $seensql `notify`.`seen` ORDER BY `notify`.`date` $order LIMIT %d, 50",
intval($uid),
- intval(Type::INTRO),
- intval(Type::MAIL),
+ intval(Notification\Type::INTRO),
+ intval(Notification\Type::MAIL),
intval($offset)
);
$notification["message"] = $notification["msg_cache"];
} else {
$notification["name"] = strip_tags(BBCode::convert($notification["name"]));
- $notification["message"] = Friendica\Model\Notify::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"])));
+ $notification["message"] = Notification::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"])));
q(
"UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d",
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
-use Friendica\Model\Notify\Type;
+use Friendica\Model\Notification;
use Friendica\Model\User;
use Friendica\Module\BaseSettings;
use Friendica\Module\Security\Login;
'$h_not' => DI::l10n()->t('Notification Settings'),
'$lbl_not' => DI::l10n()->t('Send a notification email when:'),
- '$notify1' => ['notify1', DI::l10n()->t('You receive an introduction'), ($notify & Type::INTRO), Type::INTRO, ''],
- '$notify2' => ['notify2', DI::l10n()->t('Your introductions are confirmed'), ($notify & Type::CONFIRM), Type::CONFIRM, ''],
- '$notify3' => ['notify3', DI::l10n()->t('Someone writes on your profile wall'), ($notify & Type::WALL), Type::WALL, ''],
- '$notify4' => ['notify4', DI::l10n()->t('Someone writes a followup comment'), ($notify & Type::COMMENT), Type::COMMENT, ''],
- '$notify5' => ['notify5', DI::l10n()->t('You receive a private message'), ($notify & Type::MAIL), Type::MAIL, ''],
- '$notify6' => ['notify6', DI::l10n()->t('You receive a friend suggestion'), ($notify & Type::SUGGEST), Type::SUGGEST, ''],
- '$notify7' => ['notify7', DI::l10n()->t('You are tagged in a post'), ($notify & Type::TAG_SELF), Type::TAG_SELF, ''],
- '$notify8' => ['notify8', DI::l10n()->t('You are poked/prodded/etc. in a post'), ($notify & Type::POKE), Type::POKE, ''],
+ '$notify1' => ['notify1', DI::l10n()->t('You receive an introduction'), ($notify & Notification\Type::INTRO), Notification\Type::INTRO, ''],
+ '$notify2' => ['notify2', DI::l10n()->t('Your introductions are confirmed'), ($notify & Notification\Type::CONFIRM), Notification\Type::CONFIRM, ''],
+ '$notify3' => ['notify3', DI::l10n()->t('Someone writes on your profile wall'), ($notify & Notification\Type::WALL), Notification\Type::WALL, ''],
+ '$notify4' => ['notify4', DI::l10n()->t('Someone writes a followup comment'), ($notify & Notification\Type::COMMENT), Notification\Type::COMMENT, ''],
+ '$notify5' => ['notify5', DI::l10n()->t('You receive a private message'), ($notify & Notification\Type::MAIL), Notification\Type::MAIL, ''],
+ '$notify6' => ['notify6', DI::l10n()->t('You receive a friend suggestion'), ($notify & Notification\Type::SUGGEST), Notification\Type::SUGGEST, ''],
+ '$notify7' => ['notify7', DI::l10n()->t('You are tagged in a post'), ($notify & Notification\Type::TAG_SELF), Notification\Type::TAG_SELF, ''],
+ '$notify8' => ['notify8', DI::l10n()->t('You are poked/prodded/etc. in a post'), ($notify & Notification\Type::POKE), Notification\Type::POKE, ''],
'$desktop_notifications' => ['desktop_notifications', DI::l10n()->t('Activate desktop notifications') , false, DI::l10n()->t('Show desktop popup on new notifications')],
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Collection;
+
+use Friendica\BaseCollection;
+use Friendica\Model;
+
+class Notifications extends BaseCollection
+{
+ /**
+ * @return Model\Notification
+ */
+ public function current()
+ {
+ return parent::current();
+ }
+}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2020, Friendica
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Collection;
-
-use Friendica\BaseCollection;
-use Friendica\Model;
-
-class Notifies extends BaseCollection
-{
- /**
- * @return Model\Notify
- */
- public function current()
- {
- return parent::current();
- }
-}
}
/**
- * @return Repository\Notify
+ * @return Repository\Notification
*/
public static function notify()
{
- return self::$dice->create(Repository\Notify::class);
+ return self::$dice->create(Repository\Notification::class);
}
//
{
/** @var Database */
private $dba;
- /** @var Repository\Notify */
+ /** @var Repository\Notification */
private $notification;
/** @var BaseURL */
private $baseUrl;
/** @var string */
private $nurl;
- public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
+ public function __construct(LoggerInterface $logger, Database $dba, Repository\Notification $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
{
parent::__construct($logger);
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Model\Notify\Type;
use Friendica\Network\HTTPException;
use Friendica\Network\Probe;
use Friendica\Protocol\Activity;
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
- if (($user['notify-flags'] & Type::INTRO) &&
+ if (($user['notify-flags'] & Notification\Type::INTRO) &&
in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL])) {
notification([
- 'type' => Type::INTRO,
- 'otype' => Notify\ObjectType::INTRO,
+ 'type' => Notification\Type::INTRO,
+ 'otype' => Notification\ObjectType::INTRO,
'verb' => ($sharing ? Activity::FRIEND : Activity::FOLLOW),
'uid' => $user['uid'],
'cid' => $contact_record['id'],
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Model\Notify\Type;
use Friendica\Network\Probe;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
DBA::insert('intro', $fields);
notification([
- 'type' => Type::SUGGEST,
- 'otype' => Notify\ObjectType::INTRO,
+ 'type' => Notification\Type::SUGGEST,
+ 'otype' => Notification\ObjectType::INTRO,
'verb' => Activity::REQ_FRIEND,
'uid' => $owner['uid'],
'cid' => $from_contact['uid'],
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\DI;
use Friendica\Database\DBA;
-use Friendica\Model\Notify\Type;
+use Friendica\DI;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Worker\Delivery;
// send notifications.
$notif_params = [
- 'type' => Type::MAIL,
- 'otype' => Notify\ObjectType::MAIL,
+ 'type' => Notification\Type::MAIL,
+ 'otype' => Notification\ObjectType::MAIL,
'verb' => Activity::POST,
'uid' => $user['uid'],
'cid' => $msg['contact-id'],
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Model;
+
+use Friendica\BaseModel;
+use Friendica\Content\Text\BBCode;
+use Friendica\Database\Database;
+use Friendica\Network\HTTPException\InternalServerErrorException;
+use Psr\Log\LoggerInterface;
+
+/**
+ * Model for an entry in the notify table
+ *
+ * @property string hash
+ * @property integer type
+ * @property string name Full name of the contact subject
+ * @property string url Profile page URL of the contact subject
+ * @property string photo Profile photo URL of the contact subject
+ * @property string date YYYY-MM-DD hh:mm:ss local server time
+ * @property string msg
+ * @property integer uid Owner User Id
+ * @property string link Notification URL
+ * @property integer iid Item Id
+ * @property integer parent Parent Item Id
+ * @property boolean seen Whether the notification was read or not.
+ * @property string verb Verb URL (@see http://activitystrea.ms)
+ * @property string otype Subject type ('item', 'intro' or 'mail')
+ *
+ * @property-read string name_cache Full name of the contact subject
+ * @property-read string msg_cache Plaintext version of the notification text with a placeholder (`{0}`) for the subject contact's name.
+ */
+class Notification extends BaseModel
+{
+ /** @var \Friendica\Repository\Notification */
+ private $repo;
+
+ public function __construct(Database $dba, LoggerInterface $logger, \Friendica\Repository\Notification $repo, array $data = [])
+ {
+ parent::__construct($dba, $logger, $data);
+
+ $this->repo = $repo;
+
+ $this->setNameCache();
+ $this->setMsgCache();
+ }
+
+ /**
+ * Sets the pre-formatted name (caching)
+ */
+ private function setNameCache()
+ {
+ try {
+ $this->name_cache = strip_tags(BBCode::convert($this->source_name));
+ } catch (InternalServerErrorException $e) {
+ }
+ }
+
+ /**
+ * Sets the pre-formatted msg (caching)
+ */
+ private function setMsgCache()
+ {
+ try {
+ $this->msg_cache = self::formatMessage($this->name_cache, strip_tags(BBCode::convert($this->msg)));
+ } catch (InternalServerErrorException $e) {
+ }
+ }
+
+ public function __set($name, $value)
+ {
+ parent::__set($name, $value);
+
+ if ($name == 'msg') {
+ $this->setMsgCache();
+ }
+
+ if ($name == 'source_name') {
+ $this->setNameCache();
+ }
+ }
+
+ /**
+ * Formats a notification message with the notification author
+ *
+ * Replace the name with {0} but ensure to make that only once. The {0} is used
+ * later and prints the name in bold.
+ *
+ * @param string $name
+ * @param string $message
+ *
+ * @return string Formatted message
+ */
+ public static function formatMessage($name, $message)
+ {
+ if ($name != '') {
+ $pos = strpos($message, $name);
+ } else {
+ $pos = false;
+ }
+
+ if ($pos !== false) {
+ $message = substr_replace($message, '{0}', $pos, strlen($name));
+ }
+
+ return $message;
+ }
+}
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Model\Notification;
+
+/**
+ * Enum for different otypes of the Notify
+ */
+class ObjectType
+{
+ const PERSON = 'person';
+ const MAIL = 'mail';
+ const ITEM = 'item';
+ const INTRO = 'intro';
+}
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Model\Notification;
+
+/**
+ * Enum for different types of the Notify
+ */
+class Type
+{
+ /** @var int Notification about a introduction */
+ const INTRO = 1;
+ /** @var int Notification about a confirmed introduction */
+ const CONFIRM = 2;
+ /** @var int Notification about a post on your wall */
+ const WALL = 4;
+ /** @var int Notification about a followup comment */
+ const COMMENT = 8;
+ /** @var int Notification about a private message */
+ const MAIL = 16;
+ /** @var int Notification about a friend suggestion */
+ const SUGGEST = 32;
+ /** @var int Unknown Notification
+ * @deprecated
+ */
+ const PROFILE = 64;
+ /** @var int Notification about being tagged in a post */
+ const TAG_SELF = 128;
+ /** @var int Notification about being tagged
+ * @deprecated
+ */
+ const TAG_SHARE = 256;
+ /** @var int Notification about getting poked/prodded/etc. */
+ const POKE = 512;
+ /** @var int Notification about either a contact had posted something directly or the contact is a mentioned forum */
+ const SHARE = 1024;
+
+ /** @var int Global System notifications */
+ const SYSTEM = 32768;
+}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2020, Friendica
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Model;
-
-use Friendica\BaseModel;
-use Friendica\Content\Text\BBCode;
-use Friendica\Database\Database;
-use Friendica\Network\HTTPException\InternalServerErrorException;
-use Psr\Log\LoggerInterface;
-
-/**
- * Model for an entry in the notify table
- *
- * @property string hash
- * @property integer type
- * @property string name Full name of the contact subject
- * @property string url Profile page URL of the contact subject
- * @property string photo Profile photo URL of the contact subject
- * @property string date YYYY-MM-DD hh:mm:ss local server time
- * @property string msg
- * @property integer uid Owner User Id
- * @property string link Notification URL
- * @property integer iid Item Id
- * @property integer parent Parent Item Id
- * @property boolean seen Whether the notification was read or not.
- * @property string verb Verb URL (@see http://activitystrea.ms)
- * @property string otype Subject type ('item', 'intro' or 'mail')
- *
- * @property-read string name_cache Full name of the contact subject
- * @property-read string msg_cache Plaintext version of the notification text with a placeholder (`{0}`) for the subject contact's name.
- */
-class Notify extends BaseModel
-{
-
- /** @var \Friendica\Repository\Notify */
- private $repo;
-
- public function __construct(Database $dba, LoggerInterface $logger, \Friendica\Repository\Notify $repo, array $data = [])
- {
- parent::__construct($dba, $logger, $data);
-
- $this->repo = $repo;
-
- $this->setNameCache();
- $this->setMsgCache();
- }
-
- /**
- * Sets the pre-formatted name (caching)
- */
- private function setNameCache()
- {
- try {
- $this->name_cache = strip_tags(BBCode::convert($this->source_name));
- } catch (InternalServerErrorException $e) {
- }
- }
-
- /**
- * Sets the pre-formatted msg (caching)
- */
- private function setMsgCache()
- {
- try {
- $this->msg_cache = self::formatMessage($this->name_cache, strip_tags(BBCode::convert($this->msg)));
- } catch (InternalServerErrorException $e) {
- }
- }
-
- public function __set($name, $value)
- {
- parent::__set($name, $value);
-
- if ($name == 'msg') {
- $this->setMsgCache();
- }
-
- if ($name == 'source_name') {
- $this->setNameCache();
- }
- }
-
- /**
- * Formats a notification message with the notification author
- *
- * Replace the name with {0} but ensure to make that only once. The {0} is used
- * later and prints the name in bold.
- *
- * @param string $name
- * @param string $message
- *
- * @return string Formatted message
- */
- public static function formatMessage($name, $message)
- {
- if ($name != '') {
- $pos = strpos($message, $name);
- } else {
- $pos = false;
- }
-
- if ($pos !== false) {
- $message = substr_replace($message, '{0}', $pos, strlen($name));
- }
-
- return $message;
- }
-}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2020, Friendica
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-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';
-}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2020, Friendica
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Model\Notify;
-
-/**
- * Enum for different types of the Notify
- */
-class Type
-{
- /** @var int Notification about a introduction */
- const INTRO = 1;
- /** @var int Notification about a confirmed introduction */
- const CONFIRM = 2;
- /** @var int Notification about a post on your wall */
- const WALL = 4;
- /** @var int Notification about a followup comment */
- const COMMENT = 8;
- /** @var int Notification about a private message */
- const MAIL = 16;
- /** @var int Notification about a friend suggestion */
- const SUGGEST = 32;
- /** @var int Unknown Notification
- * @deprecated
- */
- const PROFILE = 64;
- /** @var int Notification about being tagged in a post */
- const TAG_SELF = 128;
- /** @var int Notification about being tagged
- * @deprecated
- */
- const TAG_SHARE = 256;
- /** @var int Notification about getting poked/prodded/etc. */
- const POKE = 512;
- /** @var int Notification about either a contact had posted something directly or the contact is a mentioned forum */
- const SHARE = 1024;
-
- /** @var int Global System notifications */
- const SYSTEM = 32768;
-}
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\Notify\Type;
+use Friendica\Model\Notification;
use Friendica\Model\User;
use Friendica\Network\HTTPException\ForbiddenException;
$identities[$key]['selected'] = ($identity['nickname'] === DI::app()->user['nickname']);
- $condition = ["`uid` = ? AND `msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", $identity['uid'], Type::INTRO, Type::MAIL];
+ $condition = ["`uid` = ? AND `msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", $identity['uid'], Notification\Type::INTRO, Notification\Type::MAIL];
$params = ['distinct' => true, 'expression' => 'parent'];
$notifications = DBA::count('notify', $condition, $params);
// send notification to admins
while ($admin = DBA::fetch($admins_stmt)) {
\notification([
- 'type' => Model\Notify\Type::SYSTEM,
+ 'type' => Model\Notification\Type::SYSTEM,
'event' => 'SYSTEM_REGISTER_REQUEST',
'uid' => $admin['uid'],
'link' => $base_url . '/admin/users/',
use Friendica\BaseEntity;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
-use Friendica\Model\Notify;
+use Friendica\Model\Notification as NotificationModel;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
/** @var string Message (Plaintext) */
protected $msg_plain;
- public function __construct(Notify $notify)
+ public function __construct(NotificationModel $notify)
{
// map each notify attribute to the entity
foreach ($notify->toArray() as $key => $value) {
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Mail;
-use Friendica\Model\Notify;
-use Friendica\Model\Notify\Type;
+use Friendica\Model\Notification;
use Friendica\Model\PermissionSet;
use Friendica\Model\Post;
use Friendica\Model\Post\Category;
// send a notification
notification(
[
- "type" => Type::POKE,
- "otype" => Notify\ObjectType::PERSON,
+ "type" => Notification\Type::POKE,
+ "otype" => Notification\ObjectType::PERSON,
"activity" => $verb,
"verb" => $item["verb"],
"uid" => $importer["importer_uid"],
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Repository;
+
+use Exception;
+use Friendica\BaseRepository;
+use Friendica\Collection;
+use Friendica\Core\Hook;
+use Friendica\Model;
+use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Network\HTTPException\NotFoundException;
+use Friendica\Util\DateTimeFormat;
+
+class Notification extends BaseRepository
+{
+ protected static $table_name = 'notify';
+
+ protected static $model_class = Model\Notification::class;
+
+ protected static $collection_class = Collection\Notifications::class;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return Model\Notification
+ */
+ protected function create(array $data)
+ {
+ return new Model\Notification($this->dba, $this->logger, $this, $data);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return Collection\Notifications
+ */
+ public function select(array $condition = [], array $params = [])
+ {
+ $params['order'] = $params['order'] ?? ['date' => 'DESC'];
+
+ return parent::select($condition, $params);
+ }
+
+ /**
+ * Return one notify instance based on ID / UID
+ *
+ * @param int $id The ID of the notify instance
+ * @param int $uid The user ID, bound to this notify instance (= security check)
+ *
+ * @return Model\Notification
+ * @throws NotFoundException
+ */
+ public function getByID(int $id, int $uid)
+ {
+ return $this->selectFirst(['id' => $id, 'uid' => $uid]);
+ }
+
+ /**
+ * Set seen state of notifications of the local_user()
+ *
+ * @param bool $seen optional true or false. default true
+ * @param Model\Notification $notify optional a notify, which should be set seen (including his parents)
+ *
+ * @return bool true on success, false on error
+ *
+ * @throws Exception
+ */
+ public function setSeen(bool $seen = true, Model\Notification $notify = null)
+ {
+ if (empty($notify)) {
+ $conditions = ['uid' => local_user()];
+ } else {
+ $conditions = ['(`link` = ? OR (`parent` != 0 AND `parent` = ? AND `otype` = ?)) AND `uid` = ?',
+ $notify->link,
+ $notify->parent,
+ $notify->otype,
+ local_user()];
+ }
+
+ return $this->dba->update('notify', ['seen' => $seen], $conditions);
+ }
+
+ /**
+ * @param array $fields
+ *
+ * @return Model\Notification|false
+ *
+ * @throws InternalServerErrorException
+ * @throws Exception
+ */
+ public function insert(array $fields)
+ {
+ $fields['date'] = DateTimeFormat::utcNow();
+
+ Hook::callAll('enotify_store', $fields);
+
+ if (empty($fields)) {
+ $this->logger->debug('Abort adding notification entry');
+ return false;
+ }
+
+ $this->logger->debug('adding notification entry', ['fields' => $fields]);
+
+ return parent::insert($fields);
+ }
+}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (C) 2020, Friendica
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Repository;
-
-use Exception;
-use Friendica\BaseRepository;
-use Friendica\Collection;
-use Friendica\Core\Hook;
-use Friendica\Model;
-use Friendica\Network\HTTPException\InternalServerErrorException;
-use Friendica\Network\HTTPException\NotFoundException;
-use Friendica\Util\DateTimeFormat;
-
-class Notify extends BaseRepository
-{
- protected static $table_name = 'notify';
-
- protected static $model_class = Model\Notify::class;
-
- protected static $collection_class = Collection\Notifies::class;
-
- /**
- * {@inheritDoc}
- *
- * @return Model\Notify
- */
- protected function create(array $data)
- {
- return new Model\Notify($this->dba, $this->logger, $this, $data);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return Collection\Notifies
- */
- public function select(array $condition = [], array $params = [])
- {
- $params['order'] = $params['order'] ?? ['date' => 'DESC'];
-
- return parent::select($condition, $params);
- }
-
- /**
- * Return one notify instance based on ID / UID
- *
- * @param int $id The ID of the notify instance
- * @param int $uid The user ID, bound to this notify instance (= security check)
- *
- * @return Model\Notify
- * @throws NotFoundException
- */
- public function getByID(int $id, int $uid)
- {
- return $this->selectFirst(['id' => $id, 'uid' => $uid]);
- }
-
- /**
- * Set seen state of notifications of the local_user()
- *
- * @param bool $seen optional true or false. default true
- * @param Model\Notify $notify optional a notify, which should be set seen (including his parents)
- *
- * @return bool true on success, false on error
- *
- * @throws Exception
- */
- public function setSeen(bool $seen = true, Model\Notify $notify = null)
- {
- if (empty($notify)) {
- $conditions = ['uid' => local_user()];
- } else {
- $conditions = ['(`link` = ? OR (`parent` != 0 AND `parent` = ? AND `otype` = ?)) AND `uid` = ?',
- $notify->link,
- $notify->parent,
- $notify->otype,
- local_user()];
- }
-
- return $this->dba->update('notify', ['seen' => $seen], $conditions);
- }
-
- /**
- * @param array $fields
- *
- * @return Model\Notify|false
- *
- * @throws InternalServerErrorException
- * @throws Exception
- */
- public function insert(array $fields)
- {
- $fields['date'] = DateTimeFormat::utcNow();
-
- Hook::callAll('enotify_store', $fields);
-
- if (empty($fields)) {
- $this->logger->debug('Abort adding notification entry');
- return false;
- }
-
- $this->logger->debug('adding notification entry', ['fields' => $fields]);
-
- return parent::insert($fields);
- }
-}
*
*/
-use Friendica\Model\Notify;
+use Friendica\Model\Notification;
return [
// Empty these tables
'iid' => 4,
'seen' => 0,
'verb' => '',
- 'otype' => Notify\ObjectType::ITEM,
+ 'otype' => Notification\ObjectType::ITEM,
'name_cache' => 'Reply to',
'msg_cache' => 'A test reply from an item',
],
* If you need to run a script before the database update, name the function "pre_update_4712()"
*/
-use Friendica\Core\Addon;
use Friendica\Core\Logger;
use Friendica\Core\Update;
use Friendica\Core\Worker;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
-use Friendica\Model\Notify;
+use Friendica\Model\Notification;
use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\Storage;
function update_1380()
{
if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`iid` SET `notify`.`uri-id` = `item`.`uri-id` WHERE `notify`.`uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
- Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) {
+ Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
return Update::FAILED;
}
if (!DBA::e("UPDATE `notify` INNER JOIN `item` ON `item`.`id` = `notify`.`parent` SET `notify`.`parent-uri-id` = `item`.`uri-id` WHERE `notify`.`parent-uri-id` IS NULL AND `notify`.`otype` IN (?, ?)",
- Notify\ObjectType::ITEM, Notify\ObjectType::PERSON)) {
+ Notification\ObjectType::ITEM, Notification\ObjectType::PERSON)) {
return Update::FAILED;
}