-
Notifications
You must be signed in to change notification settings - Fork 12
Implement handling of new cookie received from SU platform #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,51 +13,67 @@ | |||||||||||||
| from utils import GLOBAL_SSL_CONTEXT | ||||||||||||||
|
|
||||||||||||||
| if TYPE_CHECKING: | ||||||||||||||
| from collections.abc import Mapping, Sequence | ||||||||||||||
| from collections.abc import Mapping, MutableMapping, Sequence | ||||||||||||||
| from http.cookies import Morsel | ||||||||||||||
| from logging import Logger | ||||||||||||||
| from typing import Final | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| __all__: "Sequence[str]" = ( | ||||||||||||||
| "fetch_community_group_members_count", | ||||||||||||||
| "fetch_community_group_members_list", | ||||||||||||||
| "fetch_url_content_with_session", | ||||||||||||||
| "is_id_a_community_group_member", | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| logger: "Final[Logger]" = logging.getLogger("TeX-Bot") | ||||||||||||||
|
|
||||||||||||||
| SU_PLATFORM_ACCESS_COOKIE: "Final[str]" = settings["SU_PLATFORM_ACCESS_COOKIE"] | ||||||||||||||
|
|
||||||||||||||
| BASE_SU_PLATFORM_WEB_HEADERS: "Final[Mapping[str, str]]" = { | ||||||||||||||
| "Cache-Control": "no-cache", | ||||||||||||||
| "Pragma": "no-cache", | ||||||||||||||
| "Expires": "0", | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| BASE_SU_PLATFORM_WEB_COOKIES: "Final[Mapping[str, str]]" = { | ||||||||||||||
| ".AspNet.SharedCookie": settings["SU_PLATFORM_ACCESS_COOKIE"], | ||||||||||||||
| BASE_SU_PLATFORM_WEB_COOKIES: "Final[MutableMapping[str, str]]" = { | ||||||||||||||
|
||||||||||||||
| BASE_SU_PLATFORM_WEB_COOKIES: "Final[MutableMapping[str, str]]" = { | |
| BASE_SU_PLATFORM_WEB_COOKIES: "MutableMapping[str, str]" = { |
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 neither know nor care if this matters, the code runs fine - Matt up to you if you want this fixed
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 the correct annotation here is Mapping[str, str]. Then when you need to update the cookie, assign a new dict to BASE_SU_PLATFORM_WEB_COOKIES rather than just updating the key.
MattyTheHacker marked this conversation as resolved.
Show resolved
Hide resolved
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.
What is the need to use # type: ignore[type-arg] here?
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.
| returned_asp_cookie | |
| returned_asp_cookie is not None |
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.
| and returned_asp_cookie.value | |
| != BASE_SU_PLATFORM_WEB_COOKIES[".AspNet.SharedCookie"] | |
| and ( | |
| returned_asp_cookie.value | |
| != BASE_SU_PLATFORM_WEB_COOKIES[".AspNet.SharedCookie"] | |
| ) |
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.
| BASE_SU_PLATFORM_WEB_COOKIES[".AspNet.SharedCookie"] = returned_asp_cookie.value | |
| BASE_SU_PLATFORM_WEB_COOKIES = {".AspNet.SharedCookie": returned_asp_cookie.value} |
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.
settings["SU_PLATFORM_ACCESS_COOKIE"]can be used directly, rather than assigning to a variable first.