mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-15 19:41:02 +08:00
Compare commits
11 Commits
codex/impr
...
codex/fix-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99c3ac1837 | ||
|
|
749ab560ff | ||
|
|
541ad4d149 | ||
|
|
03eb027ea4 | ||
|
|
4194b2be91 | ||
|
|
9dadaad5ba | ||
|
|
d4b3400c5f | ||
|
|
e585100625 | ||
|
|
e94471b53e | ||
|
|
997dacdbe6 | ||
|
|
c01349a436 |
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel, Field, ConfigDict
|
from pydantic import BaseModel, Field, ConfigDict, field_validator
|
||||||
|
|
||||||
|
|
||||||
class SearchResultItem(BaseModel):
|
class SearchResultItem(BaseModel):
|
||||||
@@ -170,6 +170,15 @@ class CommentData(BaseModel):
|
|||||||
|
|
||||||
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
||||||
|
|
||||||
|
@field_validator("replies", "reactions", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def _ensure_comment_lists(cls, value: Any) -> list[Any]:
|
||||||
|
"""Convert ``None`` payloads to empty lists for comment collections."""
|
||||||
|
|
||||||
|
if value is None:
|
||||||
|
return []
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class CommentReplyResult(BaseModel):
|
class CommentReplyResult(BaseModel):
|
||||||
"""Structured response returned when replying to a comment."""
|
"""Structured response returned when replying to a comment."""
|
||||||
@@ -253,6 +262,15 @@ class PostSummary(BaseModel):
|
|||||||
|
|
||||||
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
||||||
|
|
||||||
|
@field_validator("tags", "reactions", "participants", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def _ensure_post_lists(cls, value: Any) -> list[Any]:
|
||||||
|
"""Normalize ``None`` values returned by the backend to empty lists."""
|
||||||
|
|
||||||
|
if value is None:
|
||||||
|
return []
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class RecentPostsResponse(BaseModel):
|
class RecentPostsResponse(BaseModel):
|
||||||
"""Structured response for the recent posts tool."""
|
"""Structured response for the recent posts tool."""
|
||||||
@@ -278,6 +296,15 @@ class PostDetail(PostSummary):
|
|||||||
|
|
||||||
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
||||||
|
|
||||||
|
@field_validator("comments", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def _ensure_comments_list(cls, value: Any) -> list[Any]:
|
||||||
|
"""Treat ``None`` comments payloads as empty lists."""
|
||||||
|
|
||||||
|
if value is None:
|
||||||
|
return []
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class NotificationData(BaseModel):
|
class NotificationData(BaseModel):
|
||||||
"""Unread notification payload returned by the backend."""
|
"""Unread notification payload returned by the backend."""
|
||||||
|
|||||||
Reference in New Issue
Block a user