Mercurial > libervia-backend
changeset 4162:98687eaa6a09
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 28 Nov 2023 17:37:02 +0100 |
parents | 2074b2bbe616 |
children | 3b3cd9453d9b |
files | libervia/backend/models/core.py |
diffstat | 1 files changed, 11 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- 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 <http://www.gnu.org/licenses/>. -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)