mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 23:20:49 +08:00
Compare commits
5 Commits
codex/fix-
...
codex/fix-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fbaa332fc | ||
|
|
4e6cb59753 | ||
|
|
1c6c17e577 | ||
|
|
c968efa42a | ||
|
|
0cd5ded39b |
@@ -74,7 +74,7 @@ class SearchClient:
|
|||||||
def _build_headers(
|
def _build_headers(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
token: str | None = None,
|
token: str,
|
||||||
accept: str = "application/json",
|
accept: str = "application/json",
|
||||||
include_json: bool = False,
|
include_json: bool = False,
|
||||||
) -> dict[str, str]:
|
) -> dict[str, str]:
|
||||||
@@ -111,9 +111,8 @@ class SearchClient:
|
|||||||
async def reply_to_comment(
|
async def reply_to_comment(
|
||||||
self,
|
self,
|
||||||
comment_id: int,
|
comment_id: int,
|
||||||
|
token: str,
|
||||||
content: str,
|
content: str,
|
||||||
*,
|
|
||||||
token: str | None = None,
|
|
||||||
captcha: str | None = None,
|
captcha: str | None = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Reply to an existing comment and return the created reply."""
|
"""Reply to an existing comment and return the created reply."""
|
||||||
@@ -145,9 +144,8 @@ class SearchClient:
|
|||||||
async def reply_to_post(
|
async def reply_to_post(
|
||||||
self,
|
self,
|
||||||
post_id: int,
|
post_id: int,
|
||||||
|
token: str,
|
||||||
content: str,
|
content: str,
|
||||||
*,
|
|
||||||
token: str | None = None,
|
|
||||||
captcha: str | None = None,
|
captcha: str | None = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Create a comment on a post and return the backend payload."""
|
"""Create a comment on a post and return the backend payload."""
|
||||||
@@ -180,7 +178,7 @@ class SearchClient:
|
|||||||
self,
|
self,
|
||||||
payload: dict[str, Any],
|
payload: dict[str, Any],
|
||||||
*,
|
*,
|
||||||
token: str | None = None,
|
token: str,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Create a new post and return the detailed backend payload."""
|
"""Create a new post and return the detailed backend payload."""
|
||||||
|
|
||||||
@@ -200,7 +198,7 @@ class SearchClient:
|
|||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
body = self._ensure_dict(response.json())
|
body = self._ensure_dict(response.json())
|
||||||
logger.info("Post creation succeeded with id=%s", body.get("id"))
|
logger.info("Post creation succeeded with id=%s, token=%s", body.get("id"), token)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
async def recent_posts(self, minutes: int) -> list[dict[str, Any]]:
|
async def recent_posts(self, minutes: int) -> list[dict[str, Any]]:
|
||||||
@@ -251,7 +249,7 @@ class SearchClient:
|
|||||||
*,
|
*,
|
||||||
page: int = 0,
|
page: int = 0,
|
||||||
size: int = 30,
|
size: int = 30,
|
||||||
token: str | None = None,
|
token: str,
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
"""Return unread notifications for the authenticated user."""
|
"""Return unread notifications for the authenticated user."""
|
||||||
|
|
||||||
@@ -287,7 +285,7 @@ class SearchClient:
|
|||||||
self,
|
self,
|
||||||
ids: list[int],
|
ids: list[int],
|
||||||
*,
|
*,
|
||||||
token: str | None = None,
|
token: str
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Mark the provided notifications as read for the authenticated user."""
|
"""Mark the provided notifications as read for the authenticated user."""
|
||||||
|
|
||||||
|
|||||||
@@ -509,6 +509,8 @@ async def create_post(
|
|||||||
raise ValueError("Category identifier must be an integer.") from exc
|
raise ValueError("Category identifier must be an integer.") from exc
|
||||||
if sanitized_category_id <= 0:
|
if sanitized_category_id <= 0:
|
||||||
raise ValueError("Category identifier must be a positive integer.")
|
raise ValueError("Category identifier must be a positive integer.")
|
||||||
|
if sanitized_category_id is None:
|
||||||
|
raise ValueError("A category identifier is required to create a post.")
|
||||||
|
|
||||||
sanitized_tag_ids: list[int] | None = None
|
sanitized_tag_ids: list[int] | None = None
|
||||||
if tag_ids is not None:
|
if tag_ids is not None:
|
||||||
@@ -525,6 +527,10 @@ async def create_post(
|
|||||||
sanitized_tag_ids.append(converted)
|
sanitized_tag_ids.append(converted)
|
||||||
if not sanitized_tag_ids:
|
if not sanitized_tag_ids:
|
||||||
sanitized_tag_ids = None
|
sanitized_tag_ids = None
|
||||||
|
if not sanitized_tag_ids:
|
||||||
|
raise ValueError("At least one tag identifier is required to create a post.")
|
||||||
|
if len(sanitized_tag_ids) > 2:
|
||||||
|
raise ValueError("At most two tag identifiers can be provided for a post.")
|
||||||
|
|
||||||
sanitized_post_type = post_type.strip() if isinstance(post_type, str) else None
|
sanitized_post_type = post_type.strip() if isinstance(post_type, str) else None
|
||||||
if sanitized_post_type == "":
|
if sanitized_post_type == "":
|
||||||
|
|||||||
Reference in New Issue
Block a user