From 971186ef3a94b493a19525a8310942d0c0bd5339 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Mon, 9 Mar 2020 20:11:44 +0000 Subject: [PATCH 1/3] Add field manually_approves_followers to db. --- fedireads/forms.py | 2 +- .../0013_user_manually_approves_followers.py | 18 ++++++++++++++++++ fedireads/models/user.py | 1 + fedireads/view_actions.py | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 fedireads/migrations/0013_user_manually_approves_followers.py diff --git a/fedireads/forms.py b/fedireads/forms.py index 0dd5f4d67..34a7802b5 100644 --- a/fedireads/forms.py +++ b/fedireads/forms.py @@ -51,7 +51,7 @@ class CommentForm(ModelForm): class EditUserForm(ModelForm): class Meta: model = models.User - fields = ['avatar', 'name', 'summary'] + fields = ['avatar', 'name', 'summary', 'manually_approves_followers'] help_texts = {f: None for f in fields} diff --git a/fedireads/migrations/0013_user_manually_approves_followers.py b/fedireads/migrations/0013_user_manually_approves_followers.py new file mode 100644 index 000000000..c94aaed9e --- /dev/null +++ b/fedireads/migrations/0013_user_manually_approves_followers.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.3 on 2020-03-09 20:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fedireads', '0012_auto_20200308_1625'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='manually_approves_followers', + field=models.BooleanField(default=False), + ), + ] diff --git a/fedireads/models/user.py b/fedireads/models/user.py index 292a79062..23df60bed 100644 --- a/fedireads/models/user.py +++ b/fedireads/models/user.py @@ -50,6 +50,7 @@ class User(AbstractUser): ) created_date = models.DateTimeField(auto_now_add=True) updated_date = models.DateTimeField(auto_now=True) + manually_approves_followers = models.BooleanField(default=False) @property def absolute_id(self): diff --git a/fedireads/view_actions.py b/fedireads/view_actions.py index eb8e5f477..5aa2c8add 100644 --- a/fedireads/view_actions.py +++ b/fedireads/view_actions.py @@ -23,6 +23,7 @@ def edit_profile(request): if 'avatar' in form.files: request.user.avatar = form.files['avatar'] request.user.summary = form.data['summary'] + request.user.manually_approves_followers = form.cleaned_data['manually_approves_followers'] request.user.save() return redirect('/user/%s' % request.user.localname) From e1fa7a73cc33412ca9af9a3b6ca2783feb18a43c Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Mon, 9 Mar 2020 20:13:54 +0000 Subject: [PATCH 2/3] Don't automatically accept follows if the user doesn't want to. --- fedireads/incoming.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fedireads/incoming.py b/fedireads/incoming.py index 22a701e30..baaedd056 100644 --- a/fedireads/incoming.py +++ b/fedireads/incoming.py @@ -214,7 +214,8 @@ def handle_incoming_follow(activity): return HttpResponse() create_notification(to_follow, 'FOLLOW', related_user=user) - outgoing.handle_outgoing_accept(user, to_follow, activity) + if not to_follow.manually_approves_followers: + outgoing.handle_outgoing_accept(user, to_follow, activity) return HttpResponse() From 43500ec4780a92766b37a107e3c7274a0ba13a88 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Mon, 9 Mar 2020 21:27:45 +0000 Subject: [PATCH 3/3] Putting login_required on user_page breaks federation. The inbox can't verify the signature because it can't fetch the profile. --- fedireads/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fedireads/views.py b/fedireads/views.py index 17f183fae..c5b4c5656 100644 --- a/fedireads/views.py +++ b/fedireads/views.py @@ -150,7 +150,6 @@ def notifications_page(request): return TemplateResponse(request, 'notifications.html', data) -@login_required def user_page(request, username): ''' profile page for a user ''' content = request.headers.get('Accept')