[notifications] Send mood check-in

This commit is contained in:
2025-07-30 18:30:18 -04:00
parent ae889bff7d
commit c452ac24e0
10 changed files with 104 additions and 14 deletions

View File

@ -13,7 +13,7 @@ from django.utils import timezone
from profiles.models import UserProfile
from profiles.utils import now_user_timezone
from scrobbles.constants import LONG_PLAY_MEDIA
from scrobbles.notifications import NtfyNotification
from scrobbles.notifications import MoodNtfyNotification, ScrobbleNtfyNotification
from scrobbles.tasks import (
process_koreader_import,
process_lastfm_import,
@ -318,7 +318,20 @@ def send_stop_notifications_for_in_progress_scrobbles() -> int:
).seconds
if elapsed_scrobble_seconds > scrobble.media_obj.run_time_seconds:
NtfyNotification(scrobble, end=True).send()
ScrobbleNtfyNotification(scrobble, end=True).send()
notifications_sent += 1
return notifications_sent
def send_mood_checkin_reminders() -> int:
"""Get all profiles with mood check-ins enabled and checkin!"""
from profiles.models import UserProfile
now = timezone.now()
notifications_sent = 0
for profile in UserProfile.objects.filter(mood_checkin_enabled=True):
if profile.mood_checkin_period == "hourly" and now.minute == 0:
MoodNtfyNotification(profile).send()
notifications_sent += 1
return notifications_sent