From 6c4d0d217fa9b864bb10a65db2ef178f9b698af4 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:40:47 +1300 Subject: [PATCH] minor bugfixes --- app/activitypub/routes.py | 10 ++++++---- app/cli.py | 1 + app/models.py | 2 ++ app/user/routes.py | 5 ++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index c051ee51..239b416a 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -722,10 +722,12 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): if user and community: join_request = CommunityJoinRequest.query.filter_by(user_id=user.id, community_id=community.id).first() if join_request: - member = CommunityMember(user_id=user.id, community_id=community.id) - db.session.add(member) - community.subscriptions_count += 1 - db.session.commit() + existing_membership = CommunityMember.query.filter_by(user_id=user.id, community_id=community.id).first() + if not existing_membership: + member = CommunityMember(user_id=user.id, community_id=community.id) + db.session.add(member) + community.subscriptions_count += 1 + db.session.commit() activity_log.result = 'success' cache.delete_memoized(community_membership, user, community) diff --git a/app/cli.py b/app/cli.py index d37646cc..5847d6b2 100644 --- a/app/cli.py +++ b/app/cli.py @@ -120,6 +120,7 @@ def register(app): if block_list: for domain in block_list.split('\n'): db.session.add(Domain(name=domain.strip(), banned=True)) + db.session.add(Domain(name='anonib.al', banned=True)) # Initial roles anon_role = Role(name='Anonymous user', weight=0) diff --git a/app/models.py b/app/models.py index 0bbdf1da..8d4cc870 100644 --- a/app/models.py +++ b/app/models.py @@ -207,6 +207,8 @@ class File(db.Model): os.unlink(self.file_path) if self.thumbnail_path and os.path.isfile(self.thumbnail_path): os.unlink(self.thumbnail_path) + if self.source_url and not self.source_url.startswith('http') and os.path.isfile(self.source_url): + os.unlink(self.source_url) def filesize(self): size = 0 diff --git a/app/user/routes.py b/app/user/routes.py index 091d2338..cbd00cf6 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -25,7 +25,10 @@ import os @bp.route('/people', methods=['GET', 'POST']) @login_required def show_people(): - people = User.query.filter_by(ap_id=None, deleted=False, banned=False).all() + if current_user.is_admin(): + people = User.query.filter_by(ap_id=None, deleted=False, banned=False).all() + else: + people = User.query.filter_by(ap_id=None, deleted=False, banned=False, searchable=True).all() return render_template('user/people.html', people=people, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), title=_('People'))