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
Convert Requester to attrs #9586
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ | ||
Convert `synapse.types.Requester` to an `attrs` class. |
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 |
---|---|---|
|
@@ -337,7 +337,8 @@ async def validate_user_via_ui_auth( | |
user is too high to proceed | ||
|
||
""" | ||
|
||
if not requester.access_token_id: | ||
raise ValueError("Cannot validate a user without an access token") | ||
if self._ui_auth_session_timeout: | ||
last_validated = await self.store.get_access_token_last_validated( | ||
requester.access_token_id | ||
|
@@ -1213,7 +1214,7 @@ async def delete_access_token(self, access_token: str): | |
async def delete_access_tokens_for_user( | ||
self, | ||
user_id: str, | ||
except_token_id: Optional[str] = None, | ||
except_token_id: Optional[int] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was an incorrect annotation. |
||
device_id: Optional[str] = None, | ||
): | ||
"""Invalidate access tokens belonging to a user | ||
|
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
from synapse.config._base import ConfigError | ||
from synapse.logging.context import defer_to_thread | ||
from synapse.metrics.background_process_metrics import run_as_background_process | ||
from synapse.types import UserID | ||
from synapse.util.async_helpers import Linearizer | ||
from synapse.util.retryutils import NotRetryingDestination | ||
from synapse.util.stringutils import random_string | ||
|
@@ -145,7 +146,7 @@ async def create_content( | |
upload_name: Optional[str], | ||
content: IO, | ||
content_length: int, | ||
auth_user: str, | ||
auth_user: UserID, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so was this |
||
) -> str: | ||
"""Store uploaded content for a local user and return the mxc URL | ||
|
||
|
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 |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
# limitations under the License. | ||
import logging | ||
import re | ||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple | ||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union | ||
|
||
import attr | ||
|
||
|
@@ -1510,7 +1510,7 @@ def f(txn): | |
async def user_delete_access_tokens( | ||
self, | ||
user_id: str, | ||
except_token_id: Optional[str] = None, | ||
except_token_id: Optional[int] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this |
||
device_id: Optional[str] = None, | ||
) -> List[Tuple[str, int, Optional[str]]]: | ||
""" | ||
|
@@ -1533,7 +1533,7 @@ def f(txn): | |
|
||
items = keyvalues.items() | ||
where_clause = " AND ".join(k + " = ?" for k, _ in items) | ||
values = [v for _, v in items] | ||
values = [v for _, v in items] # type: List[Union[str, int]] | ||
if except_token_id: | ||
where_clause += " AND id != ?" | ||
values.append(except_token_id) | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unreachable, but I had to add a check to keep mypy happy.