mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Add endpoint for plugin subscription
This commit is contained in:
parent
3b19883dde
commit
259f6cb285
@ -75,7 +75,7 @@ struct SubscriptionList
|
|||||||
forward_missing_to @ary
|
forward_missing_to @ary
|
||||||
|
|
||||||
def initialize(@dir)
|
def initialize(@dir)
|
||||||
@path = Path[@dir, "subscriptions.json"]
|
@path = Path[@dir, "subscriptions.json"].to_s
|
||||||
if File.exists? @path
|
if File.exists? @path
|
||||||
@ary = Array(Subscription).from_json File.read @path
|
@ary = Array(Subscription).from_json File.read @path
|
||||||
end
|
end
|
||||||
|
@ -630,6 +630,30 @@ struct APIRouter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post "/api/admin/plugin/subscribe" do |env|
|
||||||
|
begin
|
||||||
|
plugin_id = env.params.json["plugin"].as String
|
||||||
|
filters = Array(Filter).from_json env.params.json["filters"].to_s
|
||||||
|
name = env.params.json["name"].as String
|
||||||
|
|
||||||
|
sub = Subscription.new plugin_id, name
|
||||||
|
sub.filters = filters
|
||||||
|
|
||||||
|
plugin = Plugin.new plugin_id
|
||||||
|
plugin.subscribe sub
|
||||||
|
|
||||||
|
send_json env, {
|
||||||
|
"success" => true,
|
||||||
|
}.to_json
|
||||||
|
rescue e
|
||||||
|
Logger.error e
|
||||||
|
send_json env, {
|
||||||
|
"success" => false,
|
||||||
|
"error" => e.message,
|
||||||
|
}.to_json
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Koa.describe "Lists the chapters in a title from a plugin"
|
Koa.describe "Lists the chapters in a title from a plugin"
|
||||||
Koa.tags ["admin", "downloader"]
|
Koa.tags ["admin", "downloader"]
|
||||||
Koa.query "plugin", schema: String
|
Koa.query "plugin", schema: String
|
||||||
|
Loading…
x
Reference in New Issue
Block a user