Feed parser: Changed behaviour to use RR id for tracking chapters instead of using the extraced chapter number (which was dumb anyway)
Build & Publish to GHCR / build (push) Successful in 23s

This commit is contained in:
florian committed 2025-10-30 09:26:20 +01:00
1 parent 18904abcec
commit eda004626a
3 files changed
+17 -22

No files matched your search

+5 -5
View File
@@ -12,13 +12,13 @@ api_key= return_credentials("/etc/secrets/api_key")
logger = setup_logger(__name__)
def send_notification(title: str,chapter: int,link: str,max_retries: int = 5,timeout: int = 5):
def send_notification(title: str, chapter_title: str,link: str,max_retries: int = 5,timeout: int = 5):
"""
Sends a notification to the internal backend service when a new Royalroad chapter is released.
Parameters:
title: Name of the story.
chapter: Latest chapter number.
chapter_title: Title of the chapter.
link: Direct link to the new chapter.
"""
@@ -31,14 +31,14 @@ def send_notification(title: str,chapter: int,link: str,max_retries: int = 5,tim
"receipent_user_id": 1,
"message": {
"title": title,
"body": f"Chapter {chapter} has been released",
"body": chapter_title,
"link": link,
"category":"royal-road",
"timestamp": int(time.time())
}
}
logger.debug(f"[Notify] Preparing to send notification: title='{title}', chapter={chapter}, link='{link}'")
logger.debug(f"[Notify] Preparing to send notification: title='{title}', chapter={chapter_title}, link='{link}'")
with requests.Session() as session:
for attempt in range(1, max_retries + 1):
@@ -46,7 +46,7 @@ def send_notification(title: str,chapter: int,link: str,max_retries: int = 5,tim
logger.debug(f"[Notify] Sending request to backend (attempt {attempt}/{max_retries})")
response = session.post(backend_api_url, headers=headers, json=data, timeout=timeout)
response.raise_for_status()
logger.info(f"[Notify] Notification sent successfully for '{title}' (chapter {chapter})")
logger.info(f"[Notify] Notification sent successfully for '{title}' (chapter {chapter_title})")
return response.text
except (Timeout, ConnectionError) as e: