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
502ae6c6
Commit
502ae6c6
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Comment
parent
e6acf0c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/event_push_actions.py
+14
-7
14 additions, 7 deletions
synapse/storage/event_push_actions.py
with
14 additions
and
7 deletions
synapse/storage/event_push_actions.py
+
14
−
7
View file @
502ae6c6
...
...
@@ -26,30 +26,37 @@ import ujson as json
logger
=
logging
.
getLogger
(
__name__
)
DEFAULT_NOTIF_AC
I
TON
=
[
"
notify
"
,
{
"
set_tweak
"
:
"
highlight
"
,
"
value
"
:
False
}]
DEFAULT_HIGHLIGHT_AC
I
TON
=
[
DEFAULT_NOTIF_ACT
I
ON
=
[
"
notify
"
,
{
"
set_tweak
"
:
"
highlight
"
,
"
value
"
:
False
}]
DEFAULT_HIGHLIGHT_ACT
I
ON
=
[
"
notify
"
,
{
"
set_tweak
"
:
"
sound
"
,
"
value
"
:
"
default
"
},
{
"
set_tweak
"
:
"
highlight
"
}
]
def
_serialize_action
(
actions
,
is_highlight
):
"""
Custom serializer for actions. This allows us to
"
compress
"
common actions.
We use the fact that most users have the same actions for notifs (and for
highlights). We replaces these default actions with the emtpy string.
"""
if
is_highlight
:
if
actions
==
DEFAULT_HIGHLIGHT_AC
I
TON
:
return
""
if
actions
==
DEFAULT_HIGHLIGHT_ACT
I
ON
:
return
""
# We use empty string as the column is non-NULL
else
:
if
actions
==
DEFAULT_NOTIF_AC
I
TON
:
if
actions
==
DEFAULT_NOTIF_ACT
I
ON
:
return
""
return
json
.
dumps
(
actions
)
def
_deserialize_action
(
actions
,
is_highlight
):
"""
Custom deserializer for actions. This allows us to
"
compress
"
common actions
"""
if
actions
:
return
json
.
loads
(
actions
)
if
is_highlight
:
return
DEFAULT_HIGHLIGHT_AC
I
TON
return
DEFAULT_HIGHLIGHT_ACT
I
ON
else
:
return
DEFAULT_NOTIF_AC
I
TON
return
DEFAULT_NOTIF_ACT
I
ON
class
EventPushActionsStore
(
SQLBaseStore
):
...
...
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