This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type hints to media rest resources. (#9093)
- Loading branch information
Showing
13 changed files
with
286 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add type hints to media repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Will Hunt <[email protected]> | ||
# Copyright 2020-2021 The Matrix.org Foundation C.I.C. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -14,22 +15,29 @@ | |
# limitations under the License. | ||
# | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from twisted.web.http import Request | ||
|
||
from synapse.http.server import DirectServeJsonResource, respond_with_json | ||
|
||
if TYPE_CHECKING: | ||
from synapse.app.homeserver import HomeServer | ||
|
||
|
||
class MediaConfigResource(DirectServeJsonResource): | ||
isLeaf = True | ||
|
||
def __init__(self, hs): | ||
def __init__(self, hs: "HomeServer"): | ||
super().__init__() | ||
config = hs.get_config() | ||
self.clock = hs.get_clock() | ||
self.auth = hs.get_auth() | ||
self.limits_dict = {"m.upload.size": config.max_upload_size} | ||
|
||
async def _async_render_GET(self, request): | ||
async def _async_render_GET(self, request: Request) -> None: | ||
await self.auth.get_user_by_req(request) | ||
respond_with_json(request, 200, self.limits_dict, send_cors=True) | ||
|
||
async def _async_render_OPTIONS(self, request): | ||
async def _async_render_OPTIONS(self, request: Request) -> None: | ||
respond_with_json(request, 200, {}, send_cors=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.