2022-10-16 21:11:48 +00:00
|
|
|
from rest_framework import serializers
|
2022-10-25 18:04:12 +00:00
|
|
|
|
2022-10-16 21:11:48 +00:00
|
|
|
from chat.models import Message
|
|
|
|
|
|
|
|
|
2022-10-20 09:56:10 +00:00
|
|
|
class ChatSerializer(serializers.ModelSerializer):
|
2022-10-16 21:11:48 +00:00
|
|
|
class Meta:
|
|
|
|
model = Message
|
|
|
|
fields = (
|
|
|
|
"index",
|
|
|
|
"sender",
|
|
|
|
"PGP_message",
|
|
|
|
"created_at",
|
|
|
|
)
|
|
|
|
depth = 0
|
|
|
|
|
2022-10-20 09:56:10 +00:00
|
|
|
|
2022-10-16 21:11:48 +00:00
|
|
|
class PostMessageSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Message
|
2022-11-11 09:28:09 +00:00
|
|
|
fields = ("PGP_message", "order_id", "offset")
|
2022-10-16 21:11:48 +00:00
|
|
|
depth = 0
|
2022-10-20 09:56:10 +00:00
|
|
|
|
|
|
|
offset = serializers.IntegerField(
|
|
|
|
allow_null=True,
|
|
|
|
default=None,
|
|
|
|
required=False,
|
|
|
|
min_value=0,
|
|
|
|
help_text="Offset for message index to get as response",
|
|
|
|
)
|
2022-11-11 09:28:09 +00:00
|
|
|
|
|
|
|
order_id = serializers.IntegerField(
|
|
|
|
allow_null=False,
|
|
|
|
required=True,
|
|
|
|
min_value=0,
|
|
|
|
help_text="Order ID of chatroom",
|
|
|
|
)
|