html response logging

This commit is contained in:
rimu 2024-10-02 20:12:32 +13:00
parent cbd68f8fd8
commit 0c493549e3

View file

@ -92,7 +92,7 @@ def post_request(uri: str, body: dict | None, private_key: str, key_id: str, con
body['@context'] = default_context() body['@context'] = default_context()
type = body['type'] if 'type' in body else '' type = body['type'] if 'type' in body else ''
log = ActivityPubLog(direction='out', activity_type=type, result='processing', activity_id=body['id'], exception_message='') 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.add(log)
db.session.commit() 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}' + ' - ' log.exception_message = f'{result.status_code}: {result.text:.100}' + ' - '
if 'DOCTYPE html' in result.text: if 'DOCTYPE html' in result.text:
log.result = 'ignored' 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: elif 'community_has_no_followers' in result.text:
fix_local_community_membership(uri, private_key) fix_local_community_membership(uri, private_key)
else: else: