add: webhook
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from events import PATH_CREATED_EVENT, path_created
|
||||
from events.WebhookEventHandlers import auto_instantiate
|
||||
from events.WebhookEventHandlers.PathWebhookEventHandlers import PathWebhookEventHandler
|
||||
from misc import Singleton
|
||||
|
||||
|
||||
@auto_instantiate
|
||||
class PathCreatedWebhookEventHandler(PathWebhookEventHandler,Singleton):
|
||||
|
||||
_instance = None
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if cls._instance is None:
|
||||
cls._instance = super(PathCreatedWebhookEventHandler, cls).__new__(cls)
|
||||
return cls._instance
|
||||
def __init__(self):
|
||||
if getattr(self, "_initialized", False):
|
||||
return
|
||||
super().__init__(PATH_CREATED_EVENT)
|
||||
path_created.connect(self)
|
||||
self._initialized = True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
from events import PATH_DELETED_EVENT, path_deleted
|
||||
from events.WebhookEventHandlers import auto_instantiate
|
||||
from events.WebhookEventHandlers.PathWebhookEventHandlers import PathWebhookEventHandler
|
||||
from misc import Singleton
|
||||
|
||||
|
||||
@auto_instantiate
|
||||
class PathDeletedWebhookEventHandler(PathWebhookEventHandler, Singleton):
|
||||
_instance = None
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if cls._instance is None:
|
||||
cls._instance = super(PathDeletedWebhookEventHandler, cls).__new__(cls)
|
||||
return cls._instance
|
||||
def __init__(self):
|
||||
if getattr(self, "_initialized", False):
|
||||
return
|
||||
super().__init__(PATH_DELETED_EVENT)
|
||||
path_deleted.connect(self)
|
||||
self._initialized = True
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from events import PATH_UPDATED_EVENT, path_updated
|
||||
from events.WebhookEventHandlers import auto_instantiate
|
||||
from events.WebhookEventHandlers.PathWebhookEventHandlers import PathWebhookEventHandler
|
||||
from misc import Singleton
|
||||
|
||||
|
||||
@auto_instantiate
|
||||
class PathUpdatedWebhookEventHandler(PathWebhookEventHandler, Singleton):
|
||||
|
||||
_instance = None
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if cls._instance is None:
|
||||
cls._instance = super(PathUpdatedWebhookEventHandler, cls).__new__(cls)
|
||||
return cls._instance
|
||||
def __init__(self):
|
||||
if getattr(self, "_initialized", False):
|
||||
return
|
||||
super().__init__(PATH_UPDATED_EVENT)
|
||||
path_updated.connect(self)
|
||||
self._initialized = True
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from events.WebhookEventHandlers import WebhookEventHandler
|
||||
|
||||
|
||||
class PathWebhookEventHandler(WebhookEventHandler):
|
||||
def __init__(self, event_type):
|
||||
super().__init__(event_type)
|
||||
|
||||
def get_path_id(self, payload):
|
||||
return payload["id"]
|
||||
Reference in New Issue
Block a user