mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 00:28:22 +00:00
Add more support for Webhook URL
This commit is contained in:
parent
06a886732c
commit
bc91c202a8
2 changed files with 8 additions and 4 deletions
|
@ -374,7 +374,7 @@ def api_validate_tracker_to_add(tracker , tracker_type, nb_words=1):
|
||||||
return ({"status": "error", "reason": "Incorrect type"}, 400)
|
return ({"status": "error", "reason": "Incorrect type"}, 400)
|
||||||
return ({"status": "success", "tracker": tracker, "type": tracker_type}, 200)
|
return ({"status": "success", "tracker": tracker, "type": tracker_type}, 200)
|
||||||
|
|
||||||
def create_tracker(tracker, tracker_type, user_id, level, tags, mails, description, dashboard=0, tracker_uuid=None, sources=[]):
|
def create_tracker(tracker, tracker_type, user_id, level, tags, mails, description, webhook, dashboard=0, tracker_uuid=None, sources=[]):
|
||||||
# edit tracker
|
# edit tracker
|
||||||
if tracker_uuid:
|
if tracker_uuid:
|
||||||
edit_tracker = True
|
edit_tracker = True
|
||||||
|
@ -415,6 +415,9 @@ def create_tracker(tracker, tracker_type, user_id, level, tags, mails, descripti
|
||||||
if description:
|
if description:
|
||||||
r_serv_tracker.hset('tracker:{}'.format(tracker_uuid), 'description', description)
|
r_serv_tracker.hset('tracker:{}'.format(tracker_uuid), 'description', description)
|
||||||
|
|
||||||
|
if webhook:
|
||||||
|
r_serv_tracker.hset('tracker:{}'.format(tracker_uuid), 'webhook', webhook)
|
||||||
|
|
||||||
# type change
|
# type change
|
||||||
if edit_tracker:
|
if edit_tracker:
|
||||||
r_serv_tracker.srem('all:tracker:{}'.format(old_type), old_tracker)
|
r_serv_tracker.srem('all:tracker:{}'.format(old_type), old_tracker)
|
||||||
|
@ -486,7 +489,8 @@ def api_add_tracker(dict_input, user_id):
|
||||||
nb_words = dict_input.get('nb_words', 1)
|
nb_words = dict_input.get('nb_words', 1)
|
||||||
description = dict_input.get('description', '')
|
description = dict_input.get('description', '')
|
||||||
description = escape(description)
|
description = escape(description)
|
||||||
|
webhook = dict_input.get('webhook', '')
|
||||||
|
webhook = escape(webhook)
|
||||||
res = api_validate_tracker_to_add(tracker , tracker_type, nb_words=nb_words)
|
res = api_validate_tracker_to_add(tracker , tracker_type, nb_words=nb_words)
|
||||||
if res[1]!=200:
|
if res[1]!=200:
|
||||||
return res
|
return res
|
||||||
|
@ -528,7 +532,7 @@ def api_add_tracker(dict_input, user_id):
|
||||||
if is_tracker_in_user_level(tracker, tracker_type, user_id) and not tracker_uuid:
|
if is_tracker_in_user_level(tracker, tracker_type, user_id) and not tracker_uuid:
|
||||||
return ({"status": "error", "reason": "Tracker already exist"}, 409)
|
return ({"status": "error", "reason": "Tracker already exist"}, 409)
|
||||||
|
|
||||||
tracker_uuid = create_tracker(tracker , tracker_type, user_id, level, tags, mails, description, tracker_uuid=tracker_uuid, sources=sources)
|
tracker_uuid = create_tracker(tracker , tracker_type, user_id, level, tags, mails, description, webhook, tracker_uuid=tracker_uuid, sources=sources)
|
||||||
|
|
||||||
return ({'tracker': tracker, 'type': tracker_type, 'uuid': tracker_uuid}, 200)
|
return ({'tracker': tracker, 'type': tracker_type, 'uuid': tracker_uuid}, 200)
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-2 mr-sm-2">
|
<div class="input-group mb-2 mr-sm-2">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<div class="input-group-text bg-secondary text-white"><i class="fas fa-at"></i></div>
|
<div class="input-group-text bg-info text-white"><i class="fas fa-anchor"></i></div>
|
||||||
</div>
|
</div>
|
||||||
<input id="webhook" name="webhook" class="form-control" placeholder="Webhook URL" type="text" {%if dict_tracker%}{%if dict_tracker['webhook']%}value="{{dict_tracker['webhook']}}"{%endif%}{%endif%}>
|
<input id="webhook" name="webhook" class="form-control" placeholder="Webhook URL" type="text" {%if dict_tracker%}{%if dict_tracker['webhook']%}value="{{dict_tracker['webhook']}}"{%endif%}{%endif%}>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue