use Friendica\Database\DBA;
use Friendica\Model\Post\UserNotification;
use Friendica\Model\Verb;
-use Friendica\Navigation\Notifications\Collection;
-use Friendica\Navigation\Notifications\Entity;
+use Friendica\Navigation\Notifications\Collection\Notifications as NotificationsCollection;
+use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
use Friendica\Navigation\Notifications\Factory;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Protocol\Activity;
}
/**
- * @param array $condition
- * @param array $params
- * @return Entity\Notification
* @throws NotFoundException
*/
- private function selectOne(array $condition, array $params = []): Entity\Notification
+ private function selectOne(array $condition, array $params = []): NotificationEntity
{
- return parent::_selectOne($condition, $params);
+ $fields = $this->_selectFirstRowAsArray( $condition, $params);
+
+ return $this->factory->createFromTableRow($fields);
}
- private function select(array $condition, array $params = []): Collection\Notifications
+ private function select(array $condition, array $params = []): NotificationsCollection
{
- return new Collection\Notifications(parent::_select($condition, $params)->getArrayCopy());
+ return new NotificationsCollection(parent::_select($condition, $params)->getArrayCopy());
}
public function countForUser($uid, array $condition, array $params = []): int
}
/**
- * @param int $id
- * @return Entity\Notification
* @throws NotFoundException
*/
- public function selectOneById(int $id): Entity\Notification
+ public function selectOneById(int $id): NotificationEntity
{
return $this->selectOne(['id' => $id]);
}
- public function selectOneForUser(int $uid, array $condition, array $params = []): Entity\Notification
+ public function selectOneForUser(int $uid, array $condition, array $params = []): NotificationEntity
{
$condition = DBA::mergeConditions($condition, ['uid' => $uid]);
return $this->selectOne($condition, $params);
}
- public function selectForUser(int $uid, array $condition = [], array $params = []): Collection\Notifications
+ public function selectForUser(int $uid, array $condition = [], array $params = []): NotificationsCollection
{
$condition = DBA::mergeConditions($condition, ['uid' => $uid]);
/**
* Returns only the most recent notifications for the same conversation or contact
*
- * @param int $uid
- *
- * @return Collection\Notifications
* @throws Exception
*/
- public function selectDetailedForUser(int $uid): Collection\Notifications
+ public function selectDetailedForUser(int $uid): NotificationsCollection
{
$notify_type = $this->pconfig->get($uid, 'system', 'notify_type');
if (!is_null($notify_type)) {
}
if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
- $condition = DBA::mergeConditions($condition, ['NOT `vid` IN (?, ?)', Verb::getID(\Friendica\Protocol\Activity::LIKE), Verb::getID(\Friendica\Protocol\Activity::DISLIKE)]);
+ $condition = DBA::mergeConditions($condition, ['NOT `vid` IN (?, ?)', Verb::getID(Activity::LIKE), Verb::getID(Activity::DISLIKE)]);
}
if (!$this->pconfig->get($uid, 'system', 'notify_announce')) {
- $condition = DBA::mergeConditions($condition, ['`vid` != ?', Verb::getID(\Friendica\Protocol\Activity::ANNOUNCE)]);
+ $condition = DBA::mergeConditions($condition, ['`vid` != ?', Verb::getID(Activity::ANNOUNCE)]);
}
return $this->selectForUser($uid, $condition, ['limit' => 50, 'order' => ['id' => true]]);
/**
* Returns only the most recent notifications for the same conversation or contact
*
- * @param int $uid
- *
- * @return Collection\Notifications
* @throws Exception
*/
- public function selectDigestForUser(int $uid): Collection\Notifications
+ public function selectDigestForUser(int $uid): NotificationsCollection
{
$values = [$uid];
$like_condition = '';
if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
$like_condition = 'AND NOT `vid` IN (?, ?)';
- $values[] = Verb::getID(\Friendica\Protocol\Activity::LIKE);
- $values[] = Verb::getID(\Friendica\Protocol\Activity::DISLIKE);
+ $values[] = Verb::getID(Activity::LIKE);
+ $values[] = Verb::getID(Activity::DISLIKE);
}
$announce_condition = '';
if (!$this->pconfig->get($uid, 'system', 'notify_announce')) {
$announce_condition = 'AND vid != ?';
- $values[] = Verb::getID(\Friendica\Protocol\Activity::ANNOUNCE);
+ $values[] = Verb::getID(Activity::ANNOUNCE);
}
$rows = $this->db->p("
LIMIT 50
", ...$values);
- $Entities = new Collection\Notifications();
+ $Entities = new NotificationsCollection();
foreach ($rows as $fields) {
$Entities[] = $this->factory->createFromTableRow($fields);
}
return $Entities;
}
- public function selectAllForUser(int $uid): Collection\Notifications
+ public function selectAllForUser(int $uid): NotificationsCollection
{
return $this->selectForUser($uid);
}
{
$BaseCollection = parent::_selectByBoundaries($condition, $params, $min_id, $max_id, $limit);
- return new Collection\Notifications($BaseCollection->getArrayCopy(), $BaseCollection->getTotalCount());
+ return new NotificationsCollection($BaseCollection->getArrayCopy(), $BaseCollection->getTotalCount());
}
public function setAllSeenForUser(int $uid, array $condition = []): bool
}
/**
- * @param Entity\Notification $Notification
- * @return Entity\Notification
* @throws Exception
*/
- public function save(Entity\Notification $Notification): Entity\Notification
+ public function save(NotificationEntity $Notification): NotificationEntity
{
$fields = [
'uid' => $Notification->uid,
use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory;
use Friendica\Model;
use Friendica\Navigation\Notifications\Collection;
-use Friendica\Navigation\Notifications\Entity;
+use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
+use Friendica\Navigation\Notifications\Entity\Notify as NotifyEntity;
use Friendica\Navigation\Notifications\Exception;
use Friendica\Navigation\Notifications\Factory;
use Friendica\Network\HTTPException;
use Psr\Log\LoggerInterface;
/**
- * @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Repository\Notification instead
+ * @deprecated 2022.05 Use `\Friendica\Navigation\Notifications\Repository\Notification` instead
*/
class Notify extends BaseRepository
{
}
/**
- * @param array $condition
- * @param array $params
- *
- * @return Entity\Notify
* @throws HTTPException\NotFoundException
*/
- private function selectOne(array $condition, array $params = []): Entity\Notify
+ private function selectOne(array $condition, array $params = []): NotifyEntity
{
- return parent::_selectOne($condition, $params);
+ $fields = $this->_selectFirstRowAsArray( $condition, $params);
+
+ return $this->factory->createFromTableRow($fields);
}
private function select(array $condition, array $params = []): Collection\Notifies
/**
* @param int $id
*
- * @return Entity\Notify
* @throws HTTPException\NotFoundException
*/
- public function selectOneById(int $id): Entity\Notify
+ public function selectOneById(int $id): NotifyEntity
{
return $this->selectOne(['id' => $id]);
}
}
/**
- * @param Entity\Notify $Notify
- *
- * @return Entity\Notify
* @throws HTTPException\NotFoundException
* @throws HTTPException\InternalServerErrorException
* @throws Exception\NotificationCreationInterceptedException
*/
- public function save(Entity\Notify $Notify): Entity\Notify
+ public function save(NotifyEntity $Notify): NotifyEntity
{
$fields = [
'type' => $Notify->type,
return $Notify;
}
- public function setAllSeenForRelatedNotify(Entity\Notify $Notify): bool
+ public function setAllSeenForRelatedNotify(NotifyEntity $Notify): bool
{
$condition = [
'(`link` = ? OR (`parent` != 0 AND `parent` = ? AND `otype` = ?)) AND `uid` = ?',
return false;
}
- public function shouldShowOnDesktop(Entity\Notification $Notification, string $type = null): bool
+ public function shouldShowOnDesktop(NotificationEntity $Notification, string $type = null): bool
{
if (is_null($type)) {
$type = NotificationFactory::getType($Notification);
return false;
}
- public function createFromNotification(Entity\Notification $Notification): bool
+ public function createFromNotification(NotificationEntity $Notification): bool
{
$this->logger->info('Start', ['uid' => $Notification->uid, 'id' => $Notification->id, 'type' => $Notification->type]);
/** @var string */
private $about;
+ public function __construct(array $data = [])
+ {
+ $this->label = $data['label'] ?? '';
+ $this->type = $data['str_type'] ?? '';
+ $this->intro_id = $data['intro_id'] ?? -1;
+ $this->madeBy = $data['madeBy'] ?? '';
+ $this->madeByUrl = $data['madeByUrl'] ?? '';
+ $this->madeByZrl = $data['madeByZrl'] ?? '';
+ $this->madeByAddr = $data['madeByAddr'] ?? '';
+ $this->contactId = $data['contactId'] ?? -1;
+ $this->photo = $data['photo'] ?? '';
+ $this->name = $data['name'] ?? '';
+ $this->url = $data['url'] ?? '';
+ $this->zrl = $data['zrl'] ?? '';
+ $this->hidden = $data['hidden'] ?? false;
+ $this->postNewFriend = $data['postNewFriend'] ?? '';
+ $this->knowYou = $data['knowYou'] ?? false;
+ $this->note = $data['note'] ?? '';
+ $this->request = $data['request'] ?? '';
+ $this->dfrnId = -1;
+ $this->addr = $data['addr'] ?? '';
+ $this->network = $data['network'] ?? '';
+ $this->uid = $data['uid'] ?? -1;
+ $this->keywords = $data['keywords'] ?? '';
+ $this->location = $data['location'] ?? '';
+ $this->about = $data['about'] ?? '';
+ }
+
public function getLabel(): string
{
return $this->label;
return $this->postNewFriend;
}
- public function getKnowYou(): string
+ public function getKnowYou(): bool
{
return $this->knowYou;
}
return $this->about;
}
- public function __construct(array $data = [])
- {
- $this->label = $data['label'] ?? '';
- $this->type = $data['str_type'] ?? '';
- $this->intro_id = $data['intro_id'] ?? -1;
- $this->madeBy = $data['madeBy'] ?? '';
- $this->madeByUrl = $data['madeByUrl'] ?? '';
- $this->madeByZrl = $data['madeByZrl'] ?? '';
- $this->madeByAddr = $data['madeByAddr'] ?? '';
- $this->contactId = $data['contactId'] ?? -1;
- $this->photo = $data['photo'] ?? '';
- $this->name = $data['name'] ?? '';
- $this->url = $data['url'] ?? '';
- $this->zrl = $data['zrl'] ?? '';
- $this->hidden = $data['hidden'] ?? false;
- $this->postNewFriend = $data['postNewFriend'] ?? '';
- $this->knowYou = $data['knowYou'] ?? false;
- $this->note = $data['note'] ?? '';
- $this->request = $data['request'] ?? '';
- $this->dfrnId = -1;
- $this->addr = $data['addr'] ?? '';
- $this->network = $data['network'] ?? '';
- $this->uid = $data['uid'] ?? -1;
- $this->keywords = $data['keywords'] ?? '';
- $this->location = $data['location'] ?? '';
- $this->about = $data['about'] ?? '';
- }
-
/**
* @inheritDoc
*/