aboutsummaryrefslogtreecommitdiffstats
path: root/api/viewsets.py
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2018-11-18 22:28:02 +0100
committerGravatar Johannes Christ <[email protected]>2018-11-18 22:28:02 +0100
commit714ec7ffc63dc1b930d1ae80cabd964b8e48f55d (patch)
treea9dda25e5f0e5bd4e8ad237bfe16f1036cf5e599 /api/viewsets.py
parentAdd `MessageDeletionContext` and `DeletedMessage` to the admin. (diff)
Add viewsets and serializers.
Diffstat (limited to 'api/viewsets.py')
-rw-r--r--api/viewsets.py41
1 files changed, 38 insertions, 3 deletions
diff --git a/api/viewsets.py b/api/viewsets.py
index 08660810..bc34de1d 100644
--- a/api/viewsets.py
+++ b/api/viewsets.py
@@ -11,20 +11,55 @@ from rest_framework_bulk import BulkCreateModelMixin
from .models import (
DocumentationLink, Member,
- OffTopicChannelName,
+ MessageDeletionContext, OffTopicChannelName,
SnakeFact, SnakeIdiom,
SnakeName, SpecialSnake,
Tag
)
from .serializers import (
- DocumentationLinkSerializer,
- MemberSerializer, OffTopicChannelNameSerializer,
+ DocumentationLinkSerializer, MemberSerializer,
+ MessageDeletionContextSerializer, OffTopicChannelNameSerializer,
SnakeFactSerializer, SnakeIdiomSerializer,
SnakeNameSerializer, SpecialSnakeSerializer,
TagSerializer
)
+class DeletedMessageViewSet(GenericViewSet):
+ """
+ View providing support for posting bulk deletion logs generated by the bot.
+
+ ## Routes
+ ### POST /bot/deleted-messages
+ Post messages from bulk deletion logs.
+
+ #### Body schema
+ >>> {
+ ... # The member ID of the original actor, if applicable.
+ ... # If a member ID is given, it must be present on the site.
+ ... 'actor': Optional[int]
+ ... 'creation': datetime,
+ ... 'messages': [
+ ... {
+ ... 'id': int,
+ ... 'author': int,
+ ... 'channel_id': int,
+ ... 'content': str,
+ ... 'embeds': [
+ ... # Discord embed objects
+ ... ]
+ ... }
+ ... ]
+ ... }
+
+ #### Status codes
+ - 204: returned on success
+ """
+
+ queryset = MessageDeletionContext.objects.all()
+ serializer = MessageDeletionContextSerializer
+
+
class DocumentationLinkViewSet(
CreateModelMixin, DestroyModelMixin, ListModelMixin, RetrieveModelMixin, GenericViewSet
):