This repository has been archived by the owner on Dec 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
616122f
commit cb9d373
Showing
1 changed file
with
11 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
import asyncio | ||
import json | ||
from contextlib import asynccontextmanager | ||
from datetime import UTC, datetime | ||
|
||
from beanie import init_beanie | ||
from fastapi import FastAPI | ||
|
@@ -53,16 +52,16 @@ async def push_notification(): | |
for notification in notifications: | ||
sent_notification_number = len(notification.event_dates) | ||
for start_date in notification.event_dates: | ||
days_before = None | ||
if (start_date - datetime.now(UTC)).days == 30: | ||
days_before = 30 | ||
elif (start_date - datetime.now(UTC)).days == 7: | ||
days_before = 7 | ||
elif (start_date - datetime.now(UTC)).days == 1: | ||
days_before = 1 | ||
sent_notification_number -= 1 | ||
elif (start_date - datetime.now(UTC)).days < 0: | ||
sent_notification_number -= 1 | ||
days_before = 4 | ||
# if (start_date - datetime.now(UTC)).days == 30: | ||
# days_before = 30 | ||
# elif (start_date - datetime.now(UTC)).days == 7: | ||
# days_before = 7 | ||
# elif (start_date - datetime.now(UTC)).days == 1: | ||
# days_before = 1 | ||
# sent_notification_number -= 1 | ||
# elif (start_date - datetime.now(UTC)).days < 0: | ||
# sent_notification_number -= 1 | ||
if days_before is not None: | ||
outMsg: str | ||
if notification.sport_id is not None: | ||
|
@@ -72,7 +71,7 @@ async def push_notification(): | |
try: | ||
webpush( | ||
subscription_info=notification.subscription_info, | ||
data=json.dumps({"title": "Напоминание", "body": outMsg}), | ||
data=json.dumps({"message": outMsg}), | ||
vapid_private_key=VAPID_PRIVATE_KEY, | ||
vapid_claims={"sub": "mailto:[email protected]"}, | ||
) | ||
|