api.v1.views.EmailViewSet module

Module with the EmailViewSet viewset.

class api.v1.views.EmailViewSet.EmailViewSet(**kwargs)[source]

Bases: ReadOnlyModelViewSet, DestroyModelMixin, ToggleFavoriteMixin

Viewset for the core.models.Email.Email.

Provides every read-only and a destroy action.

BASENAME = 'email'
serializer_class

alias of FullEmailSerializer

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]
filterset_class

alias of EmailFilterSet

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]
ordering_fields: Final[list[str]] = ['datetime', 'subject', 'datasize', 'is_favorite', 'created', 'updated', 'user_agent', 'language', 'content_language', 'importance', 'priority', 'precedence', 'x_priority', 'x_originated_client']
ordering: Final[list[str]] = ['id']
get_queryset()[source]

Filters the data for entries connected to the request user.

Return type:

QuerySet

Returns:

The email entries matching the request user.

get_serializer_class()[source]

Sets the serializer for list requests to the simplified version.

Return type:

type[BaseSerializer]

URL_PATH_DOWNLOAD = 'download'
URL_NAME_DOWNLOAD = 'download'
download(request, pk=None)[source]

Action method downloading the eml file of the email.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the attachment to download. Defaults to None.

Raises:

Http404 – If the filepath is not in the database or it doesn’t exist.

Return type:

FileResponse

Returns:

A fileresponse containing the requested file.

URL_PATH_DOWNLOAD_BATCH = 'download'
URL_NAME_DOWNLOAD_BATCH = 'download-batch'
download_batch(request)[source]

Action method downloading a batch of emails.

Todo

Validation and parsing of queryparams can probably be done more concisely with a serializer.

Parameters:

request (Request) – The request triggering the action.

Raises:
  • Http404 – If there are no emails in the mailbox.

  • ValidationError – If id or file_format param is missing or in invalid format or file_format is unsupported.

Return type:

Response | FileResponse

Returns:

A fileresponse containing the emails in the requested format.

URL_PATH_THUMBNAIL = 'thumbnail'
URL_NAME_THUMBNAIL = 'thumbnail'
download_thumbnail(request, pk=None)[source]

Action method downloading the html version of the mail.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the email to download. Defaults to None.

Return type:

FileResponse

Returns:

A fileresponse containing the requested file.

URL_PATH_FULLCONVERSATION = 'full-conversation'
URL_NAME_FULLCONVERSATION = 'full-conversation'
conversation(request, pk=None)[source]

Action method getting the complete conversation a mail is part of.

The response data is paginated analogous to the list method.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the email to get the complete conversation it belongs to. Defaults to None.

Return type:

Response

Returns:

A response detailing the request status.

URL_PATH_RESTORE = 'restore'
URL_NAME_RESTORE = 'restore'
restore(request, pk=None)[source]

Action method restoring the email to its mailbox.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the email to get the complete conversation it belongs to. Defaults to None.

Return type:

Response

Returns:

A response detailing the request status.

URL_PATH_REPROCESS = 'reprocess'
URL_NAME_REPROCESS = 'reprocess'
reprocess(request, pk=None)[source]

Action method reprocessing the emails connections to other emails.

Parameters:
  • request (Request) – The request triggering the action.

  • pk (int | None) – The private key of the email to reprocess. Defaults to None.

Return type:

Response

Returns:

A response detailing the request status.

basename = None
description = None
destroy(request, *args, **kwargs)
detail = None
list(request, *args, **kwargs)
name = None
retrieve(request, *args, **kwargs)
suffix = None