Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
a234e895
Commit
a234e895
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix room name in email notifs
parent
c943d8d2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/push/mailer.py
+20
-19
20 additions, 19 deletions
synapse/push/mailer.py
with
20 additions
and
19 deletions
synapse/push/mailer.py
+
20
−
19
View file @
a234e895
...
@@ -159,12 +159,12 @@ class Mailer(object):
...
@@ -159,12 +159,12 @@ class Mailer(object):
)
)
rooms
.
append
(
roomvars
)
rooms
.
append
(
roomvars
)
reason
[
'
room_name
'
]
=
calculate_room_name
(
reason
[
'
room_name
'
]
=
yield
calculate_room_name
(
self
.
store
,
state_by_room
[
reason
[
'
room_id
'
]],
user_id
,
self
.
store
,
state_by_room
[
reason
[
'
room_id
'
]],
user_id
,
fallback_to_members
=
True
fallback_to_members
=
True
)
)
summary_text
=
self
.
make_summary_text
(
summary_text
=
yield
self
.
make_summary_text
(
notifs_by_room
,
state_by_room
,
notif_events
,
user_id
,
reason
notifs_by_room
,
state_by_room
,
notif_events
,
user_id
,
reason
)
)
...
@@ -327,6 +327,7 @@ class Mailer(object):
...
@@ -327,6 +327,7 @@ class Mailer(object):
return
messagevars
return
messagevars
@defer.inlineCallbacks
def
make_summary_text
(
self
,
notifs_by_room
,
state_by_room
,
def
make_summary_text
(
self
,
notifs_by_room
,
state_by_room
,
notif_events
,
user_id
,
reason
):
notif_events
,
user_id
,
reason
):
if
len
(
notifs_by_room
)
==
1
:
if
len
(
notifs_by_room
)
==
1
:
...
@@ -336,7 +337,7 @@ class Mailer(object):
...
@@ -336,7 +337,7 @@ class Mailer(object):
# If the room has some kind of name, use it, but we don't
# If the room has some kind of name, use it, but we don't
# want the generated-from-names one here otherwise we'll
# want the generated-from-names one here otherwise we'll
# end up with, "new message from Bob in the Bob room"
# end up with, "new message from Bob in the Bob room"
room_name
=
calculate_room_name
(
room_name
=
yield
calculate_room_name
(
state_by_room
[
room_id
],
user_id
,
fallback_to_members
=
False
state_by_room
[
room_id
],
user_id
,
fallback_to_members
=
False
)
)
...
@@ -348,16 +349,16 @@ class Mailer(object):
...
@@ -348,16 +349,16 @@ 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
%
{
defer
.
returnValue
(
INVITE_FROM_PERSON
%
{
"
person
"
:
inviter_name
,
"
person
"
:
inviter_name
,
"
app
"
:
self
.
app_name
"
app
"
:
self
.
app_name
}
}
)
else
:
else
:
return
INVITE_FROM_PERSON_TO_ROOM
%
{
defer
.
returnValue
(
INVITE_FROM_PERSON_TO_ROOM
%
{
"
person
"
:
inviter_name
,
"
person
"
:
inviter_name
,
"
room
"
:
room_name
,
"
room
"
:
room_name
,
"
app
"
:
self
.
app_name
,
"
app
"
:
self
.
app_name
,
}
}
)
sender_name
=
None
sender_name
=
None
if
len
(
notifs_by_room
[
room_id
])
==
1
:
if
len
(
notifs_by_room
[
room_id
])
==
1
:
...
@@ -368,24 +369,24 @@ class Mailer(object):
...
@@ -368,24 +369,24 @@ 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
%
{
defer
.
returnValue
(
MESSAGE_FROM_PERSON_IN_ROOM
%
{
"
person
"
:
sender_name
,
"
person
"
:
sender_name
,
"
room
"
:
room_name
,
"
room
"
:
room_name
,
"
app
"
:
self
.
app_name
,
"
app
"
:
self
.
app_name
,
}
}
)
elif
sender_name
is
not
None
:
elif
sender_name
is
not
None
:
return
MESSAGE_FROM_PERSON
%
{
defer
.
returnValue
(
MESSAGE_FROM_PERSON
%
{
"
person
"
:
sender_name
,
"
person
"
:
sender_name
,
"
app
"
:
self
.
app_name
,
"
app
"
:
self
.
app_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
%
{
defer
.
returnValue
(
MESSAGES_IN_ROOM
%
{
"
room
"
:
room_name
,
"
room
"
:
room_name
,
"
app
"
:
self
.
app_name
,
"
app
"
:
self
.
app_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"
...
@@ -394,22 +395,22 @@ class Mailer(object):
...
@@ -394,22 +395,22 @@ class Mailer(object):
for
n
in
notifs_by_room
[
room_id
]
for
n
in
notifs_by_room
[
room_id
]
]))
]))
return
MESSAGES_FROM_PERSON
%
{
defer
.
returnValue
(
MESSAGES_FROM_PERSON
%
{
"
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
]),
]),
"
app
"
:
self
.
app_name
,
"
app
"
:
self
.
app_name
,
}
}
)
else
:
else
:
# Stuff's happened in multiple different rooms
# Stuff's happened in multiple different rooms
# ...but we still refer to the 'reason' room which triggered the mail
# ...but we still refer to the 'reason' room which triggered the mail
if
reason
[
'
room_name
'
]
is
not
None
:
if
reason
[
'
room_name
'
]
is
not
None
:
return
MESSAGES_IN_ROOM_AND_OTHERS
%
{
defer
.
returnValue
(
MESSAGES_IN_ROOM_AND_OTHERS
%
{
"
room
"
:
reason
[
'
room_name
'
],
"
room
"
:
reason
[
'
room_name
'
],
"
app
"
:
self
.
app_name
,
"
app
"
:
self
.
app_name
,
}
}
)
else
:
else
:
# If the reason room doesn't have a name, say who the messages
# If the reason 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"
...
@@ -418,13 +419,13 @@ class Mailer(object):
...
@@ -418,13 +419,13 @@ class Mailer(object):
for
n
in
notifs_by_room
[
reason
[
'
room_id
'
]]
for
n
in
notifs_by_room
[
reason
[
'
room_id
'
]]
]))
]))
return
MESSAGES_FROM_PERSON_AND_OTHERS
%
{
defer
.
returnValue
(
MESSAGES_FROM_PERSON_AND_OTHERS
%
{
"
person
"
:
descriptor_from_member_events
([
"
person
"
:
descriptor_from_member_events
([
state_by_room
[
reason
[
'
room_id
'
]][(
"
m.room.member
"
,
s
)]
state_by_room
[
reason
[
'
room_id
'
]][(
"
m.room.member
"
,
s
)]
for
s
in
sender_ids
for
s
in
sender_ids
]),
]),
"
app
"
:
self
.
app_name
,
"
app
"
:
self
.
app_name
,
}
}
)
def
make_room_link
(
self
,
room_id
):
def
make_room_link
(
self
,
room_id
):
# need /beta for Universal Links to work on iOS
# need /beta for Universal Links to work on iOS
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment