Skip to content
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: tidy up
Signed-off-by: Josh <[email protected]>
  • Loading branch information
joshtrichards authored Nov 1, 2025
commit 2bc74ae335c32fd4feda163fae732b70168123e8
12 changes: 9 additions & 3 deletions lib/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ public function pushDeleteToDevice(string $userId, ?array $notificationIds, stri
$this->deletePushToken($device['token']);
} catch (PushSigningException $e) {
// Server-side key problem: log already done; skip this device.
// TODO: Confirm remaining/queue is handled properly here (not a factor in pushToDevice())
continue;
}
}
Expand Down Expand Up @@ -649,7 +650,7 @@ protected function encryptAndSign(Key $userKey, array $device, int $id, INotific
// Calculate encoded base data length and maximum subject length
$encodedBaseData = json_encode($data, JSON_THROW_ON_ERROR);
$encodedBaseDataBytes = strlen($encodedBaseData); // length of encoded data before populating subject
$maxSubjectBytes = max(0, $maxPlain - $encodedBaseDataBytes - 2; // subtract two for quotes
$maxSubjectBytes = max(0, $maxPlain - $encodedBaseDataBytes - 2); // subtract two for quotes

// Use proposed subject as-is if it's length is compliant otherwise truncate
$subject = $notification->getParsedSubject();
Expand Down Expand Up @@ -690,7 +691,7 @@ protected function encryptAndSign(Key $userKey, array $device, int $id, INotific
} else {
$error = openssl_error_string();
$this->log->error('Error while encrypting push message: ' . $error, [
'app' => 'notifications'
'app' => 'notifications',
'deviceIdentifier' => $device['deviceidentifier'] ?? null,
'uid' => $device['uid'] ?? null,
]);
Expand Down Expand Up @@ -734,6 +735,11 @@ protected function encryptAndSign(Key $userKey, array $device, int $id, INotific
* @throws PushSigningException
*/
protected function encryptAndSignDelete(Key $userKey, array $device, ?array $ids): array {

if (empty($device['devicepublickey']) || empty($userKey->getPrivate())) {
throw new \InvalidArgumentException('Missing device public key or user private key');
}

$remainingIds = [];
if ($ids === null) {
$data = [
Expand Down Expand Up @@ -763,7 +769,7 @@ protected function encryptAndSignDelete(Key $userKey, array $device, ?array $ids
} else {
$error = openssl_error_string();
$this->log->error('Error while encrypting push delete message: ' . $error, [
'app' => 'notifications'
'app' => 'notifications',
'deviceIdentifier' => $device['deviceidentifier'] ?? null,
'uid' => $device['uid'] ?? null,
]);
Expand Down