diff --git a/.env b/.env new file mode 100644 index 0000000..87f6961 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +WEBHOOK='https://crm.svs-tech.pro/rest/38/7ufrqnfpncmt279p' \ No newline at end of file diff --git a/app/constants.py b/app/constants.py index 40c4966..73d4e8b 100644 --- a/app/constants.py +++ b/app/constants.py @@ -1,5 +1,5 @@ +import os import logging -import uuid from dotenv import load_dotenv load_dotenv() @@ -9,3 +9,5 @@ logging.basicConfig( ) logging.getLogger("httpx").setLevel(logging.WARNING) logger = logging.getLogger(__name__) + +WEBHOOK = os.getenv('WEBHOOK') \ No newline at end of file diff --git a/app/main.py b/app/main.py index b1f8811..0f855ab 100644 --- a/app/main.py +++ b/app/main.py @@ -2,7 +2,7 @@ import requests import json from fastapi import FastAPI, Request -from app.constants import logger +from app.constants import logger, WEBHOOK app = FastAPI() @@ -20,9 +20,6 @@ async def intgr(request: Request): [tag, number, *args] = branch.split("-") logger.info(f"input tag {tag} number {number} args {args}") - - if number == "test": - number = 423 bx_comment = ( f"Сообщение от GITEA для задачи {number} (ветка {body['ref']} в репозитории {body['repository']['full_name']})" @@ -31,7 +28,7 @@ async def intgr(request: Request): ) bx_res = requests.get( - "https://crm.svs-tech.pro/rest/38/7ufrqnfpncmt279p/task.commentitem.add.json?" + f"{WEBHOOK}/task.commentitem.add.json?" f"taskId={number}" f"&fields[POST_MESSAGE]={bx_comment}" )