# HG changeset patch # User Goffi # Date 1701189422 -3600 # Node ID 98687eaa6a09403c678925f3fb6d62bc7ff568b6 # Parent 2074b2bbe616d1035341d2c375ee300834a8ccb8 models (core): separate `MessageEditData` from `MessageEdition`: `MessageEditData` is used to carry a new `MessageData` when an edition has happened, while `MessageEdition` is used to send changes to do for a new edition. diff -r 2074b2bbe616 -r 98687eaa6a09 libervia/backend/models/core.py --- a/libervia/backend/models/core.py Tue Nov 28 17:35:20 2023 +0100 +++ b/libervia/backend/models/core.py Tue Nov 28 17:37:02 2023 +0100 @@ -16,9 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from typing import Annotated, Literal - -from pydantic import BaseModel, Field, validator +from pydantic import BaseModel, Field class MessageData(dict): @@ -34,31 +32,19 @@ super().__init__(**kwargs) -class MessageEditData(MessageUpdateData): - message: dict[str, str] | None = Field( - None, - description=( - "Updated message content, can be in several languages (key is language code " - 'or "" for default)' - ), - ) - subject: dict[str, str] | None = Field( - None, - description=( - "Updated subject of the message, can be in several languages (key is " - 'language code or "" for default)' - ), - ) - mess_type: str | None = Field( - None, - description=( - "Updated type of the message (cf RFC 6121 ยง5.2.2) + C.MESS_TYPE_INFO (system " - "info)" - ), - ) +class MessageEditData(MessageData): + """Data used when a new message edition has been received""" + pass class MessageReactionData(MessageUpdateData): reactions: dict[str, list[str]] = Field( description="Reaction to reacting entities mapping" ) + + +class MessageEdition(BaseModel): + """Data used to send a message edition""" + message: dict[str, str] + subject: dict[str, str] = Field(default_factory=dict) + extra: dict[str, str] = Field(default_factory=dict)