1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
4 from django import forms
5 from django.contrib.sites.models import Site
7 from push.models import Notification
8 from push.utils import send_fcm_push
11 class NotificationForm(forms.ModelForm):
15 exclude = ('timestamp', 'message_id')
17 def save(self, commit=True):
18 notification = super(NotificationForm, self).save(commit=commit)
19 wl_base = 'https://' + Site.objects.get_current().domain
20 if notification.image:
21 image_url = wl_base + notification.image.url
24 notification.message_id = send_fcm_push(notification.title, notification.body, image_url)