Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Trim the subject before encrypting the subject
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and Backportbot committed Jul 16, 2019
commit 31e3ff56607f40770c114b86c593845df838ad00
9 changes: 8 additions & 1 deletion lib/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down