diff --git a/app/community/routes.py b/app/community/routes.py index 81b49bbf..7e992725 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -499,15 +499,16 @@ def join_then_add(actor): join_request = CommunityJoinRequest(user_id=current_user.id, community_id=community.id) db.session.add(join_request) db.session.commit() - follow = { - "actor": current_user.public_url(), - "to": [community.public_url()], - "object": community.public_url(), - "type": "Follow", - "id": f"https://{current_app.config['SERVER_NAME']}/activities/follow/{join_request.id}" - } - success = post_request(community.ap_inbox_url, follow, current_user.private_key, - current_user.public_url() + '#main-key') + if not community.instance.gone_forever: + follow = { + "actor": current_user.public_url(), + "to": [community.public_url()], + "object": community.public_url(), + "type": "Follow", + "id": f"https://{current_app.config['SERVER_NAME']}/activities/follow/{join_request.id}" + } + post_request(community.ap_inbox_url, follow, current_user.private_key, + current_user.public_url() + '#main-key') member = CommunityMember(user_id=current_user.id, community_id=community.id) db.session.add(member) db.session.commit() diff --git a/app/topic/routes.py b/app/topic/routes.py index 17ec86fc..59dfeb11 100644 --- a/app/topic/routes.py +++ b/app/topic/routes.py @@ -305,12 +305,13 @@ def send_community_follow(community_id, join_request_id, user_id): with current_app.app_context(): user = User.query.get(user_id) community = Community.query.get(community_id) - follow = { - "actor": user.public_url(), - "to": [community.public_url()], - "object": community.public_url(), - "type": "Follow", - "id": f"https://{current_app.config['SERVER_NAME']}/activities/follow/{join_request_id}" - } - success = post_request(community.ap_inbox_url, follow, user.private_key, - user.public_url() + '#main-key') + if not community.instance.gone_forever: + follow = { + "actor": user.public_url(), + "to": [community.public_url()], + "object": community.public_url(), + "type": "Follow", + "id": f"https://{current_app.config['SERVER_NAME']}/activities/follow/{join_request_id}" + } + post_request(community.ap_inbox_url, follow, user.private_key, + user.public_url() + '#main-key')