🐛 (notes): 想法按私密阅读设置发表并回读
新想法跟这本书的私密阅读走,修改已有想法沿用原来的可见范围。 回读对不上就当这轮失败,不把 HTTP 成功当成已经私密。
This commit is contained in:
1 parent
69a72f63c0
commit
352ee1bd99
11 files changed
+359
-57
No files matched your search
@@ -7,6 +7,7 @@ App 进度与时长走 App ``POST /book/read``;Web 在读状态用独立的网
|
||||
--]]
|
||||
|
||||
local Protocol = require("moonsource_weread.protocol")
|
||||
local Mapper = require("moonsource_weread.mapper")
|
||||
|
||||
local Context = {}
|
||||
|
||||
@@ -24,6 +25,8 @@ local readers = {}
|
||||
local sessions = {}
|
||||
---@type table<string, number>
|
||||
local book_version_by_id = {}
|
||||
---@type table<string, integer>
|
||||
local book_secret_by_id = {}
|
||||
|
||||
---@class WechatReportSession
|
||||
---@field psvts string
|
||||
@@ -88,17 +91,34 @@ function Context.rememberBookVersion(book_id, version)
|
||||
end
|
||||
end
|
||||
|
||||
--- 从书籍详情记下版本号和私密阅读。认不出的字段不覆盖已有值。
|
||||
---@param book_id string
|
||||
---@param wire table|nil
|
||||
function Context.rememberBook(book_id, wire)
|
||||
Context.rememberBookVersion(book_id, Mapper.bookVersion(wire))
|
||||
local secret = Mapper.bookSecret(wire)
|
||||
if secret ~= nil then book_secret_by_id[book_id] = secret end
|
||||
end
|
||||
|
||||
---@param book_id string
|
||||
---@return number|nil
|
||||
function Context.bookVersion(book_id)
|
||||
return book_version_by_id[book_id]
|
||||
end
|
||||
|
||||
--- 这本书是否私密阅读。没读过详情是 nil,不是公开。
|
||||
---@param book_id string
|
||||
---@return integer|nil
|
||||
function Context.bookSecret(book_id)
|
||||
return book_secret_by_id[book_id]
|
||||
end
|
||||
|
||||
--- 清空进程内缓存的 reader 状态与书籍版本号(换账号或登出后必须调)。
|
||||
function Context.clear()
|
||||
readers = {}
|
||||
sessions = {}
|
||||
book_version_by_id = {}
|
||||
book_secret_by_id = {}
|
||||
end
|
||||
|
||||
return Context
|
||||
Reference in new issue
Block a user