From 31e3ff56607f40770c114b86c593845df838ad00 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Jul 2019 15:19:18 +0200 Subject: [PATCH] Trim the subject before encrypting the subject Signed-off-by: Joas Schilling --- lib/Push.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Push.php b/lib/Push.php index 04e45d5d9..a9cca15d5 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -187,11 +187,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 {