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
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) . '…';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the substr not be 1 shorter than the dataLength?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with 245, instead of 255 so we have a little buffer there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok perfect. I wasn't sure if that was maybe for other metadata somewhere.

}

if ($isTalkNotification) {
$priority = 'high';
} else {
Expand Down