|
@@ -3,6 +3,7 @@ import requests
|
|
|
|
|
|
from django.conf import settings
|
|
|
from django.contrib.sites.models import Site
|
|
|
+from django.urls import reverse
|
|
|
|
|
|
class BasicNtfyNotification(ABC):
|
|
|
ntfy_headers: dict = {}
|
|
@@ -10,7 +11,7 @@ class BasicNtfyNotification(ABC):
|
|
|
title: str = ""
|
|
|
|
|
|
def __init__(self, profile: "UserProfile"):
|
|
|
- self.user = profile.user
|
|
|
+ self.profile = profile.user
|
|
|
protocol = "http" if settings.DEBUG else "https"
|
|
|
domain = Site.objects.get_current().domain
|
|
|
self.url_tmpl = f'{protocol}://{domain}' + '{path}'
|
|
@@ -69,8 +70,7 @@ class ScrobbleNtfyNotification(ScrobbleNotification):
|
|
|
|
|
|
class MoodNtfyNotification(BasicNtfyNotification):
|
|
|
def __init__(self, profile, **kwargs):
|
|
|
- super().__init__(scrobble)
|
|
|
- self.profile = profile
|
|
|
+ super().__init__(profile)
|
|
|
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.title = "Mood Check-in!"
|
|
@@ -82,7 +82,7 @@ class MoodNtfyNotification(BasicNtfyNotification):
|
|
|
and self.profile.ntfy_url
|
|
|
):
|
|
|
requests.post(
|
|
|
- self.user.profile.ntfy_url,
|
|
|
+ self.profile.ntfy_url,
|
|
|
data=self.ntfy_str.encode(encoding="utf-8"),
|
|
|
headers={
|
|
|
"Title": self.title,
|