prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [Bug] cannot save Mail Rule with "mail and attachment as seperate documents" in 1.11.1
        Maybe it's just me, but I cannot save Mail Rule with "mail and attachment as seperate documents".
  
  _Originally posted by @Limerick-gh in https://github.com/paperless-ngx/paperless-ngx/discussions/2265#discussioncomment-4557234_
      
  [Bug] Missing consumption scope options in frontend
  ### Discussed in https://github.com/paperless-ngx/paperless-ngx/discussions/2265
  
  <div type='discussions-op-text'>
  
  <sup>Originally posted by **morremeyer** December 30, 2022</sup>
  With #2000, frontend configuration for mail consumption was added.
  With #848, at about the same time, email body & .eml file consumption was added.
  
  #848 added the **consumption scope** for email consumption (see https://github.com/p-h-a-i-l/paperless-ngx/blob/0fda35723d62275a5beb783cbf9061d4d4a15703/src/paperless_mail/models.py#L59-L65) to decide between consuming:
  
  * only the attachments
  * the full email as .eml
  * the full email as .eml **and** the attachments
  
  The **consumption scope** is not yet configurable on the frontend. I'd be really happy if it were configurable in the frontend in a future version.
  
  I'm pretty sure someone already has that planned, but I couldn't find an issue or discussion for it, so I'm opening this one to track this request.</div>
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/paperless_mail/serialisers.py`
  Content:
  ```
  1 from documents.serialisers import CorrespondentField
  2 from documents.serialisers import DocumentTypeField
  3 from documents.serialisers import TagsField
  4 from paperless_mail.models import MailAccount
  5 from paperless_mail.models import MailRule
  6 from rest_framework import serializers
  7 
  8 
  9 class ObfuscatedPasswordField(serializers.Field):
  10     """
  11     Sends *** string instead of password in the clear
  12     """
  13 
  14     def to_representation(self, value):
  15         return "*" * len(value)
  16 
  17     def to_internal_value(self, data):
  18         return data
  19 
  20 
  21 class MailAccountSerializer(serializers.ModelSerializer):
  22     password = ObfuscatedPasswordField()
  23 
  24     class Meta:
  25         model = MailAccount
  26         depth = 1
  27         fields = [
  28             "id",
  29             "name",
  30             "imap_server",
  31             "imap_port",
  32             "imap_security",
  33             "username",
  34             "password",
  35             "character_set",
  36         ]
  37 
  38     def update(self, instance, validated_data):
  39         if "password" in validated_data:
  40             if len(validated_data.get("password").replace("*", "")) == 0:
  41                 validated_data.pop("password")
  42         super().update(instance, validated_data)
  43         return instance
  44 
  45     def create(self, validated_data):
  46         mail_account = MailAccount.objects.create(**validated_data)
  47         return mail_account
  48 
  49 
  50 class AccountField(serializers.PrimaryKeyRelatedField):
  51     def get_queryset(self):
  52         return MailAccount.objects.all().order_by("-id")
  53 
  54 
  55 class MailRuleSerializer(serializers.ModelSerializer):
  56     account = AccountField(required=True)
  57     action_parameter = serializers.CharField(
  58         allow_null=True,
  59         required=False,
  60         default="",
  61     )
  62     assign_correspondent = CorrespondentField(allow_null=True, required=False)
  63     assign_tags = TagsField(many=True, allow_null=True, required=False)
  64     assign_document_type = DocumentTypeField(allow_null=True, required=False)
  65     order = serializers.IntegerField(required=False)
  66 
  67     class Meta:
  68         model = MailRule
  69         depth = 1
  70         fields = [
  71             "id",
  72             "name",
  73             "account",
  74             "folder",
  75             "filter_from",
  76             "filter_subject",
  77             "filter_body",
  78             "filter_attachment_filename",
  79             "maximum_age",
  80             "action",
  81             "action_parameter",
  82             "assign_title_from",
  83             "assign_tags",
  84             "assign_correspondent_from",
  85             "assign_correspondent",
  86             "assign_document_type",
  87             "order",
  88             "attachment_type",
  89         ]
  90 
  91     def update(self, instance, validated_data):
  92         super().update(instance, validated_data)
  93         return instance
  94 
  95     def create(self, validated_data):
  96         if "assign_tags" in validated_data:
  97             assign_tags = validated_data.pop("assign_tags")
  98         mail_rule = MailRule.objects.create(**validated_data)
  99         if assign_tags:
  100             mail_rule.assign_tags.set(assign_tags)
  101         return mail_rule
  102 
  103     def validate(self, attrs):
  104         if (
  105             attrs["action"] == MailRule.MailAction.TAG
  106             or attrs["action"] == MailRule.MailAction.MOVE
  107         ) and attrs["action_parameter"] is None:
  108             raise serializers.ValidationError("An action parameter is required.")
  109 
  110         return attrs
  111
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/paperless_mail/serialisers.py b/src/paperless_mail/serialisers.py
  --- a/src/paperless_mail/serialisers.py
  +++ b/src/paperless_mail/serialisers.py
  @@ -86,6 +86,7 @@
               "assign_document_type",
               "order",
               "attachment_type",
  +            "consumption_scope",
           ]
   
       def update(self, instance, validated_data):
  
verification_info: {"golden_diff": "diff --git a/src/paperless_mail/serialisers.py b/src/paperless_mail/serialisers.py\n--- a/src/paperless_mail/serialisers.py\n+++ b/src/paperless_mail/serialisers.py\n@@ -86,6 +86,7 @@\n             \"assign_document_type\",\n             \"order\",\n             \"attachment_type\",\n+            \"consumption_scope\",\n         ]\n \n     def update(self, instance, validated_data):\n", "issue": "[Bug] cannot save Mail Rule with \"mail and attachment as seperate documents\" in 1.11.1\n      Maybe it's just me, but I cannot save Mail Rule with \"mail and attachment as seperate documents\".\n\n_Originally posted by @Limerick-gh in https://github.com/paperless-ngx/paperless-ngx/discussions/2265#discussioncomment-4557234_\n    \n[Bug] Missing consumption scope options in frontend\n### Discussed in https://github.com/paperless-ngx/paperless-ngx/discussions/2265\r\n\r\n<div type='discussions-op-text'>\r\n\r\n<sup>Originally posted by **morremeyer** December 30, 2022</sup>\r\nWith #2000, frontend configuration for mail consumption was added.\r\nWith #848, at about the same time, email body & .eml file consumption was added.\r\n\r\n#848 added the **consumption scope** for email consumption (see https://github.com/p-h-a-i-l/paperless-ngx/blob/0fda35723d62275a5beb783cbf9061d4d4a15703/src/paperless_mail/models.py#L59-L65) to decide between consuming:\r\n\r\n* only the attachments\r\n* the full email as .eml\r\n* the full email as .eml **and** the attachments\r\n\r\nThe **consumption scope** is not yet configurable on the frontend. I'd be really happy if it were configurable in the frontend in a future version.\r\n\r\nI'm pretty sure someone already has that planned, but I couldn't find an issue or discussion for it, so I'm opening this one to track this request.</div>\n", "before_files": [{"content": "from documents.serialisers import CorrespondentField\nfrom documents.serialisers import DocumentTypeField\nfrom documents.serialisers import TagsField\nfrom paperless_mail.models import MailAccount\nfrom paperless_mail.models import MailRule\nfrom rest_framework import serializers\n\n\nclass ObfuscatedPasswordField(serializers.Field):\n    \"\"\"\n    Sends *** string instead of password in the clear\n    \"\"\"\n\n    def to_representation(self, value):\n        return \"*\" * len(value)\n\n    def to_internal_value(self, data):\n        return data\n\n\nclass MailAccountSerializer(serializers.ModelSerializer):\n    password = ObfuscatedPasswordField()\n\n    class Meta:\n        model = MailAccount\n        depth = 1\n        fields = [\n            \"id\",\n            \"name\",\n            \"imap_server\",\n            \"imap_port\",\n            \"imap_security\",\n            \"username\",\n            \"password\",\n            \"character_set\",\n        ]\n\n    def update(self, instance, validated_data):\n        if \"password\" in validated_data:\n            if len(validated_data.get(\"password\").replace(\"*\", \"\")) == 0:\n                validated_data.pop(\"password\")\n        super().update(instance, validated_data)\n        return instance\n\n    def create(self, validated_data):\n        mail_account = MailAccount.objects.create(**validated_data)\n        return mail_account\n\n\nclass AccountField(serializers.PrimaryKeyRelatedField):\n    def get_queryset(self):\n        return MailAccount.objects.all().order_by(\"-id\")\n\n\nclass MailRuleSerializer(serializers.ModelSerializer):\n    account = AccountField(required=True)\n    action_parameter = serializers.CharField(\n        allow_null=True,\n        required=False,\n        default=\"\",\n    )\n    assign_correspondent = CorrespondentField(allow_null=True, required=False)\n    assign_tags = TagsField(many=True, allow_null=True, required=False)\n    assign_document_type = DocumentTypeField(allow_null=True, required=False)\n    order = serializers.IntegerField(required=False)\n\n    class Meta:\n        model = MailRule\n        depth = 1\n        fields = [\n            \"id\",\n            \"name\",\n            \"account\",\n            \"folder\",\n            \"filter_from\",\n            \"filter_subject\",\n            \"filter_body\",\n            \"filter_attachment_filename\",\n            \"maximum_age\",\n            \"action\",\n            \"action_parameter\",\n            \"assign_title_from\",\n            \"assign_tags\",\n            \"assign_correspondent_from\",\n            \"assign_correspondent\",\n            \"assign_document_type\",\n            \"order\",\n            \"attachment_type\",\n        ]\n\n    def update(self, instance, validated_data):\n        super().update(instance, validated_data)\n        return instance\n\n    def create(self, validated_data):\n        if \"assign_tags\" in validated_data:\n            assign_tags = validated_data.pop(\"assign_tags\")\n        mail_rule = MailRule.objects.create(**validated_data)\n        if assign_tags:\n            mail_rule.assign_tags.set(assign_tags)\n        return mail_rule\n\n    def validate(self, attrs):\n        if (\n            attrs[\"action\"] == MailRule.MailAction.TAG\n            or attrs[\"action\"] == MailRule.MailAction.MOVE\n        ) and attrs[\"action_parameter\"] is None:\n            raise serializers.ValidationError(\"An action parameter is required.\")\n\n        return attrs\n", "path": "src/paperless_mail/serialisers.py"}], "after_files": [{"content": "from documents.serialisers import CorrespondentField\nfrom documents.serialisers import DocumentTypeField\nfrom documents.serialisers import TagsField\nfrom paperless_mail.models import MailAccount\nfrom paperless_mail.models import MailRule\nfrom rest_framework import serializers\n\n\nclass ObfuscatedPasswordField(serializers.Field):\n    \"\"\"\n    Sends *** string instead of password in the clear\n    \"\"\"\n\n    def to_representation(self, value):\n        return \"*\" * len(value)\n\n    def to_internal_value(self, data):\n        return data\n\n\nclass MailAccountSerializer(serializers.ModelSerializer):\n    password = ObfuscatedPasswordField()\n\n    class Meta:\n        model = MailAccount\n        depth = 1\n        fields = [\n            \"id\",\n            \"name\",\n            \"imap_server\",\n            \"imap_port\",\n            \"imap_security\",\n            \"username\",\n            \"password\",\n            \"character_set\",\n        ]\n\n    def update(self, instance, validated_data):\n        if \"password\" in validated_data:\n            if len(validated_data.get(\"password\").replace(\"*\", \"\")) == 0:\n                validated_data.pop(\"password\")\n        super().update(instance, validated_data)\n        return instance\n\n    def create(self, validated_data):\n        mail_account = MailAccount.objects.create(**validated_data)\n        return mail_account\n\n\nclass AccountField(serializers.PrimaryKeyRelatedField):\n    def get_queryset(self):\n        return MailAccount.objects.all().order_by(\"-id\")\n\n\nclass MailRuleSerializer(serializers.ModelSerializer):\n    account = AccountField(required=True)\n    action_parameter = serializers.CharField(\n        allow_null=True,\n        required=False,\n        default=\"\",\n    )\n    assign_correspondent = CorrespondentField(allow_null=True, required=False)\n    assign_tags = TagsField(many=True, allow_null=True, required=False)\n    assign_document_type = DocumentTypeField(allow_null=True, required=False)\n    order = serializers.IntegerField(required=False)\n\n    class Meta:\n        model = MailRule\n        depth = 1\n        fields = [\n            \"id\",\n            \"name\",\n            \"account\",\n            \"folder\",\n            \"filter_from\",\n            \"filter_subject\",\n            \"filter_body\",\n            \"filter_attachment_filename\",\n            \"maximum_age\",\n            \"action\",\n            \"action_parameter\",\n            \"assign_title_from\",\n            \"assign_tags\",\n            \"assign_correspondent_from\",\n            \"assign_correspondent\",\n            \"assign_document_type\",\n            \"order\",\n            \"attachment_type\",\n            \"consumption_scope\",\n        ]\n\n    def update(self, instance, validated_data):\n        super().update(instance, validated_data)\n        return instance\n\n    def create(self, validated_data):\n        if \"assign_tags\" in validated_data:\n            assign_tags = validated_data.pop(\"assign_tags\")\n        mail_rule = MailRule.objects.create(**validated_data)\n        if assign_tags:\n            mail_rule.assign_tags.set(assign_tags)\n        return mail_rule\n\n    def validate(self, attrs):\n        if (\n            attrs[\"action\"] == MailRule.MailAction.TAG\n            or attrs[\"action\"] == MailRule.MailAction.MOVE\n        ) and attrs[\"action_parameter\"] is None:\n            raise serializers.ValidationError(\"An action parameter is required.\")\n\n        return attrs\n", "path": "src/paperless_mail/serialisers.py"}]}