peterfarrell/django-heralder

SentNotification model: better storage of attachments

Opened this issue · 1 comments

Here was we currently store for tests.notifications.MyNotification:

[
  {
    "py/tuple": [
      "Report.txt",
      "Some Report Data",
      "text/plain"
    ]
  },
  {
    "py/object": "email.mime.image.MIMEImage",
    "policy": {
      "py/object": "email._policybase.Compat32"
    },
    "_headers": [
      {
        "py/tuple": [
          "Content-Type",
          "image/jpeg"
        ]
      },
      {
        "py/tuple": [
          "MIME-Version",
          "1.0"
        ]
      },
      {
        "py/tuple": [
          "Content-Transfer-Encoding",
          "base64"
        ]
      },
      {
        "py/tuple": [
          "Content-ID",
          "<python.jpg>"
        ]
      }
    ],
    "_unixfrom": null,
    "_payload": <base64>,
   "_charset": null,
    "preamble": null,
    "epilogue": null,
    "defects": [],
    "_default_type": "text/plain"
  }
]

We need to store it in a way we can easily parse it, and get the basics about each attachment: MIME type, file name if any, and of course the payload.

Since it could be a rabbit hole, another option would be to store the the raw email and rely on some lib to parse it and display it.