A couple more for - Don't send subscription activity to communities on dead instances

This commit is contained in:
freamon 2024-08-21 13:50:11 +00:00
parent 5a02eb9ba0
commit 20a818de00
2 changed files with 20 additions and 18 deletions

View file

@ -499,6 +499,7 @@ 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()
if not community.instance.gone_forever:
follow = {
"actor": current_user.public_url(),
"to": [community.public_url()],
@ -506,7 +507,7 @@ def join_then_add(actor):
"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,
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)

View file

@ -305,6 +305,7 @@ 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)
if not community.instance.gone_forever:
follow = {
"actor": user.public_url(),
"to": [community.public_url()],
@ -312,5 +313,5 @@ def send_community_follow(community_id, join_request_id, user_id):
"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,
post_request(community.ap_inbox_url, follow, user.private_key,
user.public_url() + '#main-key')