From 058cef28716bd47c28a095d6a881884fbb91c3f1 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sat, 10 Aug 2024 18:42:49 +1200 Subject: [PATCH] MBin sends Create activities even for remote communities #290 Lemmy uses Announce -> Create for communities hosted on their instance and only uses Create when posting to a community on our instance. Mbin uses Create all the time. --- app/activitypub/routes.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index eccc592f..a615bf34 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -514,21 +514,20 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): community_ap_id = '' locations = ['audience', 'cc', 'to'] if 'object' in request_json: - rjs = [ request_json, request_json['object'] ] + rjs = [request_json, request_json['object']] else: - rjs = [ request_json ] - local_community_prefix = f"https://{current_app.config['SERVER_NAME']}/c/" + rjs = [request_json] followers_suffix = '/followers' for rj in rjs: - for loc in locations: - if loc in rj: - id = rj[loc] - if isinstance(id, str): - if id.startswith(local_community_prefix) and not id.endswith(followers_suffix): - community_ap_id = id - if isinstance(id, list): - for c in id: - if c.startswith(local_community_prefix) and not c.endswith(followers_suffix): + for location in locations: + if location in rj: + potential_id = rj[location] + if isinstance(potential_id, str): + if not potential_id.startswith('https://www.w3.org') and not potential_id.endswith(followers_suffix): + community_ap_id = potential_id + if isinstance(potential_id, list): + for c in potential_id: + if not c.startswith('https://www.w3.org') and not c.endswith(followers_suffix): community_ap_id = c break if community_ap_id: