Merge pull request 'Admin Activities Page' (#99) from freamon/pyfedi:14 into main

Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/99
This commit is contained in:
rimu 2024-03-14 23:38:21 +00:00
commit e4e9c26a2d
2 changed files with 12 additions and 5 deletions

View file

@ -39,7 +39,7 @@ import arrow
from cryptography.exceptions import InvalidSignature from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding, rsa from cryptography.hazmat.primitives.asymmetric import padding, rsa
from flask import Request, current_app from flask import Request, current_app, g
from datetime import datetime from datetime import datetime
from dateutil import parser from dateutil import parser
from pyld import jsonld from pyld import jsonld
@ -81,8 +81,9 @@ def post_request(uri: str, body: dict | None, private_key: str, key_id: str, con
if '@context' not in body: # add a default json-ld context if necessary if '@context' not in body: # add a default json-ld context if necessary
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_json=json.dumps(body), activity_type=type, log = ActivityPubLog(direction='out', activity_type=type, result='processing', activity_id=body['id'], exception_message='')
result='processing', activity_id=body['id'], exception_message='') if g.site.log_activitypub_json:
log.activity_json=json.dumps(body)
db.session.add(log) db.session.add(log)
db.session.commit() db.session.commit()
try: try:

View file

@ -38,7 +38,13 @@
<td><span style="color: red;">{{ activity.result }}</span></td> <td><span style="color: red;">{{ activity.result }}</span></td>
{% endif %} {% endif %}
<td>{{ activity.exception_message if activity.exception_message else '' }}</td> <td>{{ activity.exception_message if activity.exception_message else '' }}</td>
<td><a href="{{ url_for('admin.activity_json', activity_id=activity.id) }}">View</a></td> <td>
{% if activity.activity_json is none %}
None
{% else %}
<a href="{{ url_for('admin.activity_json', activity_id=activity.id) }}">View</a>
{% endif %}
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
@ -56,4 +62,4 @@
</nav> </nav>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}