2022-03-26 20:07:35 +00:00
|
|
|
const api = {};
|
|
|
|
|
|
|
|
/**************************************************************************************************/
|
|
|
|
api.feeds = {};
|
|
|
|
|
|
|
|
api.feeds.add_feed =
|
|
|
|
function add_feed(rss_url, title, isolate_guids, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/feeds/add",
|
|
|
|
data: {"rss_url": rss_url, "title": title, "isolate_guids": isolate_guids},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.delete =
|
|
|
|
function delete_feed(feed_id, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/delete`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.get_feeds =
|
|
|
|
function get_feeds(callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.get({
|
|
|
|
url: "/feeds.json",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.refresh =
|
|
|
|
function refresh(feed_id, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/refresh`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.refresh_all =
|
|
|
|
function refresh_all(callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/feeds/refresh_all",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_autorefresh_interval =
|
|
|
|
function set_autorefresh_interval(feed_id, interval, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_autorefresh_interval`,
|
|
|
|
data: {"autorefresh_interval": interval},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_filters =
|
|
|
|
function set_filters(feed_id, filter_ids, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_filters`,
|
|
|
|
data: {"filter_ids": filter_ids.join(",")},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_http_headers =
|
|
|
|
function set_http_headers(feed_id, http_headers, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_http_headers`,
|
|
|
|
data: {"http_headers": http_headers},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_icon =
|
|
|
|
function set_icon(feed_id, image_base64, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_icon`,
|
|
|
|
data: {"image_base64": image_base64},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_isolate_guids =
|
|
|
|
function set_isolate_guids(feed_id, isolate_guids, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_isolate_guids`,
|
|
|
|
data: {"isolate_guids": isolate_guids},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_parent =
|
|
|
|
function set_parent(feed_id, parent_id, ui_order_rank, callback)
|
|
|
|
{
|
2022-11-08 02:03:53 +00:00
|
|
|
data = {"parent_id": parent_id};
|
2022-03-26 20:07:35 +00:00
|
|
|
if (ui_order_rank !== null)
|
|
|
|
{
|
|
|
|
data["ui_order_rank"] = ui_order_rank;
|
|
|
|
}
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_parent`,
|
2022-11-08 02:03:53 +00:00
|
|
|
data: data,
|
2022-10-01 21:32:15 +00:00
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_refresh_with_others =
|
|
|
|
function set_refresh_with_others(feed_id, refresh_with_others, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_refresh_with_others`,
|
|
|
|
data: {"refresh_with_others": refresh_with_others},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_rss_url =
|
|
|
|
function set_rss_url(feed_id, rss_url, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_rss_url`,
|
|
|
|
data: {"rss_url": rss_url},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_web_url =
|
|
|
|
function set_web_url(feed_id, web_url, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_web_url`,
|
|
|
|
data: {"web_url": web_url},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_title =
|
|
|
|
function set_title(feed_id, title, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_title`,
|
|
|
|
data: {"title": title},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.feeds.set_ui_order_rank =
|
|
|
|
function set_ui_order_rank(feed_id, ui_order_rank, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/feed/${feed_id}/set_ui_order_rank`,
|
|
|
|
data: {"ui_order_rank": ui_order_rank},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************************************/
|
|
|
|
api.filters = {};
|
|
|
|
|
|
|
|
api.filters.add_filter =
|
|
|
|
function add_filter(name, conditions, actions, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: "/filters/add",
|
|
|
|
data: {"name": name, "conditions": conditions, "actions": actions},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.filters.delete_filter =
|
|
|
|
function delete_filter(filter_id, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/filter/${filter_id}/delete`,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.filters.get_filters =
|
|
|
|
function get_filters(callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.get({
|
|
|
|
url: "/filters.json",
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.filters.run_filter_now =
|
|
|
|
function run_filter_now(filter_id, feed_id, callback)
|
|
|
|
{
|
|
|
|
const data = {};
|
|
|
|
if (feed_id !== null)
|
|
|
|
{
|
|
|
|
data['feed_id'] = feed_id;
|
|
|
|
}
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/filter/${filter_id}/run_filter`,
|
|
|
|
data: data,
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.filters.set_actions =
|
|
|
|
function set_actions(filter_id, actions, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/filter/${filter_id}/set_actions`,
|
|
|
|
data: {"actions": actions},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.filters.set_conditions =
|
|
|
|
function set_conditions(filter_id, conditions, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/filter/${filter_id}/set_conditions`,
|
|
|
|
data: {"conditions": conditions},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.filters.set_name =
|
|
|
|
function set_name(filter_id, name, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/filter/${filter_id}/set_name`,
|
|
|
|
data: {"name": name},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.filters.update_filter =
|
|
|
|
function update_filter(filter_id, name, conditions, actions, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/filter/${filter_id}/update`,
|
|
|
|
data: {"name": name, "conditions": conditions, "actions": actions},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************************************/
|
|
|
|
api.news = {};
|
|
|
|
|
|
|
|
api.news.get_and_set_read =
|
|
|
|
function get_and_set_read(news_id, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/news/${news_id}.json`,
|
|
|
|
data: {"set_read": true},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.news.get_newss =
|
|
|
|
function get_newss(feed_id, read, recycled, callback)
|
|
|
|
{
|
|
|
|
let parameters = new URLSearchParams();
|
|
|
|
if (read !== null)
|
|
|
|
{
|
|
|
|
parameters.set("read", read);
|
|
|
|
}
|
|
|
|
if (recycled !== null)
|
|
|
|
{
|
|
|
|
parameters.set("recycled", recycled);
|
|
|
|
}
|
|
|
|
parameters = parameters.toString();
|
|
|
|
if (parameters !== "")
|
|
|
|
{
|
|
|
|
parameters = "?" + parameters;
|
|
|
|
}
|
|
|
|
let url = (feed_id === null) ? "/news.json" : `/feed/${feed_id}/news.json`;
|
|
|
|
url += parameters;
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.get({
|
|
|
|
url: url,
|
|
|
|
callback: callback, callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
api.news.set_read =
|
|
|
|
function set_read(news_id, read, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/news/${news_id}/set_read`,
|
|
|
|
data: {"read": read},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.news.set_recycled =
|
|
|
|
function set_recycled(news_id, recycled, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/news/${news_id}/set_recycled`,
|
|
|
|
data: {"recycled": recycled},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.news.batch_set_read =
|
|
|
|
function batch_set_read(news_ids, read, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/batch/news/set_read`,
|
|
|
|
data: {"news_ids": news_ids.join(","), "read": read},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
api.news.batch_set_recycled =
|
|
|
|
function batch_set_recycled(news_ids, recycled, callback)
|
|
|
|
{
|
2022-10-01 21:32:15 +00:00
|
|
|
return http.post({
|
|
|
|
url: `/batch/news/set_recycled`,
|
|
|
|
data: {"news_ids": news_ids.join(","), "recycled": recycled},
|
|
|
|
callback: callback,
|
|
|
|
});
|
2022-03-26 20:07:35 +00:00
|
|
|
}
|