17
17
import attr
18
18
from nacl .signing import SigningKey
19
19
20
+ from synapse .api .auth import Auth
20
21
from synapse .api .constants import MAX_DEPTH
21
22
from synapse .api .errors import UnsupportedRoomVersionError
22
23
from synapse .api .room_versions import (
27
28
)
28
29
from synapse .crypto .event_signing import add_hashes_and_signatures
29
30
from synapse .events import EventBase , _EventInternalMetadata , make_event_from_dict
31
+ from synapse .state import StateHandler
32
+ from synapse .storage .databases .main import DataStore
30
33
from synapse .types import EventID , JsonDict
31
34
from synapse .util import Clock
32
35
from synapse .util .stringutils import random_string
@@ -42,45 +45,46 @@ class EventBuilder(object):
42
45
43
46
Attributes:
44
47
room_version: Version of the target room
45
- room_id (str)
46
- type (str)
47
- sender (str)
48
- content (dict)
49
- unsigned (dict)
50
- internal_metadata (_EventInternalMetadata)
51
-
52
- _state (StateHandler)
53
- _auth (synapse.api.Auth)
54
- _store (DataStore)
55
- _clock (Clock)
56
- _hostname (str) : The hostname of the server creating the event
48
+ room_id
49
+ type
50
+ sender
51
+ content
52
+ unsigned
53
+ internal_metadata
54
+
55
+ _state
56
+ _auth
57
+ _store
58
+ _clock
59
+ _hostname: The hostname of the server creating the event
57
60
_signing_key: The signing key to use to sign the event as the server
58
61
"""
59
62
60
- _state = attr .ib ()
61
- _auth = attr .ib ()
62
- _store = attr .ib ()
63
- _clock = attr .ib ()
64
- _hostname = attr .ib ()
65
- _signing_key = attr .ib ()
63
+ _state = attr .ib (type = StateHandler )
64
+ _auth = attr .ib (type = Auth )
65
+ _store = attr .ib (type = DataStore )
66
+ _clock = attr .ib (type = Clock )
67
+ _hostname = attr .ib (type = str )
68
+ _signing_key = attr .ib (type = SigningKey )
66
69
67
70
room_version = attr .ib (type = RoomVersion )
68
71
69
- room_id = attr .ib ()
70
- type = attr .ib ()
71
- sender = attr .ib ()
72
+ room_id = attr .ib (type = str )
73
+ type = attr .ib (type = str )
74
+ sender = attr .ib (type = str )
72
75
73
- content = attr .ib (default = attr .Factory (dict ))
74
- unsigned = attr .ib (default = attr .Factory (dict ))
76
+ content = attr .ib (default = attr .Factory (dict ), type = JsonDict )
77
+ unsigned = attr .ib (default = attr .Factory (dict ), type = JsonDict )
75
78
76
79
# These only exist on a subset of events, so they raise AttributeError if
77
80
# someone tries to get them when they don't exist.
78
- _state_key = attr .ib (default = None )
79
- _redacts = attr .ib (default = None )
80
- _origin_server_ts = attr .ib (default = None )
81
+ _state_key = attr .ib (default = None , type = Optional [ str ] )
82
+ _redacts = attr .ib (default = None , type = Optional [ str ] )
83
+ _origin_server_ts = attr .ib (default = None , type = Optional [ int ] )
81
84
82
85
internal_metadata = attr .ib (
83
- default = attr .Factory (lambda : _EventInternalMetadata ({}))
86
+ default = attr .Factory (lambda : _EventInternalMetadata ({})),
87
+ type = _EventInternalMetadata ,
84
88
)
85
89
86
90
@property
0 commit comments