Generate a notification for pending follow requests.

This commit is contained in:
Adam Kelly 2020-03-13 13:13:32 +00:00
parent ec45f8d565
commit 6b5644ed00
4 changed files with 10 additions and 3 deletions

View file

@ -229,9 +229,11 @@ def handle_incoming_follow(activity):
# Accept, but then do we need to match the activity id?
return HttpResponse()
create_notification(to_follow, 'FOLLOW', related_user=user)
if not to_follow.manually_approves_followers:
create_notification(to_follow, 'FOLLOW', related_user=user)
outgoing.handle_outgoing_accept(user, to_follow, activity)
else:
create_notification(to_follow, 'FOLLOW_REQUEST', related_user=user)
return HttpResponse()

View file

@ -107,7 +107,8 @@ class Notification(FedireadsModel):
'FAVORITE',
'REPLY',
'TAG',
'FOLLOW'
'FOLLOW',
'FOLLOW_REQUEST'
]
if not self.notification_type in types:
raise ValueError('Invalid notitication type')

View file

@ -25,6 +25,10 @@
{% elif notification.notification_type == 'FOLLOW' %}
{% include 'snippets/username.html' with user=notification.related_user %}
followed you
{% elif notification.notification_type == 'FOLLOW_REQUEST' %}
{% include 'snippets/username.html' with user=notification.related_user %}
sent you a follow request
{% endif %}
<small>{{ notification.created_date | naturaltime }}</small>
</p>

View file

@ -2,7 +2,7 @@ from fedireads.models import User
from fedireads.books_manager import get_or_create_book
User.objects.create_user('mouse', 'mouse.reeve@gmail.com', 'password123')
User.objects.create_user('rat', 'rat@rat.com', 'ratword')
User.objects.create_user('rat', 'rat@rat.com', 'ratword', manually_approves_followers=True)
User.objects.get(id=1).followers.add(User.objects.get(id=2))