Chat
This package contains all models for the author and user chats
Chat Message
- class integreat_cms.cms.models.chat.chat_message.ChatHistoryManager(*args, **kwargs)[source]
Bases:
ManagerCustom manager for returning the chat history of the last x days (as configured in
AUTHOR_CHAT_HISTORY_DAYS)- get_queryset() QuerySet[source]
Custom queryset with applied filters to return the chat messages of the last x days
- Returns:
The QuerySet of the most recent chat history
- Return type:
QuerySet
- class integreat_cms.cms.models.chat.chat_message.ChatMessage(*args, **kwargs)[source]
Bases:
AbstractBaseModelA model for a message in the author chat
- Parameters:
id (BigAutoField) – Primary key: ID
text (TextField) – Content
sent_datetime (DateTimeField) – Sent date
Relationship fields:
- Parameters:
sender (
ForeignKeytoUser) – Sender (related name:chat_messages)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- get_repr() str[source]
This overwrites the default Django
__repr__()method which would return<ChatMessage: ChatMessage object (id)>. It is used for logging.- Returns:
The canonical string representation of the chat message
- Return type:
- history = <integreat_cms.cms.models.chat.chat_message.ChatHistoryManager object>[source]
Django manager to access the ORM Use
ChatMessage.objects.all()to fetch all objects.A manager for the most recent chat history
- objects = <django.db.models.Manager object>[source]
Django manager to access the ORM Use
ChatMessage.objects.all()to fetch all objects.The default manager
User Chat
- class integreat_cms.cms.models.chat.user_chat.ABTester(*args, **kwargs)[source]
Bases:
AbstractBaseModelA helper model for keeping track of A/B testers for the chat feature
- Parameters:
id (BigAutoField) – Primary key: ID
device_id (CharField) – Device id
is_tester (BooleanField) – Is tester
Relationship fields:
- Parameters:
region (
ForeignKeytoRegion) – Region (related name:abtester)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- class integreat_cms.cms.models.chat.user_chat.UserChat(*args, **kwargs)[source]
Bases:
AbstractBaseModel,ZammadAPIA model for a user (app) chat, mapping a device ID to a Zammad ticket ID
- Parameters:
id (BigAutoField) – Primary key: ID
device_id (CharField) – Device id
zammad_id (IntegerField) – Zammad id
total_words_generated (IntegerField) – Total words generated. Number of words generated in this chat.
created_timestamp (DateTimeField) – Created timestamp. Date and time when the chat was started.
last_message_timestamp (DateTimeField) – Last message timestamp. Date and time when the last chat message was sent.
Relationship fields:
- Parameters:
region (
ForeignKeytoRegion) – Region for Chat (related name:chats)language (
ForeignKeytoLanguage) – Language of chat app user (related name:chats)
- exception DoesNotExist[source]
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned[source]
Bases:
MultipleObjectsReturned
- get_repr() str[source]
This overwrites the default Django
__repr__()method which would return<UserChat: UserChat object (id)>. It is used for logging.- Returns:
The canonical string representation of the user chat
- Return type:
- property is_expired: bool[source]
Whether the chat has been inactive long enough that its Zammad ticket is assumed to be gone (Zammad’s ticket retention is shorter than ours).
Using the timestamp avoids an extra request to the Zammad API on every chat request just to check whether the ticket still exists.
- Returns:
True if the chat is considered expired, False otherwise
- class integreat_cms.cms.models.chat.user_chat.UserChatManager(*args, **kwargs)[source]
Bases:
Managercustom manager providing function to get the current chat
- create(region: Region, device_id: str, language: Language) UserChat[source]
Override super create method to create a Zammad ticket for each new chat