wallabag : fixes synchronization when "send review as tags" is checked (#8733)

In this PR https://github.com/koreader/koreader/pull/8637
It worked on my sev environnement, but when updating my device, there
were synchronization errors.

Apparently sometimes documents do not have a summary.
To avoid an error during the synchronisation this change adds checks
when getting tags for the document.
reviewable/pr8737/r1
Adrien Gallou 2 years ago committed by GitHub
parent b7a2a27590
commit 66afbf15f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -807,30 +807,31 @@ function Wallabag:addTags(path)
if id then
local docinfo = DocSettings:open(path)
local tags = docinfo.data.summary.note
if docinfo.data and docinfo.data.summary and docinfo.data.summary.note then
local tags = docinfo.data.summary.note
if tags ~= "" and tags ~= nil then
if tags ~= "" and tags ~= nil then
logger.dbg("Wallabag: sending tags ", tags, " for ", path)
logger.dbg("Wallabag: sending tags ", tags, " for ", path)
local body = {
tags = tags
}
local bodyJSON = JSON.encode(body)
local body = {
tags = tags,
}
local headers = {
["Content-type"] = "application/json",
["Accept"] = "application/json, */*",
["Content-Length"] = tostring(#bodyJSON),
["Authorization"] = "Bearer " .. self.access_token,
}
local bodyJSON = JSON.encode(body)
self:callAPI("POST", "/api/entries/" .. id .. "/tags.json", headers, bodyJSON, "")
else
logger.dbg("Wallabag: no tags to send for ", path)
end
local headers = {
["Content-type"] = "application/json",
["Accept"] = "application/json, */*",
["Content-Length"] = tostring(#bodyJSON),
["Authorization"] = "Bearer " .. self.access_token,
}
self:callAPI("POST", "/api/entries/" .. id .. "/tags.json", headers, bodyJSON, "")
else
logger.dbg("Wallabag: no tags to send for ", path)
end
end
end
end

Loading…
Cancel
Save