From 6ce5e7208c00b7e9869ff71fdbaa51bb0e370577 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sat, 20 Apr 2024 20:46:51 +1200 Subject: [PATCH] a way for senders to see the result of their POST to our inbox for debugging --- app/activitypub/routes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 3a965ff3..0803daf6 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -1255,3 +1255,17 @@ def activities_json(type, id): return resp else: abort(404) + + +# Other instances can query the result of their POST to the inbox by using this endpoint. The ID of the activity they +# sent (minus the https:// on the front) is the id parameter. e.g. https://piefed.ngrok.app/activity_result/piefed.ngrok.app/activities/announce/EfjyZ3BE5SzQK0C +@bp.route('/activity_result/') +def activity_result(id): + activity = ActivityPubLog.query.filter_by(activity_id=f'https://{id}').first() + if activity: + if activity.result == 'success': + return jsonify('Ok') + else: + return jsonify({'error': activity.result, 'message': activity.exception_message}) + else: + abort(404)