diff --git a/lib/Push.php b/lib/Push.php index beade4755..6cdf5d2db 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -186,11 +186,18 @@ protected function encryptAndSign(Key $userKey, array $device, int $id, INotific $data = [ 'nid' => $id, 'app' => $notification->getApp(), - 'subject' => $notification->getParsedSubject(), + 'subject' => '', 'type' => $notification->getObjectType(), 'id' => $notification->getObjectId(), ]; + // Max length of encryption is 255, so we need to shorten the subject to be shorter + $subject = $notification->getParsedSubject(); + $dataLength = 245 - strlen(json_encode($data)); + if (strlen($subject) > $dataLength) { + $data['subject'] = substr($subject, 0, $dataLength) . '…'; + } + if ($isTalkNotification) { $priority = 'high'; } else {