From 4d0fabe553ecda0b7310d2b52465ade82ad85529 Mon Sep 17 00:00:00 2001 From: duobradovic <153935011+duobradovic@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:36:43 +0200 Subject: [PATCH 1/2] Implement Quarantine response as AbstractManipulation --- src/purepythonmilter/protocol/responses.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/purepythonmilter/protocol/responses.py b/src/purepythonmilter/protocol/responses.py index d8e212f..78d623b 100644 --- a/src/purepythonmilter/protocol/responses.py +++ b/src/purepythonmilter/protocol/responses.py @@ -226,7 +226,7 @@ class DiscardMessage(BaseVerdictNoData): @attrs.define(auto_attribs=False, kw_only=True) -class Quarantine(AbstractVerdict): +class Quarantine(AbstractManipulation): """ Put the message in the hold queue. Only valid at End of Message stage. The reason text is ignored by Postfix at the time of writing. @@ -234,7 +234,10 @@ class Quarantine(AbstractVerdict): """ response_char: ClassVar[bytes] = b"q" # SMFIR_QUARANTINE - reason: str + reason: str = attrs.field() + + def encode(self) -> Payload: + return Payload(self.response_char + self.reason.encode() + b"\x00") @attrs.define(auto_attribs=False, kw_only=True) From adaf02d2facff4552330d04c430013ccbbb6e15b Mon Sep 17 00:00:00 2001 From: duobradovic <153935011+duobradovic@users.noreply.github.com> Date: Sat, 2 Nov 2024 02:14:31 +0100 Subject: [PATCH 2/2] Update api.md --- docs/api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index fa57e37..d996462 100644 --- a/docs/api.md +++ b/docs/api.md @@ -104,7 +104,7 @@ This applies as possible return type of all of the hooks below. in order to use the `RemoveRecipient` manipulation. - `can_quarantine` (default: False) - in order to use the `Quarantine` response in `hook_on_end_of_message`. + in order to use the `Quarantine` manipulation. ## `Command`s @@ -142,6 +142,7 @@ This applies as possible return type of all of the hooks below. - `ChangeHeader` - `ReplaceBodyChunk` - `ChangeMailFrom` + - `Quarantine` - *AbstractResponse* - *AbstractVerdict* - *BaseVerdictNoData* @@ -152,7 +153,6 @@ This applies as possible return type of all of the hooks below. - *BaseReplyWithCode* - `RejectWithCode` - `TempFailWithCode` - - `Quarantine` - *BaseResponseNoData* - `Continue` - `SkipToNextStage`