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
4845c735
Commit
4845c735
authored
8 years ago
by
David Baker
Browse files
Options
Downloads
Patches
Plain Diff
Support image notifs
parent
60f86fc8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
res/templates/notif.html
+8
-4
8 additions, 4 deletions
res/templates/notif.html
synapse/push/mailer.py
+25
-11
25 additions, 11 deletions
synapse/push/mailer.py
with
33 additions
and
15 deletions
res/templates/notif.html
+
8
−
4
View file @
4845c735
...
...
@@ -17,10 +17,14 @@
<div
class=
"sender_name"
>
{{ message.sender_name }}
</div>
<div
class=
"message_time"
>
{{ message.ts|format_ts("%H:%M") }}
</div>
<div
class=
"message_body"
>
{% if message.format == "org.matrix.custom.html" %}
{{ message.body_text_html }}
{% else %}
{{ message.body_text_plain }}
{% if message.msgtype == "m.text" %}
{% if message.format == "org.matrix.custom.html" %}
{{ message.body_text_html }}
{% else %}
{{ message.body_text_plain }}
{% endif %}
{% elif message.msgtype == "m.image" %}
<img
src=
"{{ message.image_url|mxc_to_http(640, 480, scale) }}"
/>
{% endif %}
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
synapse/push/mailer.py
+
25
−
11
View file @
4845c735
...
...
@@ -200,13 +200,6 @@ class Mailer(object):
def
get_message_vars
(
self
,
notif
,
event
,
room_state
):
if
event
.
type
!=
"
m.room.message
"
:
return
None
if
event
.
content
[
"
msgtype
"
]
!=
"
m.text
"
:
return
None
if
"
format
"
in
event
.
content
:
msgformat
=
event
.
content
[
"
format
"
]
else
:
msgformat
=
None
sender_state_event
=
room_state
[(
"
m.room.member
"
,
event
.
sender
)]
sender_name
=
name_from_member_event
(
sender_state_event
)
...
...
@@ -217,7 +210,7 @@ class Mailer(object):
sender_hash
=
string_ordinal_total
(
event
.
sender
)
ret
=
{
"
format
"
:
msgformat
,
"
msgtype
"
:
event
.
content
[
"
msgtype
"
]
,
"
is_historical
"
:
event
.
event_id
!=
notif
[
'
event_id
'
],
"
ts
"
:
event
.
origin_server_ts
,
"
sender_name
"
:
sender_name
,
...
...
@@ -225,13 +218,34 @@ class Mailer(object):
"
sender_hash
"
:
sender_hash
,
}
if
msgformat
==
"
org.matrix.custom.html
"
:
ret
[
"
body_text_html
"
]
=
safe_markup
(
event
.
content
[
"
formatted_body
"
])
if
event
.
content
[
"
msgtype
"
]
==
"
m.text
"
:
self
.
add_text_message_vars
(
ret
,
event
)
elif
event
.
content
[
"
msgtype
"
]
==
"
m.image
"
:
self
.
add_image_message_vars
(
ret
,
event
)
else
:
ret
[
"
body_text_html
"
]
=
safe_text
(
event
.
content
[
"
body
"
])
ret
urn
None
return
ret
def
add_text_message_vars
(
self
,
vars
,
event
):
if
"
format
"
in
event
.
content
:
msgformat
=
event
.
content
[
"
format
"
]
else
:
msgformat
=
None
vars
[
"
format
"
]
=
msgformat
if
msgformat
==
"
org.matrix.custom.html
"
:
vars
[
"
body_text_html
"
]
=
safe_markup
(
event
.
content
[
"
formatted_body
"
])
else
:
vars
[
"
body_text_html
"
]
=
safe_text
(
event
.
content
[
"
body
"
])
return
vars
def
add_image_message_vars
(
self
,
vars
,
event
):
vars
[
"
image_url
"
]
=
event
.
content
[
"
url
"
]
return
vars
def
make_summary_text
(
self
,
notifs_by_room
,
state_by_room
,
notif_events
,
user_id
):
if
len
(
notifs_by_room
)
==
1
:
# Only one room has new stuff
...
...
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