Hash event UID to make sure it's not too long for PushProvider

notifications

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-02-01 15:29:02 +01:00
parent 7b5072ab61
commit 41fa057285
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 5 additions and 2 deletions

View File

@ -93,6 +93,9 @@ class PushProvider extends AbstractProvider {
$eventDetails = $this->extractEventDetails($vevent); $eventDetails = $this->extractEventDetails($vevent);
$eventDetails['calendar_displayname'] = $calendarDisplayName; $eventDetails['calendar_displayname'] = $calendarDisplayName;
$eventUUID = (string) $vevent->UID;
// Empty Notification ObjectId will be catched by OC\Notification\Notification
$eventUUIDHash = $eventUUID ? hash('sha256', $eventUUID, false) : '';
foreach($users as $user) { foreach($users as $user) {
/** @var INotification $notification */ /** @var INotification $notification */
@ -100,7 +103,7 @@ class PushProvider extends AbstractProvider {
$notification->setApp(Application::APP_ID) $notification->setApp(Application::APP_ID)
->setUser($user->getUID()) ->setUser($user->getUID())
->setDateTime($this->timeFactory->getDateTime()) ->setDateTime($this->timeFactory->getDateTime())
->setObject(Application::APP_ID, (string) $vevent->UID) ->setObject(Application::APP_ID, $eventUUIDHash)
->setSubject('calendar_reminder', [ ->setSubject('calendar_reminder', [
'title' => $eventDetails['title'], 'title' => $eventDetails['title'],
'start_atom' => $eventDetails['start_atom'] 'start_atom' => $eventDetails['start_atom']

View File

@ -189,7 +189,7 @@ class PushProviderTest extends AbstractNotificationProviderTest {
$notification->expects($this->once()) $notification->expects($this->once())
->method('setObject') ->method('setObject')
->with('dav', 'uid1234') ->with('dav', hash('sha256', 'uid1234', false))
->willReturn($notification); ->willReturn($notification);
$notification->expects($this->once()) $notification->expects($this->once())