aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_real.php27
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/Mail/Message.php38
-rw-r--r--lib/public/Mail/Headers/AutoSubmitted.php75
-rw-r--r--lib/public/Mail/IMessage.php10
6 files changed, 135 insertions, 17 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 08a871e8466..5d9a90a3f02 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -479,6 +479,7 @@ return array(
'OCP\\Log\\IWriter' => $baseDir . '/lib/public/Log/IWriter.php',
'OCP\\Log\\RotationTrait' => $baseDir . '/lib/public/Log/RotationTrait.php',
'OCP\\Mail\\Events\\BeforeMessageSent' => $baseDir . '/lib/public/Mail/Events/BeforeMessageSent.php',
+ 'OCP\\Mail\\Headers\\AutoSubmitted' => $baseDir . '/lib/public/Mail/Headers/AutoSubmitted.php',
'OCP\\Mail\\IAttachment' => $baseDir . '/lib/public/Mail/IAttachment.php',
'OCP\\Mail\\IEMailTemplate' => $baseDir . '/lib/public/Mail/IEMailTemplate.php',
'OCP\\Mail\\IMailer' => $baseDir . '/lib/public/Mail/IMailer.php',
diff --git a/lib/composer/composer/autoload_real.php b/lib/composer/composer/autoload_real.php
index 6b98041770d..6dbf91afee6 100644
--- a/lib/composer/composer/autoload_real.php
+++ b/lib/composer/composer/autoload_real.php
@@ -31,25 +31,18 @@ class ComposerAutoloaderInit749170dad3f5e7f9ca158f5a9f04f6a2
$loader->register(true);
- $includeFiles = \Composer\Autoload\ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2::$files;
- foreach ($includeFiles as $fileIdentifier => $file) {
- composerRequire749170dad3f5e7f9ca158f5a9f04f6a2($fileIdentifier, $file);
+ $filesToLoad = \Composer\Autoload\ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2::$files;
+ $requireFile = static function ($fileIdentifier, $file) {
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
+
+ require $file;
+ }
+ };
+ foreach ($filesToLoad as $fileIdentifier => $file) {
+ ($requireFile)($fileIdentifier, $file);
}
return $loader;
}
}
-
-/**
- * @param string $fileIdentifier
- * @param string $file
- * @return void
- */
-function composerRequire749170dad3f5e7f9ca158f5a9f04f6a2($fileIdentifier, $file)
-{
- if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
- $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
-
- require $file;
- }
-}
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index eec226c9a6e..15bcc0f4843 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -512,6 +512,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Log\\IWriter' => __DIR__ . '/../../..' . '/lib/public/Log/IWriter.php',
'OCP\\Log\\RotationTrait' => __DIR__ . '/../../..' . '/lib/public/Log/RotationTrait.php',
'OCP\\Mail\\Events\\BeforeMessageSent' => __DIR__ . '/../../..' . '/lib/public/Mail/Events/BeforeMessageSent.php',
+ 'OCP\\Mail\\Headers\\AutoSubmitted' => __DIR__ . '/../../..' . '/lib/public/Mail/Headers/AutoSubmitted.php',
'OCP\\Mail\\IAttachment' => __DIR__ . '/../../..' . '/lib/public/Mail/IAttachment.php',
'OCP\\Mail\\IEMailTemplate' => __DIR__ . '/../../..' . '/lib/public/Mail/IEMailTemplate.php',
'OCP\\Mail\\IMailer' => __DIR__ . '/../../..' . '/lib/public/Mail/IMailer.php',
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index 8b94f44ddba..3313b39e2e2 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -31,6 +31,7 @@ declare(strict_types=1);
*/
namespace OC\Mail;
+use OCP\Mail\Headers\AutoSubmitted;
use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMessage;
@@ -301,4 +302,41 @@ class Message implements IMessage {
}
return $this;
}
+
+ /**
+ * Add the Auto-Submitted header to the email, preventing most automated
+ * responses to automated messages.
+ *
+ * @param AutoSubmitted::VALUE_* $value (one of AutoSubmitted::VALUE_NO, AutoSubmitted::VALUE_AUTO_GENERATED, AutoSubmitted::VALUE_AUTO_REPLIED)
+ * @return $this
+ */
+ public function setAutoSubmitted(string $value): IMessage {
+ $headers = $this->swiftMessage->getHeaders();
+
+ if ($headers->has(AutoSubmitted::HEADER)) {
+ // if the header already exsists, remove it.
+ // the value can be modified with some implementations
+ // of the interface \Swift_Mime_Header, however the
+ // interface doesn't, and this makes the static-code
+ // analysis unhappy.
+ $headers->remove(AutoSubmitted::HEADER);
+ }
+
+ $headers->addTextHeader(AutoSubmitted::HEADER, $value);
+
+ return $this;
+ }
+
+ /**
+ * Get the current value of the Auto-Submitted header. Defaults to "no"
+ * which is equivalent to the header not existing at all
+ *
+ * @return string
+ */
+ public function getAutoSubmitted(): string {
+ $headers = $this->swiftMessage->getHeaders();
+
+ return $headers->has(AutoSubmitted::HEADER) ?
+ $headers->get(AutoSubmitted::HEADER)->toString() : AutoSubmitted::VALUE_NO;
+ }
}
diff --git a/lib/public/Mail/Headers/AutoSubmitted.php b/lib/public/Mail/Headers/AutoSubmitted.php
new file mode 100644
index 00000000000..21df18dd918
--- /dev/null
+++ b/lib/public/Mail/Headers/AutoSubmitted.php
@@ -0,0 +1,75 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2022 Bennet Becker <dev@bennet.cc>
+ *
+ * @author Bennet Becker <dev@bennet.cc>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCP\Mail\Headers;
+
+/**
+ * Keyword values for the Auto-Submitted email header, as per RFC 3834.
+ *
+ * The value "auto-notified" as per RFC 5436 is deliberately omitted as it is
+ * meant of notification of the sieve system.
+ *
+ * @link https://www.iana.org/assignments/auto-submitted-keywords/auto-submitted-keywords.xhtml
+ *
+ * @since 26.0.0
+ */
+final class AutoSubmitted {
+
+ /**
+ * Name of the Header as used in the final message later
+ *
+ * @var string
+ * @since 26.0.0
+ */
+ public const HEADER = 'Auto-Submitted';
+
+ /**
+ * Indicates that a message was NOT automatically generated, but was
+ * created by a human (or following human interaction). It is the equivalent
+ * to the absence of an Auto-Submitted header altogether.
+ *
+ * @var string
+ * @since 26.0.0
+ */
+ public const VALUE_NO = 'no';
+
+ /**
+ * Indicates that a message was generated by an automatic process, and is
+ * not a direct response to another message
+ *
+ * @var string
+ * @since 26.0.0
+ */
+ public const VALUE_AUTO_GENERATED = 'auto-generated';
+
+ /**
+ * Indicates that a message was automatically generated as a direct response
+ * to another message.
+ *
+ * @var string
+ * @since 26.0.0
+ */
+ public const VALUE_AUTO_REPLIED = 'auto-replied';
+}
diff --git a/lib/public/Mail/IMessage.php b/lib/public/Mail/IMessage.php
index 1549f61c1fe..994d32603e9 100644
--- a/lib/public/Mail/IMessage.php
+++ b/lib/public/Mail/IMessage.php
@@ -93,4 +93,14 @@ interface IMessage {
* @since 13.0.0
*/
public function useTemplate(IEMailTemplate $emailTemplate): IMessage;
+
+ /**
+ * Add the Auto-Submitted header to the email, preventing most automated
+ * responses to automated messages.
+ *
+ * @param Headers\AutoSubmitted::VALUE_* $value (one of AutoSubmitted::VALUE_NO, AutoSubmitted::VALUE_AUTO_GENERATED, AutoSubmitted::VALUE_AUTO_REPLIED)
+ * @return IMessage
+ * @since 26.0.0
+ */
+ public function setAutoSubmitted(string $value): IMessage;
}