diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2021-02-19 08:20:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 08:20:58 +0100 |
commit | 946430862e63a2b1fdbb49ced4942b1534292606 (patch) | |
tree | 9cfa117927736fffe5f736306ce76b8ba185cc8c /apps/sharebymail/lib | |
parent | c222bac9ed07fb6d4cd1a233e8b39645515579e3 (diff) | |
parent | 69bf0c8a9e5eb66d2509e019631465f1db0a2a9a (diff) | |
download | nextcloud-server-946430862e63a2b1fdbb49ced4942b1534292606.tar.gz nextcloud-server-946430862e63a2b1fdbb49ced4942b1534292606.zip |
Merge pull request #24978 from dems54/issue24139
Diffstat (limited to 'apps/sharebymail/lib')
-rw-r--r-- | apps/sharebymail/lib/Settings/Admin.php | 3 | ||||
-rw-r--r-- | apps/sharebymail/lib/Settings/SettingsManager.php | 12 | ||||
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 57 |
3 files changed, 47 insertions, 25 deletions
diff --git a/apps/sharebymail/lib/Settings/Admin.php b/apps/sharebymail/lib/Settings/Admin.php index 23881212692..bc766d59af6 100644 --- a/apps/sharebymail/lib/Settings/Admin.php +++ b/apps/sharebymail/lib/Settings/Admin.php @@ -41,7 +41,8 @@ class Admin implements ISettings { public function getForm() { $parameters = [ 'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(), - 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection() + 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection(), + 'replyToInitiator' => $this->settingsManager->replyToInitiator() ]; return new TemplateResponse('sharebymail', 'settings-admin', $parameters, ''); diff --git a/apps/sharebymail/lib/Settings/SettingsManager.php b/apps/sharebymail/lib/Settings/SettingsManager.php index e7937e4c60f..6a3183b23bd 100644 --- a/apps/sharebymail/lib/Settings/SettingsManager.php +++ b/apps/sharebymail/lib/Settings/SettingsManager.php @@ -38,6 +38,8 @@ class SettingsManager { private $enforcePasswordProtectionDefault = 'no'; + private $replyToInitiatorDefault = 'yes'; + public function __construct(IConfig $config) { $this->config = $config; } @@ -61,4 +63,14 @@ class SettingsManager { $enforcePassword = $this->config->getAppValue('sharebymail', 'enforcePasswordProtection', $this->enforcePasswordProtectionDefault); return $enforcePassword === 'yes'; } + + /** + * should add reply to with initiator mail + * + * @return bool + */ + public function replyToInitiator(): bool { + $replyToInitiator = $this->config->getAppValue('sharebymail', 'replyToInitiator', $this->replyToInitiatorDefault); + return $replyToInitiator === 'yes'; + } } diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 5977cbd18bb..6f2b5de437f 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -399,19 +399,22 @@ class ShareByMailProvider implements IShareProvider { // The "From" contains the sharers name $instanceName = $this->defaults->getName(); - $senderName = $this->l->t( - '%1$s via %2$s', - [ - $initiatorDisplayName, - $instanceName - ] - ); + $senderName = $instanceName; + if ($this->settingsManager->replyToInitiator()) { + $senderName = $this->l->t( + '%1$s via %2$s', + [ + $initiatorDisplayName, + $instanceName + ] + ); + } $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]); // The "Reply-To" is set to the sharer if an mail address is configured // also the default footer contains a "Do not reply" which needs to be adjusted. $initiatorEmail = $initiatorUser->getEMailAddress(); - if ($initiatorEmail !== null) { + if ($this->settingsManager->replyToInitiator() && $initiatorEmail !== null) { $message->setReplyTo([$initiatorEmail => $initiatorDisplayName]); $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')); } else { @@ -464,15 +467,18 @@ class ShareByMailProvider implements IShareProvider { // The "From" contains the sharers name $instanceName = $this->defaults->getName(); - $senderName = $this->l->t( - '%1$s via %2$s', - [ - $initiatorDisplayName, - $instanceName - ] - ); + $senderName = $instanceName; + if ($this->settingsManager->replyToInitiator()) { + $senderName = $this->l->t( + '%1$s via %2$s', + [ + $initiatorDisplayName, + $instanceName + ] + ); + } $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]); - if ($initiatorEmailAddress !== null) { + if ($this->settingsManager->replyToInitiator() && $initiatorEmailAddress !== null) { $message->setReplyTo([$initiatorEmailAddress => $initiatorDisplayName]); $emailTemplate->addFooter($instanceName . ' - ' . $this->defaults->getSlogan()); } else { @@ -521,15 +527,18 @@ class ShareByMailProvider implements IShareProvider { // The "From" contains the sharers name $instanceName = $this->defaults->getName(); - $senderName = $this->l->t( - '%1$s via %2$s', - [ - $initiatorDisplayName, - $instanceName - ] - ); + $senderName = $instanceName; + if ($this->settingsManager->replyToInitiator()) { + $senderName = $this->l->t( + '%1$s via %2$s', + [ + $initiatorDisplayName, + $instanceName + ] + ); + } $message->setFrom([\OCP\Util::getDefaultEmailAddress($instanceName) => $senderName]); - if ($initiatorEmailAddress !== null) { + if ($this->settingsManager->replyToInitiator() && $initiatorEmailAddress !== null) { $message->setReplyTo([$initiatorEmailAddress => $initiatorDisplayName]); $emailTemplate->addFooter($instanceName . ' - ' . $this->defaults->getSlogan()); } else { |