🐛 (notes): 想法按私密阅读设置发表并回读

新想法跟这本书的私密阅读走,修改已有想法沿用原来的可见范围。
回读对不上就当这轮失败,不把 HTTP 成功当成已经私密。
This commit is contained in:
Garfield committed 2026-12-01 12:47:12 +08:00
1 parent 69a72f63c0
commit 352ee1bd99
11 files changed
+359 -57

No files matched your search

+43
View File
@@ -357,6 +357,49 @@ do
Assert.eq(review_body.abstract, "原文")
Assert.eq(review_body.range, "0-5")
Assert.eq(review_body.chapterUid, 9)
Assert.eq(review_body.isPrivate, 0, "非私密阅读的新想法明确公开")
local secret_body = Notes.toReviewBody("1", 9, {
note = "想法", text = "原文", wr_range = "0-5",
}, 1)
Assert.eq(secret_body.isPrivate, 1)
local kept = Notes.toReviewBody("1", 9, {
note = "想法", text = "原文", wr_range = "0-5", wr_private = 1,
}, 0)
Assert.eq(kept.isPrivate, 1, "条目自己的可见范围优先于书籍设置")
local edit_unknown = Notes.toReviewEditBody("1", 9, {
note = "想法", text = "原文", wr_range = "0-5", wr_review_id = "rv1",
}, 1)
Assert.is_nil(edit_unknown.isPrivate, "没记过可见范围的旧想法不能在修改时改成公开或私密")
local edit_private = Notes.toReviewEditBody("1", 9, {
note = "想法", text = "原文", wr_range = "0-5", wr_review_id = "rv1", wr_private = 1,
}, 0)
Assert.eq(edit_private.isPrivate, 1)
Assert.eq(edit_private.reviewId, "rv1")
local pulled_private = Notes.toAnnotations({ updated = {} }, "9", {
reviews = { { review = {
reviewId = "rv-p", chapterUid = "9", range = "0-1",
abstract = "原文", content = "私密", isPrivate = 1,
} } },
})
Assert.eq(pulled_private[1].wr_private, 1)
local reconciled = { note = "想法", text = "原文", wr_range = "0-5", wr_review_id = "rv1" }
Notes.reconcileReviews({ reconciled }, {
reviews = { { review = { reviewId = "rv1", isPrivate = 1, range = "0-5", abstract = "原文", content = "想法" } } },
})
Assert.eq(reconciled.wr_private, 1)
local pending_private = {
note = "想法", text = "原文", wr_range = "0-5", wr_review_id = "rv1", wr_private = 0,
}
Notes.reconcileReviews({ pending_private }, {
reviews = { { review = { reviewId = "rv1", isPrivate = 1 } } },
})
Assert.eq(pending_private.wr_private, 0, "本地已记下的可见范围不被列表覆盖")
Assert.eq(Mapper.bookSecret({ book = { bookId = "1", secret = 1 } }), 1)
Assert.eq(Mapper.bookSecret({ book = { bookId = "1", version = 3 } }), 0)
Assert.is_nil(Mapper.bookSecret({}))
Assert.eq(Notes.privateOf({ review = { isPrivate = 1 } }), 1)
Assert.eq(Notes.privateOf({ review = { isPrivate = 0 } }), 0)
Assert.is_nil(Notes.privateOf({ review = {} }))
local pending = {
text = "原文", note = "想法", wr_range = "0-5", wr_review_only = true,
}