Skip to content

Commit 8d8bcea

Browse files
committed
Move dav.invitation_link_recipients from getSystemValue to getAppValue
Per @georgehrke change request for PR #12392, instead of setting dav.invitation_link_recipients in the system config.php file, we set it in the database table oc_appconfig. Furthermore, the value of the config variable is always a string: 'yes' to include links in imip mail, 'no' to exclude them, or a comma-separated list of email addresses and/or domains for which they should be included. If not specified in oc_appconfig, the default is 'yes'. Signed-off-by: brad2014 <[email protected]>
1 parent 1a29239 commit 8d8bcea

File tree

3 files changed

+26
-55
lines changed

3 files changed

+26
-55
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,28 +249,26 @@ public function schedule(Message $iTipMessage) {
249249
** nextcloud server, to recipients who can access the nextcloud server via
250250
** their internet/intranet. Issue #12156
251251
**
252+
** The app setting is stored in the appconfig database table.
253+
**
252254
** For nextcloud servers accessible to the public internet, the default
253-
** "dav.invitation_link_recipients" value "true" (all recipients) is appropriate.
255+
** "invitation_link_recipients" value "yes" (all recipients) is appropriate.
254256
**
255257
** When the nextcloud server is restricted behind a firewall, accessible
256258
** only via an internal network or via vpn, you can set "dav.invitation_link_recipients"
257-
** to the email address or email domain, or array of addresses or domains,
259+
** to the email address or email domain, or comma separated list of addresses or domains,
258260
** of recipients who can access the server.
259261
**
260-
** To deliver URL's always, set invitation_link_recipients to boolean "true".
261-
** To suppress URL's entirely, set invitation_link_recipients to boolean "false".
262+
** To always deliver URLs, set invitation_link_recipients to "yes".
263+
** To suppress URLs entirely, set invitation_link_recipients to boolean "no".
262264
*/
263265

264266
$recipientDomain = substr(strrchr($recipient, "@"), 1);
265-
$invitationLinkRecipients = $this->config->getSystemValue('dav.invitation_link_recipients', true);
266-
if (is_array($invitationLinkRecipients)) {
267-
$invitationLinkRecipients = array_map('strtolower', $invitationLinkRecipients); // for case insensitive in_array
268-
}
269-
if ($invitationLinkRecipients === true
270-
|| (is_string($invitationLinkRecipients) && strcasecmp($recipient, $invitationLinkRecipients) === 0)
271-
|| (is_string($invitationLinkRecipients) && strcasecmp($recipientDomain, $invitationLinkRecipients) === 0)
272-
|| (is_array($invitationLinkRecipients) && in_array(strtolower($recipient), $invitationLinkRecipients))
273-
|| (is_array($invitationLinkRecipients) && in_array(strtolower($recipientDomain), $invitationLinkRecipients))) {
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)) {
274272
$this->addResponseButtons($template, $l10n, $iTipMessage, $lastOccurrence);
275273
}
276274
}

apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public function setUp() {
9696

9797
public function testDelivery() {
9898
$this->config
99-
->method('getSystemValue')
100-
->with('dav.invitation_link_recipients', true)
101-
->willReturn(true);
99+
->method('getAppValue')
100+
->with('dav', 'invitation_link_recipients', 'yes')
101+
->willReturn('yes');
102102

103103
$message = $this->_testMessage();
104104
$this->_expectSend();
@@ -108,9 +108,9 @@ public function testDelivery() {
108108

109109
public function testFailedDelivery() {
110110
$this->config
111-
->method('getSystemValue')
112-
->with('dav.invitation_link_recipients', true)
113-
->willReturn(true);
111+
->method('getAppValue')
112+
->with('dav', 'invitation_link_recipients', 'yes')
113+
->willReturn('yes');
114114

115115
$message = $this->_testMessage();
116116
$this->mailer
@@ -127,9 +127,9 @@ public function testFailedDelivery() {
127127
public function testNoMessageSendForPastEvents($veventParams, $expectsMail) {
128128

129129
$this->config
130-
->method('getSystemValue')
131-
->with('dav.invitation_link_recipients', true)
132-
->willReturn(true);
130+
->method('getAppValue')
131+
->with('dav', 'invitation_link_recipients', 'yes')
132+
->willReturn('yes');
133133

134134
$message = $this->_testMessage( $veventParams );
135135

@@ -167,8 +167,8 @@ public function testIncludeResponseButtons( $config_setting, $recipient, $has_bu
167167

168168
$this->_expectSend($recipient, true, $has_buttons);
169169
$this->config
170-
->method('getSystemValue')
171-
->with('dav.invitation_link_recipients', true)
170+
->method('getAppValue')
171+
->with('dav', 'invitation_link_recipients', 'yes')
172172
->willReturn($config_setting);
173173

174174
$this->plugin->schedule($message);
@@ -178,13 +178,13 @@ public function testIncludeResponseButtons( $config_setting, $recipient, $has_bu
178178
public function dataIncludeResponseButtons() {
179179
return [
180180
// dav.invitation_link_recipients, recipient, $has_buttons
181-
[ true, '[email protected]', true],
181+
[ 'yes', '[email protected]', true],
182182
183183
[ 'internal.com', '[email protected]', true],
184-
[ ['[email protected]', 'internal.com'], '[email protected]', true],
185-
[ false, '[email protected]', false],
184+
[ '[email protected],internal.com', '[email protected]', true],
185+
[ 'no', '[email protected]', false],
186186
[ 'internal.com', '[email protected]', false],
187-
[ ['[email protected]', 'internal.com'], '[email protected]', false],
187+
[ '[email protected],internal.com', '[email protected]', false],
188188
];
189189
}
190190

config/config.sample.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,33 +1696,6 @@
16961696
'/^Microsoft-WebDAV-MiniRedir/', // Windows webdav drive
16971697
),
16981698

1699-
/**
1700-
* The caldav server sends invitation emails to invitees, attaching the ICS
1701-
* file for the invitation. It also may include, in the body of the e-mail,
1702-
* invitation accept/reject web links referencing URL's that point to the nextcloud server.
1703-
*
1704-
* Although any recipient can read and reply to the ICS file via the iMip protocol,
1705-
* we must only present the web links to recipients who can access the nextcloud
1706-
* web server via their internet/intranet.
1707-
*
1708-
* When your nextcloud server is restricted behind a firewall, accessible
1709-
* only via an internal network or via vpn, you can set "dav.invitation_link_recipients"
1710-
* to the email address or email domain, or array of addresses or domains,
1711-
* of recipients who can access the server. Only those recipients will get web links. External
1712-
* users can accept/reject invitations by emailing back ICS files containing appropriate
1713-
* messages, using the iMip protocol. Many mail clients support this functionality.
1714-
*
1715-
* To suppress iMip web links entirely, set dav.invitation_link_recipients to false.
1716-
* To deliver iMip web links always, set dav.invitation_link_recipients to true.
1717-
*
1718-
* Examples:
1719-
* 'dav.invitation_link_recipients' => 'internal.example.com',
1720-
* 'dav.invitation_link_recipients' => array( 'internal.example.com', '[email protected]' ),
1721-
* 'dav.invitation_link_recipients' => false,
1722-
*
1723-
*/
1724-
'dav.invitation_link_recipients' => true, // always include accept/reject server links in iMip emails
1725-
17261699
/**
17271700
* By default there is on public pages a link shown that allows users to
17281701
* learn about the "simple sign up" - see https://nextcloud.com/signup/

0 commit comments

Comments
 (0)