Trigger rebroadcast of follow requests

This commit is contained in:
Mouse Reeve 2022-03-24 11:25:42 -07:00
parent 88e915409b
commit a3b9c621af
2 changed files with 11 additions and 12 deletions

View file

@ -133,7 +133,9 @@ class UserFollowRequest(ActivitypubMixin, UserRelationship):
user_object=self.user_subject,
)
).exists():
raise IntegrityError()
raise IntegrityError(
"Attempting to follow blocked user", self.user_subject, self.user_object
)
super().save(*args, **kwargs)
if broadcast and self.user_subject.local and not self.user_object.local:

View file

@ -2,7 +2,6 @@
import urllib.parse
import re
from django.contrib.auth.decorators import login_required
from django.db import IntegrityError
from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.views.decorators.http import require_POST
@ -23,16 +22,14 @@ def follow(request):
username = request.POST["user"]
to_follow = get_user_from_username(request.user, username)
try:
models.UserFollowRequest.objects.create(
follow_request, created = models.UserFollowRequest.objects.get_or_create(
user_subject=request.user,
user_object=to_follow,
)
except IntegrityError:
pass
if request.GET.get("next"):
return redirect(request.GET.get("next", "/"))
if not created:
# this request probably failed to connect with the remote
# that means we should save to trigger a re-broadcast
follow_request.save()
return redirect(to_follow.local_path)