mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
local only communities - do not federate
This commit is contained in:
parent
5b66fea4fe
commit
04a4abe9d5
4 changed files with 436 additions and 416 deletions
|
@ -589,39 +589,43 @@ def process_inbox_request(request_json, activitypublog_id, ip_address):
|
||||||
follow_id = request_json['id']
|
follow_id = request_json['id']
|
||||||
user = find_actor_or_create(user_ap_id)
|
user = find_actor_or_create(user_ap_id)
|
||||||
community = find_actor_or_create(community_ap_id)
|
community = find_actor_or_create(community_ap_id)
|
||||||
if user is not None and community is not None:
|
if community and community.local_only:
|
||||||
# check if user is banned from this community
|
# todo: send Deny activity
|
||||||
banned = CommunityBan.query.filter_by(user_id=user.id, community_id=community.id).first()
|
activity_log.exception_message = 'Local only cannot be followed by remote users'
|
||||||
if banned is None:
|
else:
|
||||||
user.last_seen = utcnow()
|
if user is not None and community is not None:
|
||||||
if community_membership(user, community) != SUBSCRIPTION_MEMBER:
|
# check if user is banned from this community
|
||||||
member = CommunityMember(user_id=user.id, community_id=community.id)
|
banned = CommunityBan.query.filter_by(user_id=user.id, community_id=community.id).first()
|
||||||
db.session.add(member)
|
if banned is None:
|
||||||
db.session.commit()
|
user.last_seen = utcnow()
|
||||||
cache.delete_memoized(community_membership, user, community)
|
if community_membership(user, community) != SUBSCRIPTION_MEMBER:
|
||||||
# send accept message to acknowledge the follow
|
member = CommunityMember(user_id=user.id, community_id=community.id)
|
||||||
accept = {
|
db.session.add(member)
|
||||||
"@context": default_context(),
|
db.session.commit()
|
||||||
"actor": community.ap_profile_id,
|
cache.delete_memoized(community_membership, user, community)
|
||||||
"to": [
|
# send accept message to acknowledge the follow
|
||||||
user.ap_profile_id
|
accept = {
|
||||||
],
|
"@context": default_context(),
|
||||||
"object": {
|
"actor": community.ap_profile_id,
|
||||||
"actor": user.ap_profile_id,
|
"to": [
|
||||||
"to": None,
|
user.ap_profile_id
|
||||||
"object": community.ap_profile_id,
|
],
|
||||||
"type": "Follow",
|
"object": {
|
||||||
"id": follow_id
|
"actor": user.ap_profile_id,
|
||||||
},
|
"to": None,
|
||||||
"type": "Accept",
|
"object": community.ap_profile_id,
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/accept/" + gibberish(32)
|
"type": "Follow",
|
||||||
}
|
"id": follow_id
|
||||||
if post_request(user.ap_inbox_url, accept, community.private_key, f"https://{current_app.config['SERVER_NAME']}/c/{community.name}#main-key"):
|
},
|
||||||
activity_log.result = 'success'
|
"type": "Accept",
|
||||||
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/accept/" + gibberish(32)
|
||||||
|
}
|
||||||
|
if post_request(user.ap_inbox_url, accept, community.private_key, f"https://{current_app.config['SERVER_NAME']}/c/{community.name}#main-key"):
|
||||||
|
activity_log.result = 'success'
|
||||||
|
else:
|
||||||
|
activity_log.exception_message = 'Error sending Accept'
|
||||||
else:
|
else:
|
||||||
activity_log.exception_message = 'Error sending Accept'
|
activity_log.exception_message = 'user is banned from this community'
|
||||||
else:
|
|
||||||
activity_log.exception_message = 'user is banned from this community'
|
|
||||||
# Accept: remote server is accepting our previous follow request
|
# Accept: remote server is accepting our previous follow request
|
||||||
elif request_json['type'] == 'Accept':
|
elif request_json['type'] == 'Accept':
|
||||||
if request_json['object']['type'] == 'Follow':
|
if request_json['object']['type'] == 'Follow':
|
||||||
|
|
|
@ -917,6 +917,10 @@ def delete_post_or_comment_task(user_ap_id, community_ap_id, to_be_deleted_ap_id
|
||||||
|
|
||||||
|
|
||||||
def create_post_reply(activity_log: ActivityPubLog, community: Community, in_reply_to, request_json: dict, user: User, announce_id=None) -> Union[Post, None]:
|
def create_post_reply(activity_log: ActivityPubLog, community: Community, in_reply_to, request_json: dict, user: User, announce_id=None) -> Union[Post, None]:
|
||||||
|
if community.local_only:
|
||||||
|
activity_log.exception_message = 'Community is local only, reply discarded'
|
||||||
|
activity_log.result = 'ignored'
|
||||||
|
return None
|
||||||
post_id, parent_comment_id, root_id = find_reply_parent(in_reply_to)
|
post_id, parent_comment_id, root_id = find_reply_parent(in_reply_to)
|
||||||
if post_id or parent_comment_id or root_id:
|
if post_id or parent_comment_id or root_id:
|
||||||
# set depth to +1 of the parent depth
|
# set depth to +1 of the parent depth
|
||||||
|
@ -1006,6 +1010,10 @@ def create_post_reply(activity_log: ActivityPubLog, community: Community, in_rep
|
||||||
|
|
||||||
|
|
||||||
def create_post(activity_log: ActivityPubLog, community: Community, request_json: dict, user: User, announce_id=None) -> Union[Post, None]:
|
def create_post(activity_log: ActivityPubLog, community: Community, request_json: dict, user: User, announce_id=None) -> Union[Post, None]:
|
||||||
|
if community.local_only:
|
||||||
|
activity_log.exception_message = 'Community is local only, post discarded'
|
||||||
|
activity_log.result = 'ignored'
|
||||||
|
return None
|
||||||
post = Post(user_id=user.id, community_id=community.id,
|
post = Post(user_id=user.id, community_id=community.id,
|
||||||
title=html.unescape(request_json['object']['name']),
|
title=html.unescape(request_json['object']['name']),
|
||||||
comments_enabled=request_json['object']['commentsEnabled'],
|
comments_enabled=request_json['object']['commentsEnabled'],
|
||||||
|
|
|
@ -376,87 +376,88 @@ def add_post(actor):
|
||||||
|
|
||||||
notify_about_post(post)
|
notify_about_post(post)
|
||||||
|
|
||||||
page = {
|
if not community.local_only:
|
||||||
'type': 'Page',
|
page = {
|
||||||
'id': post.ap_id,
|
'type': 'Page',
|
||||||
'attributedTo': current_user.ap_profile_id,
|
'id': post.ap_id,
|
||||||
'to': [
|
'attributedTo': current_user.ap_profile_id,
|
||||||
community.ap_profile_id,
|
'to': [
|
||||||
'https://www.w3.org/ns/activitystreams#Public'
|
community.ap_profile_id,
|
||||||
],
|
'https://www.w3.org/ns/activitystreams#Public'
|
||||||
'name': post.title,
|
],
|
||||||
'cc': [],
|
'name': post.title,
|
||||||
'content': post.body_html if post.body_html else '',
|
'cc': [],
|
||||||
'mediaType': 'text/html',
|
'content': post.body_html if post.body_html else '',
|
||||||
'source': {
|
'mediaType': 'text/html',
|
||||||
'content': post.body if post.body else '',
|
'source': {
|
||||||
'mediaType': 'text/markdown'
|
'content': post.body if post.body else '',
|
||||||
},
|
'mediaType': 'text/markdown'
|
||||||
'attachment': [],
|
},
|
||||||
'commentsEnabled': post.comments_enabled,
|
'attachment': [],
|
||||||
'sensitive': post.nsfw,
|
'commentsEnabled': post.comments_enabled,
|
||||||
'nsfl': post.nsfl,
|
'sensitive': post.nsfw,
|
||||||
'published': ap_datetime(utcnow()),
|
'nsfl': post.nsfl,
|
||||||
'audience': community.ap_profile_id
|
'published': ap_datetime(utcnow()),
|
||||||
}
|
'audience': community.ap_profile_id
|
||||||
create = {
|
}
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/create/{gibberish(15)}",
|
create = {
|
||||||
"actor": current_user.ap_profile_id,
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/create/{gibberish(15)}",
|
||||||
"to": [
|
"actor": current_user.ap_profile_id,
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
|
||||||
"cc": [
|
|
||||||
community.ap_profile_id
|
|
||||||
],
|
|
||||||
"type": "Create",
|
|
||||||
"audience": community.ap_profile_id,
|
|
||||||
"object": page,
|
|
||||||
'@context': default_context()
|
|
||||||
}
|
|
||||||
if post.type == POST_TYPE_LINK:
|
|
||||||
page['attachment'] = [{'href': post.url, 'type': 'Link'}]
|
|
||||||
elif post.image_id:
|
|
||||||
if post.image.file_path:
|
|
||||||
image_url = post.image.file_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
|
||||||
elif post.image.thumbnail_path:
|
|
||||||
image_url = post.image.thumbnail_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
|
||||||
else:
|
|
||||||
image_url = post.image.source_url
|
|
||||||
# NB image is a dict while attachment is a list of dicts (usually just one dict in the list)
|
|
||||||
page['image'] = {'type': 'Image', 'url': image_url}
|
|
||||||
if post.type == POST_TYPE_IMAGE:
|
|
||||||
page['attachment'] = [{'type': 'Link', 'href': post.image.source_url}] # source_url is always a https link, no need for .replace() as done above
|
|
||||||
if not community.is_local(): # this is a remote community - send the post to the instance that hosts it
|
|
||||||
success = post_request(community.ap_inbox_url, create, current_user.private_key,
|
|
||||||
current_user.ap_profile_id + '#main-key')
|
|
||||||
if success:
|
|
||||||
flash(_('Your post to %(name)s has been made.', name=community.title))
|
|
||||||
else:
|
|
||||||
flash('There was a problem making your post to ' + community.title)
|
|
||||||
else: # local community - send (announce) post out to followers
|
|
||||||
announce = {
|
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
|
||||||
"type": 'Announce',
|
|
||||||
"to": [
|
"to": [
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
],
|
],
|
||||||
"actor": community.ap_profile_id,
|
|
||||||
"cc": [
|
"cc": [
|
||||||
community.ap_followers_url
|
community.ap_profile_id
|
||||||
],
|
],
|
||||||
'@context': default_context(),
|
"type": "Create",
|
||||||
'object': create
|
"audience": community.ap_profile_id,
|
||||||
|
"object": page,
|
||||||
|
'@context': default_context()
|
||||||
}
|
}
|
||||||
|
if post.type == POST_TYPE_LINK:
|
||||||
|
page['attachment'] = [{'href': post.url, 'type': 'Link'}]
|
||||||
|
elif post.image_id:
|
||||||
|
if post.image.file_path:
|
||||||
|
image_url = post.image.file_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
||||||
|
elif post.image.thumbnail_path:
|
||||||
|
image_url = post.image.thumbnail_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
||||||
|
else:
|
||||||
|
image_url = post.image.source_url
|
||||||
|
# NB image is a dict while attachment is a list of dicts (usually just one dict in the list)
|
||||||
|
page['image'] = {'type': 'Image', 'url': image_url}
|
||||||
|
if post.type == POST_TYPE_IMAGE:
|
||||||
|
page['attachment'] = [{'type': 'Link', 'href': post.image.source_url}] # source_url is always a https link, no need for .replace() as done above
|
||||||
|
if not community.is_local(): # this is a remote community - send the post to the instance that hosts it
|
||||||
|
success = post_request(community.ap_inbox_url, create, current_user.private_key,
|
||||||
|
current_user.ap_profile_id + '#main-key')
|
||||||
|
if success:
|
||||||
|
flash(_('Your post to %(name)s has been made.', name=community.title))
|
||||||
|
else:
|
||||||
|
flash('There was a problem making your post to ' + community.title)
|
||||||
|
else: # local community - send (announce) post out to followers
|
||||||
|
announce = {
|
||||||
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
|
"type": 'Announce',
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"actor": community.ap_profile_id,
|
||||||
|
"cc": [
|
||||||
|
community.ap_followers_url
|
||||||
|
],
|
||||||
|
'@context': default_context(),
|
||||||
|
'object': create
|
||||||
|
}
|
||||||
|
|
||||||
sent_to = 0
|
sent_to = 0
|
||||||
for instance in community.following_instances():
|
for instance in community.following_instances():
|
||||||
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
||||||
send_to_remote_instance(instance.id, community.id, announce)
|
send_to_remote_instance(instance.id, community.id, announce)
|
||||||
sent_to += 1
|
sent_to += 1
|
||||||
if sent_to:
|
if sent_to:
|
||||||
flash(_('Your post to %(name)s has been made.', name=community.title))
|
flash(_('Your post to %(name)s has been made.', name=community.title))
|
||||||
else:
|
else:
|
||||||
flash(_('Your post to %(name)s has been made.', name=community.title))
|
flash(_('Your post to %(name)s has been made.', name=community.title))
|
||||||
|
|
||||||
return redirect(f"/c/{community.link()}")
|
return redirect(f"/c/{community.link()}")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -232,36 +232,37 @@ def post_vote(post_id: int, vote_direction):
|
||||||
post.author.reputation += effect
|
post.author.reputation += effect
|
||||||
db.session.add(vote)
|
db.session.add(vote)
|
||||||
|
|
||||||
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
if not post.community.local_only:
|
||||||
action_json = {
|
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
||||||
'actor': current_user.profile_id(),
|
action_json = {
|
||||||
'object': post.profile_id(),
|
'actor': current_user.profile_id(),
|
||||||
'type': action_type,
|
'object': post.profile_id(),
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
'type': action_type,
|
||||||
'audience': post.community.profile_id()
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
||||||
}
|
'audience': post.community.profile_id()
|
||||||
if post.community.is_local():
|
|
||||||
announce = {
|
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
|
||||||
"type": 'Announce',
|
|
||||||
"to": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
|
||||||
"actor": post.community.ap_profile_id,
|
|
||||||
"cc": [
|
|
||||||
post.community.ap_followers_url
|
|
||||||
],
|
|
||||||
'@context': default_context(),
|
|
||||||
'object': action_json
|
|
||||||
}
|
}
|
||||||
for instance in post.community.following_instances():
|
if post.community.is_local():
|
||||||
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
announce = {
|
||||||
send_to_remote_instance(instance.id, post.community.id, announce)
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
else:
|
"type": 'Announce',
|
||||||
success = post_request(post.community.ap_inbox_url, action_json, current_user.private_key,
|
"to": [
|
||||||
current_user.ap_profile_id + '#main-key')
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
if not success:
|
],
|
||||||
flash('Failed to send vote', 'warning')
|
"actor": post.community.ap_profile_id,
|
||||||
|
"cc": [
|
||||||
|
post.community.ap_followers_url
|
||||||
|
],
|
||||||
|
'@context': default_context(),
|
||||||
|
'object': action_json
|
||||||
|
}
|
||||||
|
for instance in post.community.following_instances():
|
||||||
|
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
||||||
|
send_to_remote_instance(instance.id, post.community.id, announce)
|
||||||
|
else:
|
||||||
|
success = post_request(post.community.ap_inbox_url, action_json, current_user.private_key,
|
||||||
|
current_user.ap_profile_id + '#main-key')
|
||||||
|
if not success:
|
||||||
|
flash('Failed to send vote', 'warning')
|
||||||
|
|
||||||
current_user.last_seen = utcnow()
|
current_user.last_seen = utcnow()
|
||||||
current_user.ip_address = ip_address()
|
current_user.ip_address = ip_address()
|
||||||
|
@ -325,18 +326,19 @@ def comment_vote(comment_id, vote_direction):
|
||||||
...
|
...
|
||||||
# todo: federate vote
|
# todo: federate vote
|
||||||
else:
|
else:
|
||||||
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
if not comment.community.local_only:
|
||||||
action_json = {
|
action_type = 'Like' if vote_direction == 'upvote' else 'Dislike'
|
||||||
'actor': current_user.profile_id(),
|
action_json = {
|
||||||
'object': comment.profile_id(),
|
'actor': current_user.profile_id(),
|
||||||
'type': action_type,
|
'object': comment.profile_id(),
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
'type': action_type,
|
||||||
'audience': comment.community.profile_id()
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/{action_type.lower()}/{gibberish(15)}",
|
||||||
}
|
'audience': comment.community.profile_id()
|
||||||
success = post_request(comment.community.ap_inbox_url, action_json, current_user.private_key,
|
}
|
||||||
current_user.ap_profile_id + '#main-key')
|
success = post_request(comment.community.ap_inbox_url, action_json, current_user.private_key,
|
||||||
if not success:
|
current_user.ap_profile_id + '#main-key')
|
||||||
flash('Failed to send vote', 'error')
|
if not success:
|
||||||
|
flash('Failed to send vote', 'error')
|
||||||
|
|
||||||
current_user.last_seen = utcnow()
|
current_user.last_seen = utcnow()
|
||||||
current_user.ip_address = ip_address()
|
current_user.ip_address = ip_address()
|
||||||
|
@ -438,80 +440,81 @@ def add_reply(post_id: int, comment_id: int):
|
||||||
post.flush_cache()
|
post.flush_cache()
|
||||||
|
|
||||||
# federation
|
# federation
|
||||||
reply_json = {
|
if not post.community.local_only:
|
||||||
'type': 'Note',
|
reply_json = {
|
||||||
'id': reply.profile_id(),
|
'type': 'Note',
|
||||||
'attributedTo': current_user.profile_id(),
|
'id': reply.profile_id(),
|
||||||
'to': [
|
'attributedTo': current_user.profile_id(),
|
||||||
'https://www.w3.org/ns/activitystreams#Public',
|
'to': [
|
||||||
in_reply_to.author.profile_id()
|
'https://www.w3.org/ns/activitystreams#Public',
|
||||||
],
|
in_reply_to.author.profile_id()
|
||||||
'cc': [
|
],
|
||||||
post.community.profile_id(),
|
'cc': [
|
||||||
current_user.followers_url()
|
post.community.profile_id(),
|
||||||
],
|
current_user.followers_url()
|
||||||
'content': reply.body_html,
|
],
|
||||||
'inReplyTo': in_reply_to.profile_id(),
|
'content': reply.body_html,
|
||||||
'url': reply.profile_id(),
|
'inReplyTo': in_reply_to.profile_id(),
|
||||||
'mediaType': 'text/html',
|
'url': reply.profile_id(),
|
||||||
'source': {
|
'mediaType': 'text/html',
|
||||||
'content': reply.body,
|
'source': {
|
||||||
'mediaType': 'text/markdown'
|
'content': reply.body,
|
||||||
},
|
'mediaType': 'text/markdown'
|
||||||
'published': ap_datetime(utcnow()),
|
},
|
||||||
'distinguished': False,
|
'published': ap_datetime(utcnow()),
|
||||||
'audience': post.community.profile_id(),
|
'distinguished': False,
|
||||||
'contentMap': {
|
'audience': post.community.profile_id(),
|
||||||
'en': reply.body_html
|
'contentMap': {
|
||||||
}
|
'en': reply.body_html
|
||||||
}
|
|
||||||
create_json = {
|
|
||||||
'@context': default_context(),
|
|
||||||
'type': 'Create',
|
|
||||||
'actor': current_user.profile_id(),
|
|
||||||
'audience': post.community.profile_id(),
|
|
||||||
'to': [
|
|
||||||
'https://www.w3.org/ns/activitystreams#Public',
|
|
||||||
in_reply_to.author.profile_id()
|
|
||||||
],
|
|
||||||
'cc': [
|
|
||||||
post.community.profile_id(),
|
|
||||||
current_user.followers_url()
|
|
||||||
],
|
|
||||||
'object': reply_json,
|
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/create/{gibberish(15)}"
|
|
||||||
}
|
|
||||||
if in_reply_to.notify_author and in_reply_to.author.ap_id is not None:
|
|
||||||
reply_json['tag'] = [
|
|
||||||
{
|
|
||||||
'href': in_reply_to.author.ap_profile_id,
|
|
||||||
'name': '@' + in_reply_to.author.ap_id,
|
|
||||||
'type': 'Mention'
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
|
||||||
success = post_request(post.community.ap_inbox_url, create_json, current_user.private_key,
|
|
||||||
current_user.ap_profile_id + '#main-key')
|
|
||||||
if not success:
|
|
||||||
flash('Failed to send reply', 'error')
|
|
||||||
else: # local community - send it to followers on remote instances
|
|
||||||
announce = {
|
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
|
||||||
"type": 'Announce',
|
|
||||||
"to": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
|
||||||
"actor": post.community.ap_profile_id,
|
|
||||||
"cc": [
|
|
||||||
post.community.ap_followers_url
|
|
||||||
],
|
|
||||||
'@context': default_context(),
|
|
||||||
'object': create_json
|
|
||||||
}
|
}
|
||||||
|
create_json = {
|
||||||
|
'@context': default_context(),
|
||||||
|
'type': 'Create',
|
||||||
|
'actor': current_user.profile_id(),
|
||||||
|
'audience': post.community.profile_id(),
|
||||||
|
'to': [
|
||||||
|
'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
in_reply_to.author.profile_id()
|
||||||
|
],
|
||||||
|
'cc': [
|
||||||
|
post.community.profile_id(),
|
||||||
|
current_user.followers_url()
|
||||||
|
],
|
||||||
|
'object': reply_json,
|
||||||
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/create/{gibberish(15)}"
|
||||||
|
}
|
||||||
|
if in_reply_to.notify_author and in_reply_to.author.ap_id is not None:
|
||||||
|
reply_json['tag'] = [
|
||||||
|
{
|
||||||
|
'href': in_reply_to.author.ap_profile_id,
|
||||||
|
'name': '@' + in_reply_to.author.ap_id,
|
||||||
|
'type': 'Mention'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
||||||
|
success = post_request(post.community.ap_inbox_url, create_json, current_user.private_key,
|
||||||
|
current_user.ap_profile_id + '#main-key')
|
||||||
|
if not success:
|
||||||
|
flash('Failed to send reply', 'error')
|
||||||
|
else: # local community - send it to followers on remote instances
|
||||||
|
announce = {
|
||||||
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
|
"type": 'Announce',
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"actor": post.community.ap_profile_id,
|
||||||
|
"cc": [
|
||||||
|
post.community.ap_followers_url
|
||||||
|
],
|
||||||
|
'@context': default_context(),
|
||||||
|
'object': create_json
|
||||||
|
}
|
||||||
|
|
||||||
for instance in post.community.following_instances():
|
for instance in post.community.following_instances():
|
||||||
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
||||||
send_to_remote_instance(instance.id, post.community.id, announce)
|
send_to_remote_instance(instance.id, post.community.id, announce)
|
||||||
|
|
||||||
if reply.depth <= constants.THREAD_CUTOFF_DEPTH:
|
if reply.depth <= constants.THREAD_CUTOFF_DEPTH:
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post_id, _anchor=f'comment_{reply.id}'))
|
return redirect(url_for('activitypub.post_ap', post_id=post_id, _anchor=f'comment_{reply.id}'))
|
||||||
|
@ -566,79 +569,80 @@ def post_edit(post_id: int):
|
||||||
flash(_('Your changes have been saved.'), 'success')
|
flash(_('Your changes have been saved.'), 'success')
|
||||||
# federate edit
|
# federate edit
|
||||||
|
|
||||||
page_json = {
|
if not post.community.local_only:
|
||||||
'type': 'Page',
|
page_json = {
|
||||||
'id': post.ap_id,
|
'type': 'Page',
|
||||||
'attributedTo': current_user.ap_profile_id,
|
'id': post.ap_id,
|
||||||
'to': [
|
'attributedTo': current_user.ap_profile_id,
|
||||||
post.community.ap_profile_id,
|
'to': [
|
||||||
'https://www.w3.org/ns/activitystreams#Public'
|
post.community.ap_profile_id,
|
||||||
],
|
'https://www.w3.org/ns/activitystreams#Public'
|
||||||
'name': post.title,
|
|
||||||
'cc': [],
|
|
||||||
'content': post.body_html if post.body_html else '',
|
|
||||||
'mediaType': 'text/html',
|
|
||||||
'source': {
|
|
||||||
'content': post.body if post.body else '',
|
|
||||||
'mediaType': 'text/markdown'
|
|
||||||
},
|
|
||||||
'attachment': [],
|
|
||||||
'commentsEnabled': post.comments_enabled,
|
|
||||||
'sensitive': post.nsfw,
|
|
||||||
'nsfl': post.nsfl,
|
|
||||||
'published': ap_datetime(post.posted_at),
|
|
||||||
'updated': ap_datetime(post.edited_at),
|
|
||||||
'audience': post.community.ap_profile_id
|
|
||||||
}
|
|
||||||
update_json = {
|
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/update/{gibberish(15)}",
|
|
||||||
'type': 'Update',
|
|
||||||
'actor': current_user.profile_id(),
|
|
||||||
'audience': post.community.profile_id(),
|
|
||||||
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
|
||||||
'published': ap_datetime(utcnow()),
|
|
||||||
'cc': [
|
|
||||||
current_user.followers_url()
|
|
||||||
],
|
|
||||||
'object': page_json,
|
|
||||||
}
|
|
||||||
if post.type == POST_TYPE_LINK:
|
|
||||||
page_json['attachment'] = [{'href': post.url, 'type': 'Link'}]
|
|
||||||
elif post.image_id:
|
|
||||||
if post.image.file_path:
|
|
||||||
image_url = post.image.file_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
|
||||||
elif post.image.thumbnail_path:
|
|
||||||
image_url = post.image.thumbnail_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
|
||||||
else:
|
|
||||||
image_url = post.image.source_url
|
|
||||||
# NB image is a dict while attachment is a list of dicts (usually just one dict in the list)
|
|
||||||
page_json['image'] = {'type': 'Image', 'url': image_url}
|
|
||||||
if post.type == POST_TYPE_IMAGE:
|
|
||||||
page_json['attachment'] = [{'type': 'Link', 'href': post.image.source_url}] # source_url is always a https link, no need for .replace() as done above
|
|
||||||
|
|
||||||
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
|
||||||
success = post_request(post.community.ap_inbox_url, update_json, current_user.private_key,
|
|
||||||
current_user.ap_profile_id + '#main-key')
|
|
||||||
if not success:
|
|
||||||
flash('Failed to send edit to remote server', 'error')
|
|
||||||
else: # local community - send it to followers on remote instances
|
|
||||||
announce = {
|
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
|
||||||
"type": 'Announce',
|
|
||||||
"to": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
],
|
||||||
"actor": post.community.ap_profile_id,
|
'name': post.title,
|
||||||
"cc": [
|
'cc': [],
|
||||||
post.community.ap_followers_url
|
'content': post.body_html if post.body_html else '',
|
||||||
],
|
'mediaType': 'text/html',
|
||||||
'@context': default_context(),
|
'source': {
|
||||||
'object': update_json
|
'content': post.body if post.body else '',
|
||||||
|
'mediaType': 'text/markdown'
|
||||||
|
},
|
||||||
|
'attachment': [],
|
||||||
|
'commentsEnabled': post.comments_enabled,
|
||||||
|
'sensitive': post.nsfw,
|
||||||
|
'nsfl': post.nsfl,
|
||||||
|
'published': ap_datetime(post.posted_at),
|
||||||
|
'updated': ap_datetime(post.edited_at),
|
||||||
|
'audience': post.community.ap_profile_id
|
||||||
}
|
}
|
||||||
|
update_json = {
|
||||||
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/update/{gibberish(15)}",
|
||||||
|
'type': 'Update',
|
||||||
|
'actor': current_user.profile_id(),
|
||||||
|
'audience': post.community.profile_id(),
|
||||||
|
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
||||||
|
'published': ap_datetime(utcnow()),
|
||||||
|
'cc': [
|
||||||
|
current_user.followers_url()
|
||||||
|
],
|
||||||
|
'object': page_json,
|
||||||
|
}
|
||||||
|
if post.type == POST_TYPE_LINK:
|
||||||
|
page_json['attachment'] = [{'href': post.url, 'type': 'Link'}]
|
||||||
|
elif post.image_id:
|
||||||
|
if post.image.file_path:
|
||||||
|
image_url = post.image.file_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
||||||
|
elif post.image.thumbnail_path:
|
||||||
|
image_url = post.image.thumbnail_path.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/")
|
||||||
|
else:
|
||||||
|
image_url = post.image.source_url
|
||||||
|
# NB image is a dict while attachment is a list of dicts (usually just one dict in the list)
|
||||||
|
page_json['image'] = {'type': 'Image', 'url': image_url}
|
||||||
|
if post.type == POST_TYPE_IMAGE:
|
||||||
|
page_json['attachment'] = [{'type': 'Link', 'href': post.image.source_url}] # source_url is always a https link, no need for .replace() as done above
|
||||||
|
|
||||||
for instance in post.community.following_instances():
|
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
||||||
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
success = post_request(post.community.ap_inbox_url, update_json, current_user.private_key,
|
||||||
send_to_remote_instance(instance.id, post.community.id, announce)
|
current_user.ap_profile_id + '#main-key')
|
||||||
|
if not success:
|
||||||
|
flash('Failed to send edit to remote server', 'error')
|
||||||
|
else: # local community - send it to followers on remote instances
|
||||||
|
announce = {
|
||||||
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
|
"type": 'Announce',
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"actor": post.community.ap_profile_id,
|
||||||
|
"cc": [
|
||||||
|
post.community.ap_followers_url
|
||||||
|
],
|
||||||
|
'@context': default_context(),
|
||||||
|
'object': update_json
|
||||||
|
}
|
||||||
|
|
||||||
|
for instance in post.community.following_instances():
|
||||||
|
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
||||||
|
send_to_remote_instance(instance.id, post.community.id, announce)
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
else:
|
else:
|
||||||
|
@ -680,43 +684,44 @@ def post_delete(post_id: int):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash(_('Post deleted.'))
|
flash(_('Post deleted.'))
|
||||||
|
|
||||||
delete_json = {
|
if not community.local_only:
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/delete/{gibberish(15)}",
|
delete_json = {
|
||||||
'type': 'Delete',
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/delete/{gibberish(15)}",
|
||||||
'actor': current_user.profile_id(),
|
'type': 'Delete',
|
||||||
'audience': post.community.profile_id(),
|
'actor': current_user.profile_id(),
|
||||||
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
'audience': post.community.profile_id(),
|
||||||
'published': ap_datetime(utcnow()),
|
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
||||||
'cc': [
|
'published': ap_datetime(utcnow()),
|
||||||
current_user.followers_url()
|
'cc': [
|
||||||
],
|
current_user.followers_url()
|
||||||
'object': post.ap_id,
|
|
||||||
}
|
|
||||||
|
|
||||||
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
|
||||||
success = post_request(post.community.ap_inbox_url, delete_json, current_user.private_key,
|
|
||||||
current_user.ap_profile_id + '#main-key')
|
|
||||||
if not success:
|
|
||||||
flash('Failed to send delete to remote server', 'error')
|
|
||||||
else: # local community - send it to followers on remote instances
|
|
||||||
announce = {
|
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
|
||||||
"type": 'Announce',
|
|
||||||
"to": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
],
|
||||||
"actor": post.community.ap_profile_id,
|
'object': post.ap_id,
|
||||||
"cc": [
|
|
||||||
post.community.ap_followers_url
|
|
||||||
],
|
|
||||||
'@context': default_context(),
|
|
||||||
'object': delete_json
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for instance in post.community.following_instances():
|
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
||||||
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(
|
success = post_request(post.community.ap_inbox_url, delete_json, current_user.private_key,
|
||||||
instance.domain):
|
current_user.ap_profile_id + '#main-key')
|
||||||
send_to_remote_instance(instance.id, post.community.id, announce)
|
if not success:
|
||||||
|
flash('Failed to send delete to remote server', 'error')
|
||||||
|
else: # local community - send it to followers on remote instances
|
||||||
|
announce = {
|
||||||
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
|
"type": 'Announce',
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"actor": post.community.ap_profile_id,
|
||||||
|
"cc": [
|
||||||
|
post.community.ap_followers_url
|
||||||
|
],
|
||||||
|
'@context': default_context(),
|
||||||
|
'object': delete_json
|
||||||
|
}
|
||||||
|
|
||||||
|
for instance in post.community.following_instances():
|
||||||
|
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(
|
||||||
|
instance.domain):
|
||||||
|
send_to_remote_instance(instance.id, post.community.id, announce)
|
||||||
|
|
||||||
return redirect(url_for('activitypub.community_profile', actor=community.ap_id if community.ap_id is not None else community.name))
|
return redirect(url_for('activitypub.community_profile', actor=community.ap_id if community.ap_id is not None else community.name))
|
||||||
|
|
||||||
|
@ -919,71 +924,72 @@ def post_reply_edit(post_id: int, comment_id: int):
|
||||||
else:
|
else:
|
||||||
in_reply_to = post
|
in_reply_to = post
|
||||||
# federate edit
|
# federate edit
|
||||||
reply_json = {
|
if not post.community.local_only:
|
||||||
'type': 'Note',
|
reply_json = {
|
||||||
'id': post_reply.profile_id(),
|
'type': 'Note',
|
||||||
'attributedTo': current_user.profile_id(),
|
'id': post_reply.profile_id(),
|
||||||
'to': [
|
'attributedTo': current_user.profile_id(),
|
||||||
'https://www.w3.org/ns/activitystreams#Public',
|
'to': [
|
||||||
in_reply_to.author.profile_id()
|
'https://www.w3.org/ns/activitystreams#Public',
|
||||||
],
|
in_reply_to.author.profile_id()
|
||||||
'cc': [
|
],
|
||||||
post.community.profile_id(),
|
'cc': [
|
||||||
current_user.followers_url()
|
post.community.profile_id(),
|
||||||
],
|
current_user.followers_url()
|
||||||
'content': post_reply.body_html,
|
],
|
||||||
'inReplyTo': in_reply_to.profile_id(),
|
'content': post_reply.body_html,
|
||||||
'url': post_reply.profile_id(),
|
'inReplyTo': in_reply_to.profile_id(),
|
||||||
'mediaType': 'text/html',
|
'url': post_reply.profile_id(),
|
||||||
'source': {
|
'mediaType': 'text/html',
|
||||||
'content': post_reply.body,
|
'source': {
|
||||||
'mediaType': 'text/markdown'
|
'content': post_reply.body,
|
||||||
},
|
'mediaType': 'text/markdown'
|
||||||
'published': ap_datetime(post_reply.posted_at),
|
},
|
||||||
'updated': ap_datetime(post_reply.edited_at),
|
'published': ap_datetime(post_reply.posted_at),
|
||||||
'distinguished': False,
|
'updated': ap_datetime(post_reply.edited_at),
|
||||||
'audience': post.community.profile_id(),
|
'distinguished': False,
|
||||||
'contentMap': {
|
'audience': post.community.profile_id(),
|
||||||
'en': post_reply.body_html
|
'contentMap': {
|
||||||
|
'en': post_reply.body_html
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
update_json = {
|
||||||
update_json = {
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/update/{gibberish(15)}",
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/update/{gibberish(15)}",
|
'type': 'Update',
|
||||||
'type': 'Update',
|
'actor': current_user.profile_id(),
|
||||||
'actor': current_user.profile_id(),
|
'audience': post.community.profile_id(),
|
||||||
'audience': post.community.profile_id(),
|
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
||||||
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
'published': ap_datetime(utcnow()),
|
||||||
'published': ap_datetime(utcnow()),
|
'cc': [
|
||||||
'cc': [
|
current_user.followers_url()
|
||||||
current_user.followers_url()
|
|
||||||
],
|
|
||||||
'object': reply_json,
|
|
||||||
}
|
|
||||||
|
|
||||||
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
|
||||||
success = post_request(post.community.ap_inbox_url, update_json, current_user.private_key,
|
|
||||||
current_user.ap_profile_id + '#main-key')
|
|
||||||
if not success:
|
|
||||||
flash('Failed to send edit to remote server', 'error')
|
|
||||||
else: # local community - send it to followers on remote instances
|
|
||||||
announce = {
|
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
|
||||||
"type": 'Announce',
|
|
||||||
"to": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
],
|
||||||
"actor": post.community.ap_profile_id,
|
'object': reply_json,
|
||||||
"cc": [
|
|
||||||
post.community.ap_followers_url
|
|
||||||
],
|
|
||||||
'@context': default_context(),
|
|
||||||
'object': update_json
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for instance in post.community.following_instances():
|
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
||||||
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(
|
success = post_request(post.community.ap_inbox_url, update_json, current_user.private_key,
|
||||||
instance.domain):
|
current_user.ap_profile_id + '#main-key')
|
||||||
send_to_remote_instance(instance.id, post.community.id, announce)
|
if not success:
|
||||||
|
flash('Failed to send edit to remote server', 'error')
|
||||||
|
else: # local community - send it to followers on remote instances
|
||||||
|
announce = {
|
||||||
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
|
"type": 'Announce',
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"actor": post.community.ap_profile_id,
|
||||||
|
"cc": [
|
||||||
|
post.community.ap_followers_url
|
||||||
|
],
|
||||||
|
'@context': default_context(),
|
||||||
|
'object': update_json
|
||||||
|
}
|
||||||
|
|
||||||
|
for instance in post.community.following_instances():
|
||||||
|
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(
|
||||||
|
instance.domain):
|
||||||
|
send_to_remote_instance(instance.id, post.community.id, announce)
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
else:
|
else:
|
||||||
form.body.data = post_reply.body
|
form.body.data = post_reply.body
|
||||||
|
@ -1014,42 +1020,43 @@ def post_reply_delete(post_id: int, comment_id: int):
|
||||||
post.flush_cache()
|
post.flush_cache()
|
||||||
flash(_('Comment deleted.'))
|
flash(_('Comment deleted.'))
|
||||||
# federate delete
|
# federate delete
|
||||||
delete_json = {
|
if not post.community.local_only:
|
||||||
'id': f"https://{current_app.config['SERVER_NAME']}/activities/delete/{gibberish(15)}",
|
delete_json = {
|
||||||
'type': 'Delete',
|
'id': f"https://{current_app.config['SERVER_NAME']}/activities/delete/{gibberish(15)}",
|
||||||
'actor': current_user.profile_id(),
|
'type': 'Delete',
|
||||||
'audience': post.community.profile_id(),
|
'actor': current_user.profile_id(),
|
||||||
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
'audience': post.community.profile_id(),
|
||||||
'published': ap_datetime(utcnow()),
|
'to': [post.community.profile_id(), 'https://www.w3.org/ns/activitystreams#Public'],
|
||||||
'cc': [
|
'published': ap_datetime(utcnow()),
|
||||||
current_user.followers_url()
|
'cc': [
|
||||||
],
|
current_user.followers_url()
|
||||||
'object': post_reply.ap_id,
|
|
||||||
}
|
|
||||||
|
|
||||||
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
|
||||||
success = post_request(post.community.ap_inbox_url, delete_json, current_user.private_key,
|
|
||||||
current_user.ap_profile_id + '#main-key')
|
|
||||||
if not success:
|
|
||||||
flash('Failed to send delete to remote server', 'error')
|
|
||||||
else: # local community - send it to followers on remote instances
|
|
||||||
announce = {
|
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
|
||||||
"type": 'Announce',
|
|
||||||
"to": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
],
|
],
|
||||||
"actor": post.community.ap_profile_id,
|
'object': post_reply.ap_id,
|
||||||
"cc": [
|
|
||||||
post.community.ap_followers_url
|
|
||||||
],
|
|
||||||
'@context': default_context(),
|
|
||||||
'object': delete_json
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for instance in post.community.following_instances():
|
if not post.community.is_local(): # this is a remote community, send it to the instance that hosts it
|
||||||
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
success = post_request(post.community.ap_inbox_url, delete_json, current_user.private_key,
|
||||||
send_to_remote_instance(instance.id, post.community.id, announce)
|
current_user.ap_profile_id + '#main-key')
|
||||||
|
if not success:
|
||||||
|
flash('Failed to send delete to remote server', 'error')
|
||||||
|
else: # local community - send it to followers on remote instances
|
||||||
|
announce = {
|
||||||
|
"id": f"https://{current_app.config['SERVER_NAME']}/activities/announce/{gibberish(15)}",
|
||||||
|
"type": 'Announce',
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"actor": post.community.ap_profile_id,
|
||||||
|
"cc": [
|
||||||
|
post.community.ap_followers_url
|
||||||
|
],
|
||||||
|
'@context': default_context(),
|
||||||
|
'object': delete_json
|
||||||
|
}
|
||||||
|
|
||||||
|
for instance in post.community.following_instances():
|
||||||
|
if instance.inbox and not current_user.has_blocked_instance(instance.id) and not instance_banned(instance.domain):
|
||||||
|
send_to_remote_instance(instance.id, post.community.id, announce)
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue