use Friendica\Model\Post;
use Friendica\Model\Subscription as ModelSubscription;
use Friendica\Model\User;
use Friendica\Model\Post;
use Friendica\Model\Subscription as ModelSubscription;
use Friendica\Model\User;
- $notification = DBA::selectFirst('notification', [], ['id' => $nid]);
- if (empty($notification)) {
+ try {
+ $Notification = DI::notification()->selectOneById($nid);
+ } catch (NotFoundException $e) {
- $type = Notification::getType($notification);
-
- if (!empty($notification['actor-id'])) {
- $actor = Contact::getById($notification['actor-id']);
+ if ($Notification->actorId) {
+ $actor = Contact::getById($Notification->actorId);
- if (!empty($notification['target-uri-id'])) {
- $post = Post::selectFirst([], ['uri-id' => $notification['target-uri-id'], 'uid' => [0, $notification['uid']]]);
+ if ($Notification->targetUriId) {
+ $post = Post::selectFirst([], ['uri-id' => $Notification->targetUriId, 'uid' => [0, $Notification->uid]]);
if (!empty($post['body'])) {
$body = BBCode::toPlaintext($post['body'], false);
if (!empty($post['body'])) {
$body = BBCode::toPlaintext($post['body'], false);
- // @todo Add a meaningful title here, see the functionality in enotify.php
- $title = '';
+ $message = DI::notificationFactory()->getMessageFromNotification($Notification, DI::baseUrl(), $l10n);
+ $title = $message['plain'] ?: '';
$push = Subscription::create([
'contentEncoding' => 'aesgcm',
$push = Subscription::create([
'contentEncoding' => 'aesgcm',
'access_token' => $application_token['access_token'],
'preferred_locale' => $user['language'],
'notification_id' => $nid,
'access_token' => $application_token['access_token'],
'preferred_locale' => $user['language'],
'notification_id' => $nid,
'icon' => $actor['thumb'] ?? '',
'title' => $title ?: $l10n->t('Notification from Friendica'),
'body' => $body ?: $l10n->t('Empty Post'),
'icon' => $actor['thumb'] ?? '',
'title' => $title ?: $l10n->t('Notification from Friendica'),
'body' => $body ?: $l10n->t('Empty Post'),