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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
7076eee4
Unverified
Commit
7076eee4
authored
4 years ago
by
Dirk Klimpel
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add type hints to purge room and server notice admin API. (#9520)
parent
cb7fc752
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
changelog.d/9520.misc
+1
-0
1 addition, 0 deletions
changelog.d/9520.misc
synapse/rest/admin/purge_room_servlet.py
+9
-6
9 additions, 6 deletions
synapse/rest/admin/purge_room_servlet.py
synapse/rest/admin/server_notice_servlet.py
+14
-9
14 additions, 9 deletions
synapse/rest/admin/server_notice_servlet.py
with
24 additions
and
15 deletions
changelog.d/9520.misc
0 → 100644
+
1
−
0
View file @
7076eee4
Add type hints to purge room and server notice admin API.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/rest/admin/purge_room_servlet.py
+
9
−
6
View file @
7076eee4
...
...
@@ -12,13 +12,20 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
typing
import
TYPE_CHECKING
,
Tuple
from
synapse.http.servlet
import
(
RestServlet
,
assert_params_in_dict
,
parse_json_object_from_request
,
)
from
synapse.http.site
import
SynapseRequest
from
synapse.rest.admin
import
assert_requester_is_admin
from
synapse.rest.admin._base
import
admin_patterns
from
synapse.types
import
JsonDict
if
TYPE_CHECKING
:
from
synapse.server
import
HomeServer
class
PurgeRoomServlet
(
RestServlet
):
...
...
@@ -36,16 +43,12 @@ class PurgeRoomServlet(RestServlet):
PATTERNS
=
admin_patterns
(
"
/purge_room$
"
)
def
__init__
(
self
,
hs
):
"""
Args:
hs (synapse.server.HomeServer): server
"""
def
__init__
(
self
,
hs
:
"
HomeServer
"
):
self
.
hs
=
hs
self
.
auth
=
hs
.
get_auth
()
self
.
pagination_handler
=
hs
.
get_pagination_handler
()
async
def
on_POST
(
self
,
request
)
:
async
def
on_POST
(
self
,
request
:
SynapseRequest
)
->
Tuple
[
int
,
JsonDict
]
:
await
assert_requester_is_admin
(
self
.
auth
,
request
)
body
=
parse_json_object_from_request
(
request
)
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/admin/server_notice_servlet.py
+
14
−
9
View file @
7076eee4
...
...
@@ -12,17 +12,24 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
typing
import
TYPE_CHECKING
,
Optional
,
Tuple
from
synapse.api.constants
import
EventTypes
from
synapse.api.errors
import
SynapseError
from
synapse.http.server
import
HttpServer
from
synapse.http.servlet
import
(
RestServlet
,
assert_params_in_dict
,
parse_json_object_from_request
,
)
from
synapse.http.site
import
SynapseRequest
from
synapse.rest.admin
import
assert_requester_is_admin
from
synapse.rest.admin._base
import
admin_patterns
from
synapse.rest.client.transactions
import
HttpTransactionCache
from
synapse.types
import
UserID
from
synapse.types
import
JsonDict
,
UserID
if
TYPE_CHECKING
:
from
synapse.server
import
HomeServer
class
SendServerNoticeServlet
(
RestServlet
):
...
...
@@ -44,17 +51,13 @@ class SendServerNoticeServlet(RestServlet):
}
"""
def
__init__
(
self
,
hs
):
"""
Args:
hs (synapse.server.HomeServer): server
"""
def
__init__
(
self
,
hs
:
"
HomeServer
"
):
self
.
hs
=
hs
self
.
auth
=
hs
.
get_auth
()
self
.
txns
=
HttpTransactionCache
(
hs
)
self
.
snm
=
hs
.
get_server_notices_manager
()
def
register
(
self
,
json_resource
):
def
register
(
self
,
json_resource
:
HttpServer
):
PATTERN
=
"
/send_server_notice
"
json_resource
.
register_paths
(
"
POST
"
,
admin_patterns
(
PATTERN
+
"
$
"
),
self
.
on_POST
,
self
.
__class__
.
__name__
...
...
@@ -66,7 +69,9 @@ class SendServerNoticeServlet(RestServlet):
self
.
__class__
.
__name__
,
)
async
def
on_POST
(
self
,
request
,
txn_id
=
None
):
async
def
on_POST
(
self
,
request
:
SynapseRequest
,
txn_id
:
Optional
[
str
]
=
None
)
->
Tuple
[
int
,
JsonDict
]:
await
assert_requester_is_admin
(
self
.
auth
,
request
)
body
=
parse_json_object_from_request
(
request
)
assert_params_in_dict
(
body
,
(
"
user_id
"
,
"
content
"
))
...
...
@@ -90,7 +95,7 @@ class SendServerNoticeServlet(RestServlet):
return
200
,
{
"
event_id
"
:
event
.
event_id
}
def
on_PUT
(
self
,
request
,
txn_id
)
:
def
on_PUT
(
self
,
request
:
SynapseRequest
,
txn_id
:
str
)
->
Tuple
[
int
,
JsonDict
]
:
return
self
.
txns
.
fetch_or_execute_request
(
request
,
self
.
on_POST
,
request
,
txn_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