kopia lustrzana https://gitlab.com/marnanel/chapeau
Only local accounts can receive Notifications. Closes issue #43.
As part of this, remove the previously undiscovered ability to send Accepts for remote users!status-serialisers
rodzic
d3c0663a96
commit
d2fda1e974
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.9 on 2020-10-11 14:39
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('trilby_api', '0024_localperson_featured'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='notification',
|
||||
name='for_account',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='notifications_for', to='trilby_api.LocalPerson'),
|
||||
),
|
||||
]
|
|
@ -40,7 +40,7 @@ class Notification(models.Model):
|
|||
)
|
||||
|
||||
for_account = models.ForeignKey(
|
||||
'Person',
|
||||
'LocalPerson',
|
||||
on_delete = models.DO_NOTHING,
|
||||
related_name = 'notifications_for',
|
||||
)
|
||||
|
|
|
@ -22,6 +22,10 @@ def on_follow(sender, **kwargs):
|
|||
|
||||
follow = sender # rename to prevent confusion below
|
||||
|
||||
if not follow.following.is_local:
|
||||
# we're only concerned with local accounts
|
||||
return
|
||||
|
||||
notification = kepi_models.Notification(
|
||||
notification_type = kepi_models.Notification.FOLLOW,
|
||||
for_account = follow.following,
|
||||
|
@ -62,6 +66,10 @@ def on_like(sender, **kwargs):
|
|||
|
||||
like = sender # rename to prevent confusion below
|
||||
|
||||
if not like.liked.account.is_local:
|
||||
# we're only concerned with local accounts
|
||||
return
|
||||
|
||||
notification = kepi_models.Notification(
|
||||
notification_type = kepi_models.Notification.FAVOURITE,
|
||||
for_account = like.liked.account,
|
||||
|
|
Ładowanie…
Reference in New Issue