Initial commit: Aurora Moments self-hosted photo/video sharing platform
Django/DRF + PostgreSQL/Redis/Celery backend with accounts, library, moments, and notifications apps; React/TypeScript/Vite frontend with Instagram-style sidebar nav, feed, profiles, nested comment replies, notifications, and photo/video upload with ffmpeg-generated posters. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
from apps.moments.models import Comment, Reaction
|
||||
|
||||
from .models import Notification
|
||||
|
||||
|
||||
@receiver(post_save, sender=Reaction)
|
||||
def notify_on_reaction(sender, instance, created, **kwargs):
|
||||
if not created:
|
||||
return
|
||||
moment = instance.moment
|
||||
if instance.user_id == moment.owner_id:
|
||||
return
|
||||
Notification.objects.create(
|
||||
recipient_id=moment.owner_id,
|
||||
actor=instance.user,
|
||||
verb=Notification.Verb.LIKE,
|
||||
moment=moment,
|
||||
)
|
||||
|
||||
|
||||
@receiver(post_save, sender=Comment)
|
||||
def notify_on_comment(sender, instance, created, **kwargs):
|
||||
if not created:
|
||||
return
|
||||
moment = instance.moment
|
||||
|
||||
if instance.parent_id is None:
|
||||
if instance.author_id != moment.owner_id:
|
||||
Notification.objects.create(
|
||||
recipient_id=moment.owner_id,
|
||||
actor=instance.author,
|
||||
verb=Notification.Verb.COMMENT,
|
||||
moment=moment,
|
||||
comment=instance,
|
||||
)
|
||||
return
|
||||
|
||||
parent_author_id = instance.parent.author_id
|
||||
if instance.author_id != parent_author_id:
|
||||
Notification.objects.create(
|
||||
recipient_id=parent_author_id,
|
||||
actor=instance.author,
|
||||
verb=Notification.Verb.REPLY,
|
||||
moment=moment,
|
||||
comment=instance,
|
||||
)
|
||||
Reference in New Issue
Block a user