mirror of
https://github.com/tubearchivist/tubearchivist-server.git
synced 2024-11-24 20:50:13 +00:00
store incoming hooks
This commit is contained in:
parent
f38d8a3594
commit
5b75a80ee1
@ -1,7 +1,9 @@
|
|||||||
"""parse and forward docker webhooks"""
|
"""parse and forward docker webhooks"""
|
||||||
|
|
||||||
import requests
|
import json
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import requests
|
||||||
from src.webhook_base import WebhookBase
|
from src.webhook_base import WebhookBase
|
||||||
|
|
||||||
|
|
||||||
@ -117,3 +119,10 @@ class DockerHook(WebhookBase):
|
|||||||
response = self._forward_message(message_data, url)
|
response = self._forward_message(message_data, url)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def save_hook(self):
|
||||||
|
"""save hook to disk for easy debugging"""
|
||||||
|
now = datetime.now().strftime("%s")
|
||||||
|
filename = f"/data/hooks/docker_hook-{now}.json"
|
||||||
|
with open(filename, "w", encoding="utf-8") as f:
|
||||||
|
f.write(json.dumps(self.hook))
|
||||||
|
@ -103,6 +103,13 @@ class GithubHook(WebhookBase):
|
|||||||
task.create_task("build_release")
|
task.create_task("build_release")
|
||||||
GithubBackup(tag_name).save_tag()
|
GithubBackup(tag_name).save_tag()
|
||||||
|
|
||||||
|
def save_hook(self):
|
||||||
|
"""save hook to disk for easy debugging"""
|
||||||
|
now = datetime.now().strftime("%s")
|
||||||
|
filename = f"/data/hooks/github_hook-{now}.json"
|
||||||
|
with open(filename, "w", encoding="utf-8") as f:
|
||||||
|
f.write(json.dumps(self.hook))
|
||||||
|
|
||||||
|
|
||||||
class GithubBackup:
|
class GithubBackup:
|
||||||
"""backup release and notes"""
|
"""backup release and notes"""
|
||||||
|
@ -37,6 +37,7 @@ def webhook_docker():
|
|||||||
|
|
||||||
print(request.json)
|
print(request.json)
|
||||||
message = handler.process()
|
message = handler.process()
|
||||||
|
handler.save_hook()
|
||||||
|
|
||||||
print(message, "hook sent to discord")
|
print(message, "hook sent to discord")
|
||||||
return jsonify(message)
|
return jsonify(message)
|
||||||
@ -53,5 +54,6 @@ def webhook_github():
|
|||||||
|
|
||||||
print(request.json)
|
print(request.json)
|
||||||
handler.create_hook_task()
|
handler.create_hook_task()
|
||||||
|
handler.save_hook()
|
||||||
message = {"success": True}
|
message = {"success": True}
|
||||||
return jsonify(message)
|
return jsonify(message)
|
||||||
|
Loading…
Reference in New Issue
Block a user