mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 07:13:49 +01:00
Use named parameter format
This commit is contained in:
parent
765f2b8446
commit
d3da5294e8
1 changed files with 22 additions and 14 deletions
|
@ -35,13 +35,13 @@ import time
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
||||||
MESSAGE_FROM_PERSON_IN_ROOM = "You have a message from %s in the %s room"
|
MESSAGE_FROM_PERSON_IN_ROOM = "You have a message from %(person)s in the %s room"
|
||||||
MESSAGE_FROM_PERSON = "You have a message from %s"
|
MESSAGE_FROM_PERSON = "You have a message from %(person)s"
|
||||||
MESSAGES_FROM_PERSON = "You have messages from %s"
|
MESSAGES_FROM_PERSON = "You have messages from %(person)s"
|
||||||
MESSAGES_IN_ROOM = "There are some messages for you in the %s room"
|
MESSAGES_IN_ROOM = "There are some messages for you in the %(room)s room"
|
||||||
MESSAGES_IN_ROOMS = "Here are some messages you may have missed"
|
MESSAGES_IN_ROOMS = "Here are some messages you may have missed"
|
||||||
INVITE_FROM_PERSON_TO_ROOM = "%s has invited you to join the %s room"
|
INVITE_FROM_PERSON_TO_ROOM = "%(person)s has invited you to join the %(room)s room"
|
||||||
INVITE_FROM_PERSON = "%s has invited you to chat"
|
INVITE_FROM_PERSON = "%(person)s has invited you to chat"
|
||||||
|
|
||||||
CONTEXT_BEFORE = 1
|
CONTEXT_BEFORE = 1
|
||||||
|
|
||||||
|
@ -278,9 +278,11 @@ class Mailer(object):
|
||||||
inviter_name = name_from_member_event(inviter_member_event)
|
inviter_name = name_from_member_event(inviter_member_event)
|
||||||
|
|
||||||
if room_name is None:
|
if room_name is None:
|
||||||
return INVITE_FROM_PERSON % (inviter_name,)
|
return INVITE_FROM_PERSON % {"person": inviter_name}
|
||||||
else:
|
else:
|
||||||
return INVITE_FROM_PERSON_TO_ROOM % (inviter_name, room_name)
|
return INVITE_FROM_PERSON_TO_ROOM % {
|
||||||
|
"person": inviter_name, "room": room_name
|
||||||
|
}
|
||||||
|
|
||||||
sender_name = None
|
sender_name = None
|
||||||
if len(notifs_by_room[room_id]) == 1:
|
if len(notifs_by_room[room_id]) == 1:
|
||||||
|
@ -291,14 +293,20 @@ class Mailer(object):
|
||||||
sender_name = name_from_member_event(state_event)
|
sender_name = name_from_member_event(state_event)
|
||||||
|
|
||||||
if sender_name is not None and room_name is not None:
|
if sender_name is not None and room_name is not None:
|
||||||
return MESSAGE_FROM_PERSON_IN_ROOM % (sender_name, room_name)
|
return MESSAGE_FROM_PERSON_IN_ROOM % {
|
||||||
|
"person": sender_name, "room": room_name
|
||||||
|
}
|
||||||
elif sender_name is not None:
|
elif sender_name is not None:
|
||||||
return MESSAGE_FROM_PERSON % (sender_name,)
|
return MESSAGE_FROM_PERSON % {
|
||||||
|
"person": sender_name
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
# There's more than one notification for this room, so just
|
# There's more than one notification for this room, so just
|
||||||
# say there are several
|
# say there are several
|
||||||
if room_name is not None:
|
if room_name is not None:
|
||||||
return MESSAGES_IN_ROOM % (room_name,)
|
return MESSAGES_IN_ROOM % {
|
||||||
|
"room": room_name
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
# If the room doesn't have a name, say who the messages
|
# If the room doesn't have a name, say who the messages
|
||||||
# are from explicitly to avoid, "messages in the Bob room"
|
# are from explicitly to avoid, "messages in the Bob room"
|
||||||
|
@ -307,12 +315,12 @@ class Mailer(object):
|
||||||
for n in notifs_by_room[room_id]
|
for n in notifs_by_room[room_id]
|
||||||
]))
|
]))
|
||||||
|
|
||||||
return MESSAGES_FROM_PERSON % (
|
return MESSAGES_FROM_PERSON % {
|
||||||
descriptor_from_member_events([
|
"person": descriptor_from_member_events([
|
||||||
state_by_room[room_id][("m.room.member", s)]
|
state_by_room[room_id][("m.room.member", s)]
|
||||||
for s in sender_ids
|
for s in sender_ids
|
||||||
])
|
])
|
||||||
)
|
}
|
||||||
else:
|
else:
|
||||||
# Stuff's happened in multiple different rooms
|
# Stuff's happened in multiple different rooms
|
||||||
return MESSAGES_IN_ROOMS
|
return MESSAGES_IN_ROOMS
|
||||||
|
|
Loading…
Reference in a new issue