mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Also for settings import - Don't send subscription activity to communities on dead instances
This commit is contained in:
parent
96cc0704e0
commit
1907c009b3
1 changed files with 12 additions and 8 deletions
|
@ -731,15 +731,19 @@ def import_settings_task(user_id, filename):
|
|||
# send ActivityPub message to remote community, asking to follow. Accept message will be sent to our shared inbox
|
||||
join_request = CommunityJoinRequest(user_id=user.id, community_id=community.id)
|
||||
db.session.add(join_request)
|
||||
member = CommunityMember(user_id=user.id, community_id=community.id)
|
||||
db.session.add(member)
|
||||
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, user.private_key,
|
||||
success = True
|
||||
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}"
|
||||
}
|
||||
success = post_request(community.ap_inbox_url, follow, user.private_key,
|
||||
user.public_url() + '#main-key')
|
||||
if not success:
|
||||
sleep(5) # give them a rest
|
||||
|
|
Loading…
Add table
Reference in a new issue