File: batch.py

package info (click to toggle)
mautrix-python 0.20.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,812 kB
  • sloc: python: 19,103; makefile: 16
file content (34 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (c) 2022 Tulir Asokan, Sumner Evans
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from typing import Any, Optional

from attr import dataclass
import attr

from ..primitive import EventID, UserID
from ..util import SerializableAttrs
from .base import BaseEvent


@dataclass(kw_only=True)
class BatchSendEvent(BaseEvent, SerializableAttrs):
    """Base event class for events sent via a batch send request."""

    sender: UserID
    timestamp: int = attr.ib(metadata={"json": "origin_server_ts"})
    content: Any
    # N.B. Overriding event IDs is not allowed in standard room versions
    event_id: Optional[EventID] = None


@dataclass(kw_only=True)
class BatchSendStateEvent(BatchSendEvent, SerializableAttrs):
    """
    State events to be used as initial state events on batch send events. These never need to be
    deserialized.
    """

    state_key: str