From 6b2096e200daa2fbf449462be4de8aa4a5b988cc Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 5 Mar 2021 19:20:15 +0100 Subject: [PATCH] [WARNING: CONFIG CHANGE] reorganize webhooks config --- app/anticaptcha/lib.py | 11 +++++++---- app/common/utils.py | 2 +- config/config.ini | 20 ++++++++++++++------ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/anticaptcha/lib.py b/app/anticaptcha/lib.py index 11fcf36..4d785ef 100644 --- a/app/anticaptcha/lib.py +++ b/app/anticaptcha/lib.py @@ -71,15 +71,18 @@ def check_captcha_or_raise(r): """, (nonce, r.url, captcha.action, captcha.sitekey, captcha.svalue, task_id, inputs)) conn.commit() - r2 = requests.post("https://api.capmonster.cloud/createTask", json={ - "clientKey": cf['captcha']['api_key'], + api_key = cf['captcha']['api_key'] + api_host = cf['captcha']['api_host'] + public_uri = cf['webhooks']['public_uri'] + r2 = requests.post(f"{api_host}/createTask", json={ + "clientKey": api_key, "task": { "type": "NoCaptchaTaskProxyless", "websiteURL": r.url, "websiteKey": captcha.sitekey, "recaptchaDataSValue": captcha.svalue, }, - "callbackUrl": f"{cf['captcha']['webhook_host']}/captcha_response/{nonce}", #XXX + "callbackUrl": f"{public_uri}/captcha_response/{nonce}", }) task_id = r2.json().get("taskId") c.execute(""" @@ -107,7 +110,7 @@ def solve_captcha(nonce, json_obj): solution = json_obj.get("solution", {}) inputs["g-recaptcha-response"] = solution.get("gRecaptchaResponse") - cookies = solution.get("cookies") + cookies = solution.get("cookies") # only set/used for "google.com domains and subdomains" # cookies aren't preserved in r.cookies when the redirect is followed(wtf!?), and we don't need that response anyways. r = requests.post(urljoin(url, action), cookies=cookies, data=inputs, allow_redirects=False) import pickle diff --git a/app/common/utils.py b/app/common/utils.py index ca34a1c..713a7f7 100755 --- a/app/common/utils.py +++ b/app/common/utils.py @@ -107,7 +107,7 @@ def update_subscriptions(verbose=1, force_all=False, limit=-1): update_feed(feed_id, feed_type, verbose) def update_feed(feed_id, feed_type, verbose): - webhook = cf['websub']['public_uri'] + webhook = cf['webhooks']['public_uri'] lease = cf['websub']['lease'] hmackey = cf['websub']['hmac_key'] diff --git a/config/config.ini b/config/config.ini index 2eaa112..139edb3 100644 --- a/config/config.ini +++ b/config/config.ini @@ -24,20 +24,28 @@ welcome_message =

Welcome to subscriptions.gir.st

# here (although it doesn't hurt). modules = browse,youtube,webhooks,reddit +[webhooks] +# public url of your webhook server without "/websub/v1/"... (this is probably +# the where you run your frontend, unless you run the 'webhooks' blueprint +# seperately; used for 'websub' and 'captcha' features): +public_uri = http://delta.gir.st:8801 + [websub] +# real-time updates of subscriptions. + # how long (in seconds) to request updates from websub-hub before having to # re-subscribe (5 * 24 * 60 * 60 = 5days, cargo-culted from invidious): lease = 432000 -# public url of your webhook server without "/websub/v1/"... (this is probably -# the where you run your frontend, unless you use a different server/port): -public_uri = http://delta.gir.st:8801 - # secret (7-bit ASCII) string to sign websub responses and urls (but may not be # empty): can be generated with `tr -dc '[:print:]'