- $notification = [
- 'subscription' => Subscription::create([
- 'endpoint' => $subscription['endpoint'],
- 'publicKey' => $subscription['pubkey'],
- 'authToken' => $subscription['secret'],
- ]),
- 'payload' => null,
+ 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'] ?: '';
+
+ $push = Subscription::create([
+ 'contentEncoding' => 'aesgcm',
+ 'endpoint' => $subscription['endpoint'],
+ 'keys' => [
+ 'p256dh' => $subscription['pubkey'],
+ 'auth' => $subscription['secret']
+ ],
+ ]);
+
+ $payload = [
+ 'access_token' => $application_token['access_token'],
+ 'preferred_locale' => $user['language'],
+ 'notification_id' => $nid,
+ 'notification_type' => \Friendica\Factory\Api\Mastodon\Notification::getType($Notification),
+ 'icon' => $actor['thumb'] ?? '',
+ 'title' => $title ?: $l10n->t('Notification from Friendica'),
+ 'body' => $body ?: $l10n->t('Empty Post'),