Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(imip): dont propagate attendee changes in reply message #51131

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3591,4 +3591,21 @@ protected function purgeObjectInvitations(string $eventId): void {
->where($cmd->expr()->eq('uid', $cmd->createNamedParameter($eventId, IQueryBuilder::PARAM_STR), IQueryBuilder::PARAM_STR));
$cmd->executeStatement();
}

public function findEventDataByUri(string $uid, string $organizerUri): ?array {
$principalUri = $this->principalBackend->findByUri($organizerUri, 'principals/users');
$query = $this->db->getQueryBuilder();
$query->select('co.*')
->from('calendarobjects', 'co')
->join('co', 'calendars', 'c', $query->expr()->eq('co.calendarid', 'c.id'))
->where($query->expr()->eq('co.uid', $query->createNamedParameter($uid)))
->andWhere($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri)));
$stmt = $query->executeQuery();
$row = $stmt->fetch();
$stmt->closeCursor();
if (!$row) {
return null;
}
return $this->rowToCalendarObject($row);
}
}
3 changes: 2 additions & 1 deletion apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
switch (strtolower($iTipMessage->method)) {
case self::METHOD_REPLY:
$method = self::METHOD_REPLY;
$data = $this->imipService->buildBodyData($vEvent, $oldVevent);
$organizerEvent = $this->imipService->getOrganizerVEvent($vEvent->uid, $iTipMessage->recipient);

Check failure on line 188 in apps/dav/lib/CalDAV/Schedule/IMipPlugin.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

ImplicitToStringCast

apps/dav/lib/CalDAV/Schedule/IMipPlugin.php:188:62: ImplicitToStringCast: Argument 1 of OCA\DAV\CalDAV\Schedule\IMipService::getOrganizerVEvent expects string, but Sabre\VObject\Property|null provided with a __toString method (see https://psalm.dev/060)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, you can't just pull the event by the recipient, This will fail, for external organizers

$data = $this->imipService->buildReplyBodyData($organizerEvent);
$replyingAttendee = $this->imipService->getReplyingAttendee($iTipMessage);
break;
case self::METHOD_CANCEL:
Expand Down
38 changes: 37 additions & 1 deletion apps/dav/lib/CalDAV/Schedule/IMipService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\DAV\CalDAV\Schedule;

use OC\URLGenerator;
use OCA\DAV\CalDAV\CaldavBackend;
use OCA\DAV\CalDAV\EventReader;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
Expand All @@ -23,6 +24,7 @@
use Sabre\VObject\ITip\Message;
use Sabre\VObject\Parameter;
use Sabre\VObject\Property;
use Sabre\VObject\Reader;
use Sabre\VObject\Recur\EventIterator;

class IMipService {
Expand All @@ -44,6 +46,7 @@
private ISecureRandom $random,
private L10NFactory $l10nFactory,
private ITimeFactory $timeFactory,
private CaldavBackend $caldavBackend,

Check failure on line 49 in apps/dav/lib/CalDAV/Schedule/IMipService.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidClass

apps/dav/lib/CalDAV/Schedule/IMipService.php:49:3: InvalidClass: Class, interface or enum OCA\DAV\CalDAV\CaldavBackend has wrong casing (see https://psalm.dev/007)
) {
$language = $this->l10nFactory->findGenericLanguage();
$locale = $this->l10nFactory->findLocale($language);
Expand Down Expand Up @@ -159,7 +162,35 @@
if ($eventReaderCurrent->recurs()) {
$data['meeting_occurring'] = $this->generateOccurringString($eventReaderCurrent);
}

return $data;
}

/**
* @param VEvent $vEvent
* @return array
*/
public function buildReplyBodyData(VEvent $vEvent): array {
// construct event reader
$eventReader = new EventReader($vEvent);
$defaultVal = '';
$data = [];
$data['meeting_when'] = $this->generateWhenString($eventReader);

foreach (self::STRING_DIFF as $key => $property) {
$data[$key] = self::readPropertyWithDefault($vEvent, $property, $defaultVal);
}

if (($locationHtml = $this->linkify($data['meeting_location'])) !== null) {
$data['meeting_location_html'] = $locationHtml;
}

$data['meeting_url_html'] = $data['meeting_url'] ? sprintf('<a href="%1$s">%1$s</a>', $data['meeting_url']) : '';

// generate occurring next string
if ($eventReader->recurs()) {
$data['meeting_occurring'] = $this->generateOccurringString($eventReader);
}

return $data;
}

Expand Down Expand Up @@ -1142,6 +1173,11 @@
return null;
}

public function getOrganizerVEvent(string $uid, string $organizerUri): VEvent {

Check failure on line 1176 in apps/dav/lib/CalDAV/Schedule/IMipService.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidReturnType

apps/dav/lib/CalDAV/Schedule/IMipService.php:1176:73: InvalidReturnType: The declared return type 'Sabre\VObject\Component\VEvent' for OCA\DAV\CalDAV\Schedule\IMipService::getOrganizerVEvent is incorrect, got 'Sabre\VObject\Property|null' (see https://psalm.dev/011)
$organizerEvent = $this->caldavBackend->findEventDataByUri($uid, $organizerUri);
return Reader::read($organizerEvent['calendardata'])->VEVENT ;

Check failure on line 1178 in apps/dav/lib/CalDAV/Schedule/IMipService.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidReturnStatement

apps/dav/lib/CalDAV/Schedule/IMipService.php:1178:10: InvalidReturnStatement: The inferred type 'Sabre\VObject\Property|null' does not match the declared return type 'Sabre\VObject\Component\VEvent' for OCA\DAV\CalDAV\Schedule\IMipService::getOrganizerVEvent (see https://psalm.dev/128)

Check failure on line 1178 in apps/dav/lib/CalDAV/Schedule/IMipService.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

NullableReturnStatement

apps/dav/lib/CalDAV/Schedule/IMipService.php:1178:10: NullableReturnStatement: The declared return type 'Sabre\VObject\Component\VEvent' for OCA\DAV\CalDAV\Schedule\IMipService::getOrganizerVEvent is not nullable, but the function returns 'Sabre\VObject\Property|null' (see https://psalm.dev/139)
}

public function isRoomOrResource(Property $attendee): bool {
$cuType = $attendee->offsetGet('CUTYPE');
if (!$cuType instanceof Parameter) {
Expand Down
Loading