E-Mail-Reminder to all attendees is sent only by organizer of the reminder/event
This commit is contained in:
parent
461a975749
commit
010114b887
|
@ -44,9 +44,11 @@ interface INotificationProvider {
|
|||
* @param VEvent $vevent
|
||||
* @param string $calendarDisplayName
|
||||
* @param IUser[] $users
|
||||
* @param IUser $userOfReminder
|
||||
* @return void
|
||||
*/
|
||||
public function send(VEvent $vevent,
|
||||
string $calendarDisplayName,
|
||||
array $users = []): void;
|
||||
array $users = [],
|
||||
IUser $userOfReminder = null): void;
|
||||
}
|
||||
|
|
|
@ -91,11 +91,13 @@ abstract class AbstractProvider implements INotificationProvider {
|
|||
* @param VEvent $vevent
|
||||
* @param string $calendarDisplayName
|
||||
* @param IUser[] $users
|
||||
* @param IUser $userOfReminder
|
||||
* @return void
|
||||
*/
|
||||
abstract public function send(VEvent $vevent,
|
||||
string $calendarDisplayName,
|
||||
array $users = []): void;
|
||||
array $users = [],
|
||||
IUser $userOfReminder = null): void;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
|
|
@ -37,6 +37,7 @@ use OCP\IConfig;
|
|||
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;
|
||||
|
@ -80,15 +81,24 @@ class EmailProvider extends AbstractProvider {
|
|||
* @param VEvent $vevent
|
||||
* @param string $calendarDisplayName
|
||||
* @param array $users
|
||||
* @param IUser $userOfReminder
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function send(VEvent $vevent,
|
||||
string $calendarDisplayName,
|
||||
array $users = []):void {
|
||||
array $users = [],
|
||||
IUser $userOfReminder = null):void {
|
||||
$fallbackLanguage = $this->getFallbackLanguage();
|
||||
|
||||
$emailAddressesOfSharees = $this->getEMailAddressesOfAllUsersWithWriteAccessToCalendar($users);
|
||||
|
||||
$organizer = $this->getOrganizerEMailAndNameFromEvent($vevent);
|
||||
|
||||
$emailAddressesOfAttendees = [];
|
||||
|
||||
if ($userOfReminder && strcasecmp($userOfReminder->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.
|
||||
|
@ -99,7 +109,6 @@ class EmailProvider extends AbstractProvider {
|
|||
);
|
||||
|
||||
$sortedByLanguage = $this->sortEMailAddressesByLanguage($emailAddresses, $fallbackLanguage);
|
||||
$organizer = $this->getOrganizerEMailAndNameFromEvent($vevent);
|
||||
|
||||
foreach ($sortedByLanguage as $lang => $emailAddresses) {
|
||||
if (!$this->hasL10NForLang($lang)) {
|
||||
|
@ -196,7 +205,7 @@ class EmailProvider extends AbstractProvider {
|
|||
}
|
||||
|
||||
$organizer = $vevent->ORGANIZER;
|
||||
if (strcasecmp($organizer->getValue(), 'mailto:') !== 0) {
|
||||
if (!str_starts_with($organizer->getValue(), 'mailto:')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,11 +83,13 @@ class PushProvider extends AbstractProvider {
|
|||
* @param VEvent $vevent
|
||||
* @param string $calendarDisplayName
|
||||
* @param IUser[] $users
|
||||
* @param IUser $userOfReminder
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function send(VEvent $vevent,
|
||||
string $calendarDisplayName = null,
|
||||
array $users = []):void {
|
||||
array $users = [],
|
||||
IUser $userOfReminder = null):void {
|
||||
if ($this->config->getAppValue('dav', 'sendEventRemindersPush', 'no') !== 'yes') {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -142,13 +142,13 @@ class ReminderService {
|
|||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue