Commit 3629f12a authored by Pierre-antoine Comby's avatar Pierre-antoine Comby Committed by Benjamin Graillot

[gitlabissue] envoie la notification

parent 9dec16f1
......@@ -7,15 +7,43 @@ import source
app = Flask(__name__)
PAST = {
"open":"opened",
"close":"closed",
"reopen":"reopened"
}
@app.route('/',methods=['POST'])
def foo():
global PAST
try:
notif = request.data.decode('utf-8')
except:
notif = request.data
print(notif)
data = json.loads(notif)
print(data)
notif = json.loads(notif)
kind = notif["object_kind"]
event_type = notif["event_type"]
user = notif["user"]["name"]
repo = notif["project"]["name"]
url = notif["object_attributes"]["url"]
if kind == "issue":
issue = notif["object_attributes"]["title"]
action = PAST[notif["object_attributes"]["action"]]
elif kind == "note":
issue = notif["issue"]["title"]
action = "commented on"
else:
return "OK"
ret = "[\x0310{repo}\x03] \x033{user}\x03 {action} {issue}: {url}".format(
repo=repo,
user=user,
action=action,
issue=issue,
url=url
)
push_update = app.config['push_update']
push_update(repo, ret)
return "OK"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment