Skip to content
Snippets Groups Projects
Commit 5a09bb16 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '276-fix-notification-system' into 'master'

Resolve "Fix notification system"

Closes #276

See merge request AlekSIS!280
parents 8f0bb96b 70c5a77b
No related branches found
No related tags found
1 merge request!280Resolve "Fix notification system"
Pipeline #2353 failed
import pytest
from aleksis.core.models import Notification, Person
pytestmark = pytest.mark.django_db
def test_email_notification(mailoutbox):
email = "doe@example.com"
recipient = Person.objects.create(first_name="Jane", last_name="Doe", email=email)
sender = "Foo"
title = "There is happened something."
description = "Here you get some more information."
link = "https://aleksis.org/"
notification = Notification(
sender=sender, recipient=recipient, title=title, description=description, link=link
)
notification.save()
assert notification.sent
assert len(mailoutbox) == 1
mail = mailoutbox[0]
assert email in mail.to
assert title in mail.body
assert description in mail.body
assert link in mail.body
assert sender in mail.body
assert recipient.addressing_name in mail.subject
assert recipient.addressing_name in mail.body
......@@ -73,13 +73,13 @@ def send_notification(notification: Union[int, "Notification"], resend: bool = F
If resend is passed as True, the notification is sent even if it was
previously marked as sent.
"""
channels = lazy_preference("notification", "channels")
if isinstance(notification, int):
notification = apps.get_model("core", "Notification")
notification_ = notification.objects.get(pk=notification)
Notification = apps.get_model("core", "Notification")
notification = Notification.objects.get(pk=notification)
channels = [notification.recipient.preferences["notification__channels"]]
if resend or not notification_.sent:
if resend or not notification.sent:
for channel in channels:
name, check, send = _CHANNELS_MAP[channel]
if check():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment