From 0c493549e3a5140a4b7509f77f8e2366976059d0 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Wed, 2 Oct 2024 20:12:32 +1300 Subject: [PATCH] html response logging --- app/activitypub/signature.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/activitypub/signature.py b/app/activitypub/signature.py index 65bf4c5a..9bac1e3a 100644 --- a/app/activitypub/signature.py +++ b/app/activitypub/signature.py @@ -92,7 +92,7 @@ def post_request(uri: str, body: dict | None, private_key: str, key_id: str, con body['@context'] = default_context() type = body['type'] if 'type' in body else '' log = ActivityPubLog(direction='out', activity_type=type, result='processing', activity_id=body['id'], exception_message='') - log.activity_json=json.dumps(body) + log.activity_json = json.dumps(body) db.session.add(log) db.session.commit() @@ -107,7 +107,8 @@ def post_request(uri: str, body: dict | None, private_key: str, key_id: str, con log.exception_message = f'{result.status_code}: {result.text:.100}' + ' - ' if 'DOCTYPE html' in result.text: log.result = 'ignored' - log.exception_message = f'{result.status_code}: HTML instead of JSON response - ' + log.exception_message = f'{result.status_code}: HTML instead of JSON response - ' + log.activity_json += result.text elif 'community_has_no_followers' in result.text: fix_local_community_membership(uri, private_key) else: