[feat] plugins/wallabag: addArticle() method (#4852)

Currently unused, but a prerequisite for dynamically adding links to Wallabag.
This commit is contained in:
Frans de Jonge
2019-03-29 18:10:44 +01:00
committed by GitHub
parent db5bd8884d
commit 76fd9228d3

View File

@@ -526,6 +526,29 @@ function Wallabag:processLocalFiles( mode )
return num_deleted
end
function Wallabag:addArticle(article_url)
logger.dbg("Wallabag: adding article ", article_url)
if not article_url or self:getBearerToken() == false then
return false
end
local body = {
url = article_url,
}
local body_JSON = JSON.encode(body)
local headers = {
["Content-type"] = "application/json",
["Accept"] = "application/json, */*",
["Content-Length"] = tostring(#body_JSON),
["Authorization"] = "Bearer " .. self.access_token,
}
self:callAPI("POST", "/api/entries.json", headers, body_JSON, "")
end
function Wallabag:deleteArticle( path )
logger.dbg("Wallabag: deleting article ", path )
local id = self:getArticleID( path )