diff options
author | Nicolas SIMIDE <2083596+dems54@users.noreply.github.com> | 2021-01-06 02:25:38 +0300 |
---|---|---|
committer | Nicolas SIMIDE <2083596+dems54@users.noreply.github.com> | 2021-01-28 17:57:29 +0300 |
commit | 4ac636d252a3b652902a146ae611e31fb65f2a5f (patch) | |
tree | dc330db96edbb8e052a64dbda4b463c0d46e63e7 /apps/sharebymail/lib | |
parent | 5fa935d6d6c93ccecd91b942d5014c1a4ed463bd (diff) |
ReplyTo option for sharebymail Issue #24139
Signed-off-by: Nicolas SIMIDE <2083596+dems54@users.noreply.github.com>
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..fd351a2db72 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 $replyToInitiator = '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->replyToInitiator); + 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 { |