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,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()

View file

@ -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')