[notifications] Fix a few typos
This commit is contained in:
@ -3,6 +3,7 @@ import requests
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
class BasicNtfyNotification(ABC):
|
class BasicNtfyNotification(ABC):
|
||||||
ntfy_headers: dict = {}
|
ntfy_headers: dict = {}
|
||||||
@ -10,7 +11,7 @@ class BasicNtfyNotification(ABC):
|
|||||||
title: str = ""
|
title: str = ""
|
||||||
|
|
||||||
def __init__(self, profile: "UserProfile"):
|
def __init__(self, profile: "UserProfile"):
|
||||||
self.user = profile.user
|
self.profile = profile.user
|
||||||
protocol = "http" if settings.DEBUG else "https"
|
protocol = "http" if settings.DEBUG else "https"
|
||||||
domain = Site.objects.get_current().domain
|
domain = Site.objects.get_current().domain
|
||||||
self.url_tmpl = f'{protocol}://{domain}' + '{path}'
|
self.url_tmpl = f'{protocol}://{domain}' + '{path}'
|
||||||
@ -69,8 +70,7 @@ class ScrobbleNtfyNotification(ScrobbleNotification):
|
|||||||
|
|
||||||
class MoodNtfyNotification(BasicNtfyNotification):
|
class MoodNtfyNotification(BasicNtfyNotification):
|
||||||
def __init__(self, profile, **kwargs):
|
def __init__(self, profile, **kwargs):
|
||||||
super().__init__(scrobble)
|
super().__init__(profile)
|
||||||
self.profile = profile
|
|
||||||
self.ntfy_str: str = "Would you like to check in about your mood?"
|
self.ntfy_str: str = "Would you like to check in about your mood?"
|
||||||
self.click_url = self.url_tmpl.format(path=reverse("moods:mood-list"))
|
self.click_url = self.url_tmpl.format(path=reverse("moods:mood-list"))
|
||||||
self.title = "Mood Check-in!"
|
self.title = "Mood Check-in!"
|
||||||
@ -82,7 +82,7 @@ class MoodNtfyNotification(BasicNtfyNotification):
|
|||||||
and self.profile.ntfy_url
|
and self.profile.ntfy_url
|
||||||
):
|
):
|
||||||
requests.post(
|
requests.post(
|
||||||
self.user.profile.ntfy_url,
|
self.profile.ntfy_url,
|
||||||
data=self.ntfy_str.encode(encoding="utf-8"),
|
data=self.ntfy_str.encode(encoding="utf-8"),
|
||||||
headers={
|
headers={
|
||||||
"Title": self.title,
|
"Title": self.title,
|
||||||
|
|||||||
@ -330,7 +330,7 @@ def send_mood_checkin_reminders() -> int:
|
|||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
notifications_sent = 0
|
notifications_sent = 0
|
||||||
for profile in UserProfile.objects.filter(mood_checkin_enabled=True):
|
for profile in UserProfile.objects.filter(mood_checkin_enabled=True):
|
||||||
if profile.mood_checkin_period == "hourly" and now.minute == 0:
|
if profile.mood_checkin_frequency == "hourly" and now.minute == 0:
|
||||||
MoodNtfyNotification(profile).send()
|
MoodNtfyNotification(profile).send()
|
||||||
notifications_sent += 1
|
notifications_sent += 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user