mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-07 04:01:52 +00:00
clean up coding style a bit
This commit is contained in:
parent
8b8beba194
commit
3c7857e49b
@ -30,20 +30,20 @@ class _EventInternalMetadata(object):
|
|||||||
|
|
||||||
|
|
||||||
def _event_dict_property(key):
|
def _event_dict_property(key):
|
||||||
def getter(self):
|
def getter(self):
|
||||||
return self._event_dict[key]
|
return self._event_dict[key]
|
||||||
|
|
||||||
def setter(self, v):
|
def setter(self, v):
|
||||||
self._event_dict[key] = v
|
self._event_dict[key] = v
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
del self._event_dict[key]
|
del self._event_dict[key]
|
||||||
|
|
||||||
return property(
|
return property(
|
||||||
getter,
|
getter,
|
||||||
setter,
|
setter,
|
||||||
delete,
|
delete,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class EventBase(object):
|
class EventBase(object):
|
||||||
|
@ -61,8 +61,6 @@ class BaseHandler(object):
|
|||||||
def _create_new_client_event(self, builder):
|
def _create_new_client_event(self, builder):
|
||||||
yield run_on_reactor()
|
yield run_on_reactor()
|
||||||
|
|
||||||
context = EventContext()
|
|
||||||
|
|
||||||
latest_ret = yield self.store.get_latest_events_in_room(
|
latest_ret = yield self.store.get_latest_events_in_room(
|
||||||
builder.room_id,
|
builder.room_id,
|
||||||
)
|
)
|
||||||
@ -78,6 +76,8 @@ class BaseHandler(object):
|
|||||||
builder.depth = depth
|
builder.depth = depth
|
||||||
|
|
||||||
state_handler = self.state_handler
|
state_handler = self.state_handler
|
||||||
|
|
||||||
|
context = EventContext()
|
||||||
ret = yield state_handler.annotate_context_with_state(
|
ret = yield state_handler.annotate_context_with_state(
|
||||||
builder,
|
builder,
|
||||||
context,
|
context,
|
||||||
|
@ -156,4 +156,3 @@ class DirectoryHandler(BaseHandler):
|
|||||||
"sender": user_id,
|
"sender": user_id,
|
||||||
"content": {"aliases": aliases},
|
"content": {"aliases": aliases},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -263,9 +263,7 @@ class FederationHandler(BaseHandler):
|
|||||||
context = EventContext()
|
context = EventContext()
|
||||||
yield self.state_handler.annotate_context_with_state(event, context)
|
yield self.state_handler.annotate_context_with_state(event, context)
|
||||||
|
|
||||||
events.append(
|
events.append((event, context))
|
||||||
(event, context)
|
|
||||||
)
|
|
||||||
|
|
||||||
yield self.store.persist_event(
|
yield self.store.persist_event(
|
||||||
event,
|
event,
|
||||||
@ -547,8 +545,6 @@ class FederationHandler(BaseHandler):
|
|||||||
"""
|
"""
|
||||||
event = pdu
|
event = pdu
|
||||||
|
|
||||||
context = EventContext()
|
|
||||||
|
|
||||||
event.internal_metadata.outlier = True
|
event.internal_metadata.outlier = True
|
||||||
|
|
||||||
event.signatures.update(
|
event.signatures.update(
|
||||||
@ -559,6 +555,7 @@ class FederationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
context = EventContext()
|
||||||
yield self.state_handler.annotate_context_with_state(event, context)
|
yield self.state_handler.annotate_context_with_state(event, context)
|
||||||
|
|
||||||
yield self.store.persist_event(
|
yield self.store.persist_event(
|
||||||
@ -685,13 +682,13 @@ class FederationHandler(BaseHandler):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _handle_new_event(self, event, state=None, backfilled=False,
|
def _handle_new_event(self, event, state=None, backfilled=False,
|
||||||
current_state=None, fetch_missing=True):
|
current_state=None, fetch_missing=True):
|
||||||
context = EventContext()
|
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"_handle_new_event: Before annotate: %s, sigs: %s",
|
"_handle_new_event: Before annotate: %s, sigs: %s",
|
||||||
event.event_id, event.signatures,
|
event.event_id, event.signatures,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
context = EventContext()
|
||||||
yield self.state_handler.annotate_context_with_state(
|
yield self.state_handler.annotate_context_with_state(
|
||||||
event,
|
event,
|
||||||
context,
|
context,
|
||||||
|
@ -45,8 +45,8 @@ class TypingNotificationHandler(BaseHandler):
|
|||||||
|
|
||||||
hs.get_distributor().observe("user_left_room", self.user_left_room)
|
hs.get_distributor().observe("user_left_room", self.user_left_room)
|
||||||
|
|
||||||
self._member_typing_until = {} # clock time we expect to stop
|
self._member_typing_until = {} # clock time we expect to stop
|
||||||
self._member_typing_timer = {} # deferreds to manage theabove
|
self._member_typing_timer = {} # deferreds to manage theabove
|
||||||
|
|
||||||
# map room IDs to serial numbers
|
# map room IDs to serial numbers
|
||||||
self._room_serials = {}
|
self._room_serials = {}
|
||||||
|
@ -135,6 +135,7 @@ class BaseMediaResource(Resource):
|
|||||||
if download is None:
|
if download is None:
|
||||||
download = self._get_remote_media_impl(server_name, media_id)
|
download = self._get_remote_media_impl(server_name, media_id)
|
||||||
self.downloads[key] = download
|
self.downloads[key] = download
|
||||||
|
|
||||||
@download.addBoth
|
@download.addBoth
|
||||||
def callback(media_info):
|
def callback(media_info):
|
||||||
del self.downloads[key]
|
del self.downloads[key]
|
||||||
|
@ -310,8 +310,8 @@ class RoomMessageListRestServlet(RestServlet):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_GET(self, request, room_id):
|
def on_GET(self, request, room_id):
|
||||||
user = yield self.auth.get_user_by_req(request)
|
user = yield self.auth.get_user_by_req(request)
|
||||||
pagination_config = PaginationConfig.from_request(request,
|
pagination_config = PaginationConfig.from_request(
|
||||||
default_limit=10,
|
request, default_limit=10,
|
||||||
)
|
)
|
||||||
with_feedback = "feedback" in request.args
|
with_feedback = "feedback" in request.args
|
||||||
handler = self.handlers.message_handler
|
handler = self.handlers.message_handler
|
||||||
@ -466,7 +466,9 @@ class RoomRedactEventRestServlet(RestServlet):
|
|||||||
|
|
||||||
|
|
||||||
class RoomTypingRestServlet(RestServlet):
|
class RoomTypingRestServlet(RestServlet):
|
||||||
PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/typing/(?P<user_id>[^/]*)$")
|
PATTERN = client_path_pattern(
|
||||||
|
"/rooms/(?P<room_id>[^/]*)/typing/(?P<user_id>[^/]*)$"
|
||||||
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_PUT(self, request, room_id, user_id):
|
def on_PUT(self, request, room_id, user_id):
|
||||||
|
@ -19,6 +19,7 @@ import logging
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# FIXME: elsewhere we use FooStore to indicate something in the storage layer...
|
# FIXME: elsewhere we use FooStore to indicate something in the storage layer...
|
||||||
class HttpTransactionStore(object):
|
class HttpTransactionStore(object):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user