Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fbb3f05dba | |||
| 83fa9f8e1f | |||
| f6cb85b54b | |||
| e9a21a45d3 |
13
build/Dockerfile
Normal file
13
build/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
# 작업 디렉토리 설정
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 의존성 파일 복사 및 설치
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# 소스 코드 복사
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD ["python", "run.py"]
|
||||||
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
services:
|
||||||
|
mattermost-noti:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: build/Dockerfile
|
||||||
|
image: reg.firstgarden.co.kr/mattermost-noti:latest
|
||||||
|
container_name: mattermost-noti
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- NOTION_API_SECRET=${NOTION_API_SECRET}
|
||||||
|
- NOTION_WEBHOOK_SECRET=${NOTION_WEBHOOK_SECRET}
|
||||||
|
- MATTERMOST_WEBHOOK_URL=${MATTERMOST_WEBHOOK_URL}
|
||||||
|
- MATTERMOST_BOT_TOKEN=${MATTERMOST_BOT_TOKEN}
|
||||||
|
- MATTERMOST_CH_ID=${MATTERMOST_CH_ID}
|
||||||
|
- DEBUG=${DEBUG:-false}
|
||||||
|
- LOG_LEVEL=${LOG_LEVEL:-INFO}
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
volumes:
|
||||||
|
- ./logs:/app/logs
|
||||||
@ -15,14 +15,6 @@ class Config:
|
|||||||
NOTION_API_BASE = "https://api.notion.com/v1"
|
NOTION_API_BASE = "https://api.notion.com/v1"
|
||||||
NOTION_VERSION = "2022-06-28"
|
NOTION_VERSION = "2022-06-28"
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_notion_headers(cls):
|
|
||||||
return {
|
|
||||||
"Authorization": f"Bearer {cls.NOTION_API_SECRET}",
|
|
||||||
"Notion-Version": cls.NOTION_VERSION,
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 웹훅 서명 검증용 비밀키 (옵션)
|
# 웹훅 서명 검증용 비밀키 (옵션)
|
||||||
NOTION_WEBHOOK_SECRET = os.getenv('NOTION_WEBHOOK_SECRET', None)
|
NOTION_WEBHOOK_SECRET = os.getenv('NOTION_WEBHOOK_SECRET', None)
|
||||||
|
|
||||||
|
|||||||
@ -10,11 +10,17 @@ from datetime import datetime
|
|||||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||||
|
|
||||||
from lib.config import Config
|
from lib.config import Config
|
||||||
|
HEADERS = {
|
||||||
|
"Authorization": f"Bearer {Config.NOTION_API_SECRET}",
|
||||||
|
"Notion-Version": Config.NOTION_VERSION,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
from lib.common import EVENT_TYPE_LABELS
|
from lib.common import EVENT_TYPE_LABELS
|
||||||
|
|
||||||
def get_page_details(page_id: str) -> Optional[Dict]:
|
def get_page_details(page_id: str) -> Optional[Dict]:
|
||||||
url = f"{Config.NOTION_API_BASE}/pages/{page_id}"
|
url = f"{Config.NOTION_API_BASE}/pages/{page_id}"
|
||||||
response = requests.get(url, headers=Config.HEADERS)
|
response = requests.get(url, headers=HEADERS)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
return response.json()
|
return response.json()
|
||||||
@ -157,7 +163,7 @@ def fetch_entity_detail(entity_type: str, entity_id: str) -> Optional[Dict]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, headers=Config.HEADERS, timeout=5)
|
response = requests.get(url, headers=HEADERS, timeout=5)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
flask>=2.2.0
|
flask>=2.2.0
|
||||||
requests>=2.31.0
|
requests>=2.31.0
|
||||||
python-dotenv>=1.0.0
|
python-dotenv>=1.0.0
|
||||||
|
urllib3>=1.26.0
|
||||||
Reference in New Issue
Block a user