Skip to content

Commit 954290a

Browse files
authored
Merge pull request #12392 from brad2014/feature/properly-present-buttons-from-imip-mails
Customize presentation of accept/decline buttons in iMip mail
2 parents fdcc654 + 8d8bcea commit 954290a

File tree

2 files changed

+198
-213
lines changed

2 files changed

+198
-213
lines changed

apps/dav/lib/CalDAV/Schedule/IMipPlugin.php

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,42 @@ public function schedule(Message $iTipMessage) {
239239
$meetingAttendeeName, $meetingInviteeName);
240240
$this->addBulletList($template, $l10n, $meetingWhen, $meetingLocation,
241241
$meetingDescription, $meetingUrl);
242-
$this->addResponseButtons($template, $l10n, $iTipMessage, $lastOccurrence);
242+
243+
244+
// Only add response buttons to invitation requests: Fix Issue #11230
245+
if (($method == self::METHOD_REQUEST) && $this->getAttendeeRSVP($attendee)) {
246+
247+
/*
248+
** Only offer invitation accept/reject buttons, which link back to the
249+
** nextcloud server, to recipients who can access the nextcloud server via
250+
** their internet/intranet. Issue #12156
251+
**
252+
** The app setting is stored in the appconfig database table.
253+
**
254+
** For nextcloud servers accessible to the public internet, the default
255+
** "invitation_link_recipients" value "yes" (all recipients) is appropriate.
256+
**
257+
** When the nextcloud server is restricted behind a firewall, accessible
258+
** only via an internal network or via vpn, you can set "dav.invitation_link_recipients"
259+
** to the email address or email domain, or comma separated list of addresses or domains,
260+
** of recipients who can access the server.
261+
**
262+
** To always deliver URLs, set invitation_link_recipients to "yes".
263+
** To suppress URLs entirely, set invitation_link_recipients to boolean "no".
264+
*/
265+
266+
$recipientDomain = substr(strrchr($recipient, "@"), 1);
267+
$invitationLinkRecipients = explode(',', preg_replace('/\s+/', '', strtolower($this->config->getAppValue('dav', 'invitation_link_recipients', 'yes'))));
268+
269+
if (strcmp('yes', $invitationLinkRecipients[0]) === 0
270+
|| in_array(strtolower($recipient), $invitationLinkRecipients)
271+
|| in_array(strtolower($recipientDomain), $invitationLinkRecipients)) {
272+
$this->addResponseButtons($template, $l10n, $iTipMessage, $lastOccurrence);
273+
}
274+
}
243275

244276
$template->addFooter();
277+
245278
$message->useTemplate($template);
246279

247280
$attachment = $this->mailer->createAttachment(
@@ -345,6 +378,21 @@ private function getAttendeeLangOrDefault($default, Property $attendee = null) {
345378
return $default;
346379
}
347380

381+
/**
382+
* @param Property|null $attendee
383+
* @return bool
384+
*/
385+
private function getAttendeeRSVP(Property $attendee = null) {
386+
if ($attendee !== null) {
387+
$rsvp = $attendee->offsetGet('RSVP');
388+
if (($rsvp instanceof Parameter) && (strcasecmp($rsvp->getValue(), 'TRUE') === 0)) {
389+
return true;
390+
}
391+
}
392+
// RFC 5545 3.2.17: default RSVP is false
393+
return false;
394+
}
395+
348396
/**
349397
* @param IL10N $l10n
350398
* @param Property $dtstart
@@ -447,7 +495,6 @@ private function addSubjectAndHeading(IEMailTemplate $template, IL10N $l10n,
447495
$template->setSubject('Invitation: ' . $summary);
448496
$template->addHeading($l10n->t('%1$s invited you to »%2$s«', [$inviteeName, $summary]), $l10n->t('Hello %s,', [$attendeeName]));
449497
}
450-
451498
}
452499

453500
/**
@@ -504,7 +551,7 @@ private function addResponseButtons(IEMailTemplate $template, IL10N $l10n,
504551
$moreOptionsURL, $l10n->t('More options …')
505552
]);
506553
$text = $l10n->t('More options at %s', [$moreOptionsURL]);
507-
554+
508555
$template->addBodyText($html, $text);
509556
}
510557

0 commit comments

Comments
 (0)