aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBennet Becker <dev@bennet.cc>2023-01-03 15:03:40 +0100
committerBennet Becker <dev@bennet.cc>2023-01-03 15:15:35 +0100
commit4dc09571648634d23880cc04f958d4ff3d1ace68 (patch)
tree20ae8cc213280faefc6e1b1cb85ef703d7b8b7cd /lib
parent9d9a0b7e06f1a6879658d227a5f8bb4dfbdf056a (diff)
downloadnextcloud-server-4dc09571648634d23880cc04f958d4ff3d1ace68.tar.gz
nextcloud-server-4dc09571648634d23880cc04f958d4ff3d1ace68.zip
refactor AutoSubmittedValue to Headers\AutoSubmitted and adding
header name to constants Signed-off-by: Bennet Becker <dev@bennet.cc>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Mail/Message.php14
-rw-r--r--lib/public/Mail/Headers/AutoSubmitted.php (renamed from lib/public/Mail/AutoSubmittedValue.php)19
-rw-r--r--lib/public/Mail/IMessage.php2
3 files changed, 22 insertions, 13 deletions
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index cf69d9cb3ef..3313b39e2e2 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -31,7 +31,7 @@ declare(strict_types=1);
*/
namespace OC\Mail;
-use OCP\Mail\AutoSubmittedValue;
+use OCP\Mail\Headers\AutoSubmitted;
use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMessage;
@@ -307,22 +307,22 @@ class Message implements IMessage {
* Add the Auto-Submitted header to the email, preventing most automated
* responses to automated messages.
*
- * @param AutoSubmittedValue::* $value (one of AutoSubmittedValue::NO, AutoSubmittedValue::AUTO_GENERATED, AutoSubmittedValue::AUTO_REPLIED)
+ * @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('Auto-Submitted')) {
+ 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('Auto-Submitted');
+ $headers->remove(AutoSubmitted::HEADER);
}
- $headers->addTextHeader('Auto-Submitted', $value);
+ $headers->addTextHeader(AutoSubmitted::HEADER, $value);
return $this;
}
@@ -336,7 +336,7 @@ class Message implements IMessage {
public function getAutoSubmitted(): string {
$headers = $this->swiftMessage->getHeaders();
- return $headers->has('Auto-Submitted') ?
- $headers->get('Auto-Submitted')->toString() : AutoSubmittedValue::NO;
+ return $headers->has(AutoSubmitted::HEADER) ?
+ $headers->get(AutoSubmitted::HEADER)->toString() : AutoSubmitted::VALUE_NO;
}
}
diff --git a/lib/public/Mail/AutoSubmittedValue.php b/lib/public/Mail/Headers/AutoSubmitted.php
index 3cf669d00f7..73bd35e129e 100644
--- a/lib/public/Mail/AutoSubmittedValue.php
+++ b/lib/public/Mail/Headers/AutoSubmitted.php
@@ -23,7 +23,7 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-namespace OCP\Mail;
+namespace OCP\Mail\Headers;
/**
* Keyword values for the Auto-Submitted email header, as per RFC 3834.
@@ -35,7 +35,16 @@ namespace OCP\Mail;
*
* @since 26.0.0
*/
-final class AutoSubmittedValue {
+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
@@ -44,7 +53,7 @@ final class AutoSubmittedValue {
* @var string
* @since 26.0.0
*/
- public const NO = 'no';
+ public const VALUE_NO = 'no';
/**
* Indicates that a message was generated by an automatic process, and is
@@ -53,7 +62,7 @@ final class AutoSubmittedValue {
* @var string
* @since 26.0.0
*/
- public const AUTO_GENERATED = 'auto-generated';
+ public const VALUE_AUTO_GENERATED = 'auto-generated';
/**
* Indicates that a message was automatically generated as a direct response
@@ -62,5 +71,5 @@ final class AutoSubmittedValue {
* @var string
* @since 26.0.0
*/
- public const AUTO_REPLIED = 'auto-replied';
+ public const VALUE_AUTO_REPLIED = 'auto-replied';
}
diff --git a/lib/public/Mail/IMessage.php b/lib/public/Mail/IMessage.php
index 352c47022fd..c53ab12bbb7 100644
--- a/lib/public/Mail/IMessage.php
+++ b/lib/public/Mail/IMessage.php
@@ -98,7 +98,7 @@ interface IMessage {
* Add the Auto-Submitted header to the email, preventing most automated
* responses to automated messages.
*
- * @param AutoSubmittedValue::* $value (one of AutoSubmittedValue::NO, AutoSubmittedValue::AUTO_GENERATED, AutoSubmittedValue::AUTO_REPLIED)
+ * @param AutoSubmitted::VALUE_* $value (one of AutoSubmitted::VALUE_NO, AutoSubmitted::VALUE_AUTO_GENERATED, AutoSubmitted::VALUE_AUTO_REPLIED)
* @return IMessage
* @since 26.0.0
*/