Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
ebbabc49
Commit
ebbabc49
authored
8 years ago
by
David Baker
Browse files
Options
Downloads
Patches
Plain Diff
Handle room invites in email notifs
parent
53677082
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
res/templates/room.html
+9
-5
9 additions, 5 deletions
res/templates/room.html
synapse/push/mailer.py
+30
-5
30 additions, 5 deletions
synapse/push/mailer.py
synapse/util/presentable_names.py
+3
-3
3 additions, 3 deletions
synapse/util/presentable_names.py
with
42 additions
and
13 deletions
res/templates/room.html
+
9
−
5
View file @
ebbabc49
...
...
@@ -13,9 +13,13 @@
{% endif %}
{% endif %}
</div>
<div>
{% for notif in room.notifs %}
{% include 'notif.html' with context %}
{% endfor %}
</div>
{% if room.invite %}
<a
href=
"{{ room.link }}"
>
Join the conversation.
</a>
{% else %}
<div>
{% for notif in room.notifs %}
{% include 'notif.html' with context %}
{% endfor %}
</div>
{% endif %}
</div>
This diff is collapsed.
Click to expand it.
synapse/push/mailer.py
+
30
−
5
View file @
ebbabc49
...
...
@@ -39,6 +39,8 @@ 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
"
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
"
CONTEXT_BEFORE
=
1
...
...
@@ -148,17 +150,24 @@ class Mailer(object):
@defer.inlineCallbacks
def
get_room_vars
(
self
,
room_id
,
user_id
,
notifs
,
notif_events
,
room_state
):
my_member_event
=
room_state
[(
"
m.room.member
"
,
user_id
)]
is_invite
=
my_member_event
.
content
[
"
membership
"
]
==
"
invite
"
room_vars
=
{
"
title
"
:
calculate_room_name
(
room_state
,
user_id
),
"
hash
"
:
string_ordinal_total
(
room_id
),
# See sender avatar hash
"
notifs
"
:
[],
"
invite
"
:
is_invite
}
for
n
in
notifs
:
vars
=
yield
self
.
get_notif_vars
(
n
,
user_id
,
notif_events
[
n
[
'
event_id
'
]],
room_state
)
room_vars
[
'
notifs
'
].
append
(
vars
)
if
is_invite
:
room_vars
[
"
link
"
]
=
self
.
make_room_link
(
room_id
)
else
:
for
n
in
notifs
:
vars
=
yield
self
.
get_notif_vars
(
n
,
user_id
,
notif_events
[
n
[
'
event_id
'
]],
room_state
)
room_vars
[
'
notifs
'
].
append
(
vars
)
defer
.
returnValue
(
room_vars
)
...
...
@@ -235,6 +244,18 @@ class Mailer(object):
state_by_room
[
room_id
],
user_id
,
fallback_to_members
=
False
)
my_member_event
=
state_by_room
[
room_id
][(
"
m.room.member
"
,
user_id
)]
if
my_member_event
.
content
[
"
membership
"
]
==
"
invite
"
:
inviter_member_event
=
state_by_room
[
room_id
][
(
"
m.room.member
"
,
my_member_event
.
sender
)
]
inviter_name
=
name_from_member_event
(
inviter_member_event
)
if
room_name
is
None
:
return
INVITE_FROM_PERSON
%
(
inviter_name
,)
else
:
return
INVITE_FROM_PERSON_TO_ROOM
%
(
inviter_name
,
room_name
)
sender_name
=
None
if
len
(
notifs_by_room
[
room_id
])
==
1
:
# There is just the one notification, so give some detail
...
...
@@ -242,6 +263,7 @@ class Mailer(object):
if
(
"
m.room.member
"
,
event
.
sender
)
in
state_by_room
[
room_id
]:
state_event
=
state_by_room
[
room_id
][(
"
m.room.member
"
,
event
.
sender
)]
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
)
elif
sender_name
is
not
None
:
...
...
@@ -268,6 +290,9 @@ class Mailer(object):
# Stuff's happened in multiple different rooms
return
MESSAGES_IN_ROOMS
def
make_room_link
(
self
,
room_id
):
return
"
https://matrix.to/%s
"
%
(
room_id
,)
def
make_notif_link
(
self
,
notif
):
return
"
https://matrix.to/%s/%s
"
%
(
notif
[
'
room_id
'
],
notif
[
'
event_id
'
]
...
...
This diff is collapsed.
Click to expand it.
synapse/util/presentable_names.py
+
3
−
3
View file @
ebbabc49
...
...
@@ -52,6 +52,9 @@ def calculate_room_name(room_state, user_id, fallback_to_members=True):
if
len
(
the_aliases
)
>
0
and
_looks_like_an_alias
(
the_aliases
[
0
]):
return
the_aliases
[
0
]
if
not
fallback_to_members
:
return
None
my_member_event
=
None
if
(
"
m.room.member
"
,
user_id
)
in
room_state
:
my_member_event
=
room_state
[(
"
m.room.member
"
,
user_id
)]
...
...
@@ -66,9 +69,6 @@ def calculate_room_name(room_state, user_id, fallback_to_members=True):
else
:
return
"
Room Invite
"
if
not
fallback_to_members
:
return
None
# we're going to have to generate a name based on who's in the room,
# so find out who is in the room that isn't the user.
if
"
m.room.member
"
in
room_state_bytype
:
...
...
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