mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
apf part 01: add log_incoming_ap function
This commit is contained in:
parent
5e422131ad
commit
fe7791bf4d
3 changed files with 48 additions and 1 deletions
|
@ -25,7 +25,7 @@ from app.activitypub.util import public_key, users_total, active_half_year, acti
|
||||||
update_post_from_activity, undo_vote, undo_downvote, post_to_page, get_redis_connection, find_reported_object, \
|
update_post_from_activity, undo_vote, undo_downvote, post_to_page, get_redis_connection, find_reported_object, \
|
||||||
process_report, ensure_domains_match, can_edit, can_delete, remove_data_from_banned_user, resolve_remote_post, \
|
process_report, ensure_domains_match, can_edit, can_delete, remove_data_from_banned_user, resolve_remote_post, \
|
||||||
inform_followers_of_post_update, comment_model_to_json, restore_post_or_comment, ban_local_user, unban_local_user, \
|
inform_followers_of_post_update, comment_model_to_json, restore_post_or_comment, ban_local_user, unban_local_user, \
|
||||||
lock_post
|
lock_post, log_incoming_ap
|
||||||
from app.utils import gibberish, get_setting, render_template, \
|
from app.utils import gibberish, get_setting, render_template, \
|
||||||
community_membership, ap_datetime, ip_address, can_downvote, \
|
community_membership, ap_datetime, ip_address, can_downvote, \
|
||||||
can_upvote, can_create_post, awaken_dormant_instance, shorten_string, can_create_post_reply, sha256_digest, \
|
can_upvote, can_create_post, awaken_dormant_instance, shorten_string, can_create_post_reply, sha256_digest, \
|
||||||
|
|
|
@ -2565,3 +2565,16 @@ def inform_followers_of_post_update_task(post_id: int, sending_instance_id: int)
|
||||||
post_request(i.inbox, update_json, post.author.private_key, post.author.public_url() + '#main-key')
|
post_request(i.inbox, update_json, post.author.private_key, post.author.public_url() + '#main-key')
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def log_incoming_ap(id, aplog_type, aplog_result, request_json, message=None):
|
||||||
|
aplog_in = APLOG_IN
|
||||||
|
|
||||||
|
if aplog_in and aplog_type[0] and aplog_result[0]:
|
||||||
|
activity_log = ActivityPubLog(direction='in', activity_id=id, activity_type=aplog_type[1], result=aplog_result[1])
|
||||||
|
if message:
|
||||||
|
activity_log.exception_message = message
|
||||||
|
if request_json:
|
||||||
|
activity_log.activity_json = json.dumps(request_json)
|
||||||
|
db.session.add(activity_log)
|
||||||
|
db.session.commit()
|
||||||
|
|
|
@ -36,3 +36,37 @@ ROLE_STAFF = 3
|
||||||
ROLE_ADMIN = 4
|
ROLE_ADMIN = 4
|
||||||
|
|
||||||
MICROBLOG_APPS = ["mastodon", "misskey", "akkoma", "iceshrimp", "pleroma"]
|
MICROBLOG_APPS = ["mastodon", "misskey", "akkoma", "iceshrimp", "pleroma"]
|
||||||
|
|
||||||
|
APLOG_IN = True
|
||||||
|
|
||||||
|
APLOG_MONITOR = (True, 'Debug this')
|
||||||
|
|
||||||
|
APLOG_SUCCESS = (True, 'success')
|
||||||
|
APLOG_FAILURE = (True, 'failure')
|
||||||
|
APLOG_IGNORED = (True, 'ignored')
|
||||||
|
APLOG_PROCESSING = (True, 'processing')
|
||||||
|
|
||||||
|
APLOG_NOTYPE = (True, 'Unknown')
|
||||||
|
APLOG_DUPLICATE = (True, 'Duplicate')
|
||||||
|
APLOG_FOLLOW = (True, 'Follow')
|
||||||
|
APLOG_ACCEPT = (True, 'Accept')
|
||||||
|
APLOG_DELETE = (True, 'Delete')
|
||||||
|
APLOG_CHATMESSAGE = (True, 'Create ChatMessage')
|
||||||
|
APLOG_CREATE = (True, 'Create')
|
||||||
|
APLOG_UPDATE = (True, 'Update')
|
||||||
|
APLOG_LIKE = (True, 'Like')
|
||||||
|
APLOG_DISLIKE = (True, 'Dislike')
|
||||||
|
APLOG_REPORT = (True, 'Report')
|
||||||
|
APLOG_USERBAN = (True, 'User Ban')
|
||||||
|
APLOG_LOCK = (True, 'Post Lock')
|
||||||
|
|
||||||
|
APLOG_UNDO_FOLLOW = (True, 'Undo Follow')
|
||||||
|
APLOG_UNDO_DELETE = (True, 'Undo Delete')
|
||||||
|
APLOG_UNDO_VOTE = (True, 'Undo Vote')
|
||||||
|
APLOG_UNDO_USERBAN = (True, 'Undo User Ban')
|
||||||
|
|
||||||
|
APLOG_ADD = (True, 'Add Mod/Sticky')
|
||||||
|
APLOG_REMOVE = (True, 'Remove Mod/Sticky')
|
||||||
|
|
||||||
|
APLOG_ANNOUNCE = (True, 'Announce')
|
||||||
|
APLOG_PT_VIEW = (True, 'PeerTube View')
|
||||||
|
|
Loading…
Add table
Reference in a new issue