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
8f1b385a
Unverified
Commit
8f1b385a
authored
5 years ago
by
Brendan Abolivier
Browse files
Options
Downloads
Patches
Plain Diff
Don't end up with 4 classes in registration
parent
21b5d8b1
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/storage/registration.py
+50
-52
50 additions, 52 deletions
synapse/storage/registration.py
with
50 additions
and
52 deletions
synapse/storage/registration.py
+
50
−
52
View file @
8f1b385a
...
@@ -37,57 +37,7 @@ THIRTY_MINUTES_IN_MS = 30 * 60 * 1000
...
@@ -37,57 +37,7 @@ THIRTY_MINUTES_IN_MS = 30 * 60 * 1000
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
class
RegistrationDeactivationStore
(
SQLBaseStore
):
class
RegistrationWorkerStore
(
SQLBaseStore
):
@cachedInlineCallbacks
()
def
get_user_deactivated_status
(
self
,
user_id
):
"""
Retrieve the value for the `deactivated` property for the provided user.
Args:
user_id (str): The ID of the user to retrieve the status for.
Returns:
defer.Deferred(bool): The requested value.
"""
res
=
yield
self
.
_simple_select_one_onecol
(
table
=
"
users
"
,
keyvalues
=
{
"
name
"
:
user_id
},
retcol
=
"
deactivated
"
,
desc
=
"
get_user_deactivated_status
"
,
)
# Convert the integer into a boolean.
return
res
==
1
@defer.inlineCallbacks
def
set_user_deactivated_status
(
self
,
user_id
,
deactivated
):
"""
Set the `deactivated` property for the provided user to the provided value.
Args:
user_id (str): The ID of the user to set the status for.
deactivated (bool): The value to set for `deactivated`.
"""
yield
self
.
runInteraction
(
"
set_user_deactivated_status
"
,
self
.
set_user_deactivated_status_txn
,
user_id
,
deactivated
,
)
def
set_user_deactivated_status_txn
(
self
,
txn
,
user_id
,
deactivated
):
self
.
_simple_update_one_txn
(
txn
=
txn
,
table
=
"
users
"
,
keyvalues
=
{
"
name
"
:
user_id
},
updatevalues
=
{
"
deactivated
"
:
1
if
deactivated
else
0
},
)
self
.
_invalidate_cache_and_stream
(
txn
,
self
.
get_user_deactivated_status
,
(
user_id
,)
)
class
RegistrationWorkerStore
(
RegistrationDeactivationStore
):
def
__init__
(
self
,
db_conn
,
hs
):
def
__init__
(
self
,
db_conn
,
hs
):
super
(
RegistrationWorkerStore
,
self
).
__init__
(
db_conn
,
hs
)
super
(
RegistrationWorkerStore
,
self
).
__init__
(
db_conn
,
hs
)
...
@@ -723,6 +673,27 @@ class RegistrationWorkerStore(RegistrationDeactivationStore):
...
@@ -723,6 +673,27 @@ class RegistrationWorkerStore(RegistrationDeactivationStore):
desc
=
"
get_id_servers_user_bound
"
,
desc
=
"
get_id_servers_user_bound
"
,
)
)
@cachedInlineCallbacks
()
def
get_user_deactivated_status
(
self
,
user_id
):
"""
Retrieve the value for the `deactivated` property for the provided user.
Args:
user_id (str): The ID of the user to retrieve the status for.
Returns:
defer.Deferred(bool): The requested value.
"""
res
=
yield
self
.
_simple_select_one_onecol
(
table
=
"
users
"
,
keyvalues
=
{
"
name
"
:
user_id
},
retcol
=
"
deactivated
"
,
desc
=
"
get_user_deactivated_status
"
,
)
# Convert the integer into a boolean.
return
res
==
1
def
get_threepid_validation_session
(
def
get_threepid_validation_session
(
self
,
medium
,
client_secret
,
address
=
None
,
sid
=
None
,
validated
=
True
self
,
medium
,
client_secret
,
address
=
None
,
sid
=
None
,
validated
=
True
):
):
...
@@ -817,7 +788,7 @@ class RegistrationWorkerStore(RegistrationDeactivationStore):
...
@@ -817,7 +788,7 @@ class RegistrationWorkerStore(RegistrationDeactivationStore):
class
RegistrationBackgroundUpdateStore
(
class
RegistrationBackgroundUpdateStore
(
Registration
Deactivation
Store
,
background_updates
.
BackgroundUpdateStore
Registration
Worker
Store
,
background_updates
.
BackgroundUpdateStore
):
):
def
__init__
(
self
,
db_conn
,
hs
):
def
__init__
(
self
,
db_conn
,
hs
):
super
(
RegistrationBackgroundUpdateStore
,
self
).
__init__
(
db_conn
,
hs
)
super
(
RegistrationBackgroundUpdateStore
,
self
).
__init__
(
db_conn
,
hs
)
...
@@ -1499,3 +1470,30 @@ class RegistrationStore(RegistrationWorkerStore, RegistrationBackgroundUpdateSto
...
@@ -1499,3 +1470,30 @@ class RegistrationStore(RegistrationWorkerStore, RegistrationBackgroundUpdateSto
cull_expired_threepid_validation_tokens_txn
,
cull_expired_threepid_validation_tokens_txn
,
self
.
clock
.
time_msec
(),
self
.
clock
.
time_msec
(),
)
)
@defer.inlineCallbacks
def
set_user_deactivated_status
(
self
,
user_id
,
deactivated
):
"""
Set the `deactivated` property for the provided user to the provided value.
Args:
user_id (str): The ID of the user to set the status for.
deactivated (bool): The value to set for `deactivated`.
"""
yield
self
.
runInteraction
(
"
set_user_deactivated_status
"
,
self
.
set_user_deactivated_status_txn
,
user_id
,
deactivated
,
)
def
set_user_deactivated_status_txn
(
self
,
txn
,
user_id
,
deactivated
):
self
.
_simple_update_one_txn
(
txn
=
txn
,
table
=
"
users
"
,
keyvalues
=
{
"
name
"
:
user_id
},
updatevalues
=
{
"
deactivated
"
:
1
if
deactivated
else
0
},
)
self
.
_invalidate_cache_and_stream
(
txn
,
self
.
get_user_deactivated_status
,
(
user_id
,)
)
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