mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-17 06:48:36 +02:00
Revert "Mark some API properties as nonnull"
This reverts commit 834294ecac.
Defer JSON API to v1.102
This commit is contained in:
@@ -316,10 +316,13 @@ components:
|
||||
nullable: true
|
||||
voted:
|
||||
type: boolean
|
||||
nullable: true
|
||||
bookmarked:
|
||||
type: boolean
|
||||
nullable: true
|
||||
ignored:
|
||||
type: boolean
|
||||
nullable: true
|
||||
official:
|
||||
type: boolean
|
||||
tags:
|
||||
@@ -387,8 +390,10 @@ components:
|
||||
nullable: true
|
||||
voted:
|
||||
type: boolean
|
||||
nullable: true
|
||||
bookmarked:
|
||||
type: boolean
|
||||
nullable: true
|
||||
depth:
|
||||
type: integer
|
||||
children:
|
||||
|
||||
@@ -142,7 +142,7 @@ class TopicQuery(PaginatedQuery):
|
||||
topic.bookmark_created_time = None
|
||||
topic.last_visit_time = None
|
||||
topic.comments_since_last_visit = None
|
||||
topic.user_bookmarked = False
|
||||
topic.user_bookmarked = None
|
||||
topic.user_ignored = False
|
||||
else:
|
||||
topic = result.Topic
|
||||
|
||||
@@ -60,7 +60,8 @@ def get_topics(request: Request) -> dict: # noqa
|
||||
|
||||
# Parse parameters where necessary
|
||||
try:
|
||||
period = ShortTimePeriod(allow_none=True).deserialize(period_raw)
|
||||
period = ShortTimePeriod(allow_none=True)
|
||||
period = period.deserialize(period_raw)
|
||||
except ValidationError as exc:
|
||||
return build_error_response(str(exc), field="period")
|
||||
|
||||
@@ -127,10 +128,11 @@ def get_topic(request: Request) -> dict:
|
||||
f"Invalid order value: {comment_order_raw}",
|
||||
field="order",
|
||||
)
|
||||
elif request.user and request.user.comment_sort_order_default:
|
||||
comment_order = request.user.comment_sort_order_default
|
||||
else:
|
||||
comment_order = CommentTreeSortOption.RELEVANCE
|
||||
if request.user and request.user.comment_sort_order_default:
|
||||
comment_order = request.user.comment_sort_order_default
|
||||
else:
|
||||
comment_order = CommentTreeSortOption.RELEVANCE
|
||||
|
||||
try:
|
||||
topic_id = id36_to_id(topic_id36)
|
||||
@@ -155,17 +157,15 @@ def get_topic(request: Request) -> dict:
|
||||
tree = CommentTree(comments, comment_order, request.user)
|
||||
tree.collapse_from_labels()
|
||||
|
||||
# collapse old comments if the user has a previous visit to the topic
|
||||
# (and doesn't have that behavior disabled)
|
||||
if request.user and topic.last_visit_time and request.user.collapse_old_comments:
|
||||
tree.uncollapse_new_comments(topic.last_visit_time)
|
||||
tree.finalize_collapsing_maximized()
|
||||
if request.user:
|
||||
# collapse old comments if the user has a previous visit to the topic
|
||||
# (and doesn't have that behavior disabled)
|
||||
if topic.last_visit_time and request.user.collapse_old_comments:
|
||||
tree.uncollapse_new_comments(topic.last_visit_time)
|
||||
tree.finalize_collapsing_maximized()
|
||||
|
||||
commentsjson = comment_subtree_to_dict(request, tree.tree)
|
||||
|
||||
# Construct the final response JSON object
|
||||
response = {
|
||||
"topic": topic_to_dict(topic),
|
||||
"comments": commentsjson,
|
||||
}
|
||||
response = {"topic": topic_to_dict(topic), "comments": commentsjson}
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user