- $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' => NotificationFactory::getType($notification),
+ 'icon' => $actor['thumb'] ?? '',
+ 'title' => $title ?: $l10n->t('Notification from Friendica'),
+ 'body' => $body ?: $l10n->t('Empty Post'),