- $push = [
- 'subscription' => Subscription::create([
- 'endpoint' => $subscription['endpoint'],
- 'publicKey' => $subscription['pubkey'],
- 'authToken' => $subscription['secret'],
- ]),
- // @todo Check if we are supposed to transmit a payload at all
- 'payload' => json_encode([
- 'title' => 'Friendica',
- 'body' => $notify['msg'] ?? '',
- 'icon' => $actor['thumb'] ?? '',
- 'image' => '',
- 'badge' => DI::baseUrl()->get() . '/images/friendica-192.png',
- 'tag' => $notification['parent-uri-id'] ?? '',
- 'timestamp' => DateTimeFormat::utc($notification['created'], DateTimeFormat::JSON),
- ]),
+ $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'),