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

E-Mail-Reminder to all attendees is sent only by organizer #26496

Closed
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
4 changes: 3 additions & 1 deletion apps/dav/lib/CalDAV/Reminder/INotificationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ interface INotificationProvider {
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param IUser[] $users
* @param IUser $reminderOwner
* @return void
*/
public function send(VEvent $vevent,
string $calendarDisplayName,
array $users = []): void;
array $users = [],
IUser $reminderOwner = null): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ public function __construct(ILogger $logger,
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param IUser[] $users
* @param IUser $reminderOwner
* @return void
*/
abstract public function send(VEvent $vevent,
string $calendarDisplayName,
array $users = []): void;
array $users = [],
IUser $reminderOwner = null): void;

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OCP\IL10N;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\L10N\IFactory as L10NFactory;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
Expand Down Expand Up @@ -80,15 +81,24 @@ public function __construct(IConfig $config,
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param array $users
* @param IUser $reminderOwner
* @throws \Exception
*/
public function send(VEvent $vevent,
string $calendarDisplayName,
array $users = []):void {
array $users = [],
IUser $reminderOwner = null):void {
$fallbackLanguage = $this->getFallbackLanguage();

$emailAddressesOfSharees = $this->getEMailAddressesOfAllUsersWithWriteAccessToCalendar($users);
$emailAddressesOfAttendees = $this->getAllEMailAddressesFromEvent($vevent);

$organizer = $this->getOrganizerEMailAndNameFromEvent($vevent);

$emailAddressesOfAttendees = [];

if ($organizer !== null && $reminderOwner instanceof IUser && strcasecmp($reminderOwner->getEMailAddress(), key($organizer)) === 0) {
$emailAddressesOfAttendees = $this->getAllEMailAddressesFromEvent($vevent);
}

// Quote from php.net:
// If the input arrays have the same string keys, then the later value for that key will overwrite the previous one.
Expand All @@ -99,7 +109,6 @@ public function send(VEvent $vevent,
);

$sortedByLanguage = $this->sortEMailAddressesByLanguage($emailAddresses, $fallbackLanguage);
$organizer = $this->getOrganizerEMailAndNameFromEvent($vevent);

foreach ($sortedByLanguage as $lang => $emailAddresses) {
if (!$this->hasL10NForLang($lang)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ public function __construct(IConfig $config,
* @param VEvent $vevent
* @param string $calendarDisplayName
* @param IUser[] $users
* @param IUser $reminderOwner
* @throws \Exception
*/
public function send(VEvent $vevent,
string $calendarDisplayName = null,
array $users = []):void {
array $users = [],
IUser $reminderOwner = null):void {
if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ public function processReminders():void {
}

$users = $this->getAllUsersWithWriteAccessToCalendar($reminder['calendar_id']);
$user = $this->getUserFromPrincipalURI($reminder['principaluri']);
if ($user) {
$users[] = $user;
$userOfReminder = $this->getUserFromPrincipalURI($reminder['principaluri']);
if ($userOfReminder) {
$users[] = $userOfReminder;
}

$notificationProvider = $this->notificationProviderManager->getProvider($reminder['type']);
$notificationProvider->send($vevent, $reminder['displayname'], $users);
$notificationProvider->send($vevent, $reminder['displayname'], $users, $userOfReminder);

$this->deleteOrProcessNext($reminder, $vevent);
}
Expand Down