+ if (empty($subscription)) {
+ Logger::info('Subscription not found', ['subscription' => $sid]);
+ return;
+ }
+
+ try {
+ $Notification = DI::notification()->selectOneById($nid);
+ } catch (NotFoundException $e) {
+ Logger::info('Notification not found', ['notification' => $nid]);
+ return;
+ }
+
+ $application_token = DBA::selectFirst('application-token', [], ['application-id' => $subscription['application-id'], 'uid' => $subscription['uid']]);
+ if (empty($application_token)) {
+ Logger::info('Application token not found', ['application' => $subscription['application-id']]);
+ return;
+ }
+
+ $user = User::getById($Notification->uid);
+ if (empty($user)) {
+ Logger::info('User not found', ['application' => $subscription['uid']]);
+ return;
+ }
+
+ $l10n = DI::l10n()->withLang($user['language']);
+
+ if ($Notification->actorId) {
+ $actor = Contact::getById($Notification->actorId);
+ }
+
+ $body = '';
+
+ if ($Notification->targetUriId) {
+ $post = Post::selectFirst([], ['uri-id' => $Notification->targetUriId, 'uid' => [0, $Notification->uid]]);
+ if (!empty($post['body'])) {
+ $body = BBCode::toPlaintext($post['body'], false);
+ $body = Plaintext::shorten($body, 160, $Notification->uid);
+ }
+ }
+
+ $message = DI::notificationFactory()->getMessageFromNotification($Notification);
+ $title = $message['plain'] ?: '';