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
cdd3cb87
Unverified
Commit
cdd3cb87
authored
5 years ago
by
Brendan Abolivier
Browse files
Options
Downloads
Patches
Plain Diff
Fix worker mode
parent
a6fc6754
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/data_stores/main/room.py
+56
-56
56 additions, 56 deletions
synapse/storage/data_stores/main/room.py
with
56 additions
and
56 deletions
synapse/storage/data_stores/main/room.py
+
56
−
56
View file @
cdd3cb87
...
@@ -303,6 +303,62 @@ class RoomWorkerStore(SQLBaseStore):
...
@@ -303,6 +303,62 @@ class RoomWorkerStore(SQLBaseStore):
else
:
else
:
return
None
return
None
@cachedInlineCallbacks
()
def
get_retention_policy_for_room
(
self
,
room_id
):
"""
Get the retention policy for a given room.
If no retention policy has been found for this room, returns a policy defined
by the configured default policy (which has None as both the
'
min_lifetime
'
and
the
'
max_lifetime
'
if no default policy has been defined in the server
'
s
configuration).
Args:
room_id (str): The ID of the room to get the retention policy of.
Returns:
dict[int, int]:
"
min_lifetime
"
and
"
max_lifetime
"
for this room.
"""
def
get_retention_policy_for_room_txn
(
txn
):
txn
.
execute
(
"""
SELECT min_lifetime, max_lifetime FROM room_retention
INNER JOIN current_state_events USING (event_id, room_id)
WHERE room_id = ?;
"""
,
(
room_id
,),
)
return
self
.
cursor_to_dict
(
txn
)
ret
=
yield
self
.
runInteraction
(
"
get_retention_policy_for_room
"
,
get_retention_policy_for_room_txn
,
)
# If we don't know this room ID, ret will be None, in this case return the default
# policy.
if
not
ret
:
defer
.
returnValue
(
{
"
min_lifetime
"
:
self
.
config
.
retention_default_min_lifetime
,
"
max_lifetime
"
:
self
.
config
.
retention_default_max_lifetime
,
}
)
row
=
ret
[
0
]
# If one of the room's policy's attributes isn't defined, use the matching
# attribute from the default policy.
# The default values will be None if no default policy has been defined, or if one
# of the attributes is missing from the default policy.
if
row
[
"
min_lifetime
"
]
is
None
:
row
[
"
min_lifetime
"
]
=
self
.
config
.
retention_default_min_lifetime
if
row
[
"
max_lifetime
"
]
is
None
:
row
[
"
max_lifetime
"
]
=
self
.
config
.
retention_default_max_lifetime
defer
.
returnValue
(
row
)
class
RoomStore
(
RoomWorkerStore
,
SearchStore
):
class
RoomStore
(
RoomWorkerStore
,
SearchStore
):
def
__init__
(
self
,
db_conn
,
hs
):
def
__init__
(
self
,
db_conn
,
hs
):
...
@@ -878,59 +934,3 @@ class RoomStore(RoomWorkerStore, SearchStore):
...
@@ -878,59 +934,3 @@ class RoomStore(RoomWorkerStore, SearchStore):
)
)
defer
.
returnValue
(
rooms
)
defer
.
returnValue
(
rooms
)
@cachedInlineCallbacks
()
def
get_retention_policy_for_room
(
self
,
room_id
):
"""
Get the retention policy for a given room.
If no retention policy has been found for this room, returns a policy defined
by the configured default policy (which has None as both the
'
min_lifetime
'
and
the
'
max_lifetime
'
if no default policy has been defined in the server
'
s
configuration).
Args:
room_id (str): The ID of the room to get the retention policy of.
Returns:
dict[int, int]:
"
min_lifetime
"
and
"
max_lifetime
"
for this room.
"""
def
get_retention_policy_for_room_txn
(
txn
):
txn
.
execute
(
"""
SELECT min_lifetime, max_lifetime FROM room_retention
INNER JOIN current_state_events USING (event_id, room_id)
WHERE room_id = ?;
"""
,
(
room_id
,),
)
return
self
.
cursor_to_dict
(
txn
)
ret
=
yield
self
.
runInteraction
(
"
get_retention_policy_for_room
"
,
get_retention_policy_for_room_txn
,
)
# If we don't know this room ID, ret will be None, in this case return the default
# policy.
if
not
ret
:
defer
.
returnValue
(
{
"
min_lifetime
"
:
self
.
config
.
retention_default_min_lifetime
,
"
max_lifetime
"
:
self
.
config
.
retention_default_max_lifetime
,
}
)
row
=
ret
[
0
]
# If one of the room's policy's attributes isn't defined, use the matching
# attribute from the default policy.
# The default values will be None if no default policy has been defined, or if one
# of the attributes is missing from the default policy.
if
row
[
"
min_lifetime
"
]
is
None
:
row
[
"
min_lifetime
"
]
=
self
.
config
.
retention_default_min_lifetime
if
row
[
"
max_lifetime
"
]
is
None
:
row
[
"
max_lifetime
"
]
=
self
.
config
.
retention_default_max_lifetime
defer
.
returnValue
(
row
)
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