summary refs log tree commit diff
path: root/synapse/push
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2016-04-29 19:04:40 +0100
committerDavid Baker <dave@matrix.org>2016-04-29 19:04:40 +0100
commitd3da5294e8acaba34c59bdfc62f7010363b17a18 (patch)
treec20db260d82c4a216168e84ab660856c914b28cf /synapse/push
parentDefault enable email notifs to False (diff)
downloadsynapse-d3da5294e8acaba34c59bdfc62f7010363b17a18.tar.xz
Use named parameter format
Diffstat (limited to '')
-rw-r--r--synapse/push/mailer.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py
index 0ab5168e20..b193bb84b1 100644
--- a/synapse/push/mailer.py
+++ b/synapse/push/mailer.py
@@ -35,13 +35,13 @@ import time
 import urllib
 
 
-MESSAGE_FROM_PERSON_IN_ROOM = "You have a message from %s in the %s room"
-MESSAGE_FROM_PERSON = "You have a message from %s"
-MESSAGES_FROM_PERSON = "You have messages from %s"
-MESSAGES_IN_ROOM = "There are some messages for you 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 %(person)s"
+MESSAGES_FROM_PERSON = "You have messages from %(person)s"
+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"
-INVITE_FROM_PERSON_TO_ROOM = "%s has invited you to join the %s room"
-INVITE_FROM_PERSON = "%s has invited you to chat"
+INVITE_FROM_PERSON_TO_ROOM = "%(person)s has invited you to join the %(room)s room"
+INVITE_FROM_PERSON = "%(person)s has invited you to chat"
 
 CONTEXT_BEFORE = 1
 
@@ -278,9 +278,11 @@ class Mailer(object):
                 inviter_name = name_from_member_event(inviter_member_event)
 
                 if room_name is None:
-                    return INVITE_FROM_PERSON % (inviter_name,)
+                    return INVITE_FROM_PERSON % {"person": inviter_name}
                 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
             if len(notifs_by_room[room_id]) == 1:
@@ -291,14 +293,20 @@ class Mailer(object):
                     sender_name = name_from_member_event(state_event)
 
                 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:
-                    return MESSAGE_FROM_PERSON % (sender_name,)
+                    return MESSAGE_FROM_PERSON % {
+                        "person": sender_name
+                    }
             else:
                 # There's more than one notification for this room, so just
                 # say there are several
                 if room_name is not None:
-                    return MESSAGES_IN_ROOM % (room_name,)
+                    return MESSAGES_IN_ROOM % {
+                        "room": room_name
+                    }
                 else:
                     # If the room doesn't have a name, say who the messages
                     # 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]
                     ]))
 
-                    return MESSAGES_FROM_PERSON % (
-                        descriptor_from_member_events([
+                    return MESSAGES_FROM_PERSON % {
+                        "person": descriptor_from_member_events([
                             state_by_room[room_id][("m.room.member", s)]
                             for s in sender_ids
                         ])
-                    )
+                    }
         else:
             # Stuff's happened in multiple different rooms
             return MESSAGES_IN_ROOMS