0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-18 16:02:15 +01:00

Avoid vars builtin

This commit is contained in:
David Baker 2016-04-29 19:09:28 +01:00
parent d3da5294e8
commit 29c8cf8db8

View file

@ -125,10 +125,10 @@ class Mailer(object):
rooms = [] rooms = []
for r in rooms_in_order: for r in rooms_in_order:
vars = yield self.get_room_vars( roomvars = yield self.get_room_vars(
r, user_id, notifs_by_room[r], notif_events, state_by_room[r] r, user_id, notifs_by_room[r], notif_events, state_by_room[r]
) )
rooms.append(vars) rooms.append(roomvars)
summary_text = self.make_summary_text( summary_text = self.make_summary_text(
notifs_by_room, state_by_room, notif_events, user_id notifs_by_room, state_by_room, notif_events, user_id
@ -175,10 +175,10 @@ class Mailer(object):
if not is_invite: if not is_invite:
for n in notifs: for n in notifs:
vars = yield self.get_notif_vars( notifvars = yield self.get_notif_vars(
n, user_id, notif_events[n['event_id']], room_state n, user_id, notif_events[n['event_id']], room_state
) )
room_vars['notifs'].append(vars) room_vars['notifs'].append(notifvars)
defer.returnValue(room_vars) defer.returnValue(room_vars)
@ -202,9 +202,9 @@ class Mailer(object):
the_events.append(notif_event) the_events.append(notif_event)
for event in the_events: for event in the_events:
vars = self.get_message_vars(notif, event, room_state) messagevars = self.get_message_vars(notif, event, room_state)
if vars is not None: if messagevars is not None:
ret['messages'].append(vars) ret['messages'].append(messagevars)
defer.returnValue(ret) defer.returnValue(ret)
@ -239,24 +239,24 @@ class Mailer(object):
return ret return ret
def add_text_message_vars(self, vars, event): def add_text_message_vars(self, messagevars, event):
if "format" in event.content: if "format" in event.content:
msgformat = event.content["format"] msgformat = event.content["format"]
else: else:
msgformat = None msgformat = None
vars["format"] = msgformat messagevars["format"] = msgformat
if msgformat == "org.matrix.custom.html": if msgformat == "org.matrix.custom.html":
vars["body_text_html"] = safe_markup(event.content["formatted_body"]) messagevars["body_text_html"] = safe_markup(event.content["formatted_body"])
else: else:
vars["body_text_html"] = safe_text(event.content["body"]) messagevars["body_text_html"] = safe_text(event.content["body"])
return vars return messagevars
def add_image_message_vars(self, vars, event): def add_image_message_vars(self, messagevars, event):
vars["image_url"] = event.content["url"] messagevars["image_url"] = event.content["url"]
return vars return messagevars
def make_summary_text(self, notifs_by_room, state_by_room, notif_events, user_id): def make_summary_text(self, notifs_by_room, state_by_room, notif_events, user_id):
if len(notifs_by_room) == 1: if len(notifs_by_room) == 1: