mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
update nsfl based on title when post is edited
This commit is contained in:
parent
7e1851fa1c
commit
2c00577606
1 changed files with 2 additions and 17 deletions
|
@ -1309,7 +1309,8 @@ def update_post_from_activity(post: Post, request_json: dict):
|
|||
if 'attachment' in request_json['object'] and 'href' in request_json['object']['attachment']:
|
||||
post.url = request_json['object']['attachment']['href']
|
||||
post.nsfw = request_json['object']['sensitive']
|
||||
if 'nsfl' in request_json['object']:
|
||||
nsfl_in_title = '[NSFL]' in request_json['object']['name'].upper() or '(NSFL)' in request_json['object']['name'].upper()
|
||||
if 'nsfl' in request_json['object'] or nsfl_in_title:
|
||||
post.nsfl = request_json['object']['nsfl']
|
||||
post.comments_enabled = request_json['object']['commentsEnabled']
|
||||
post.edited_at = utcnow()
|
||||
|
@ -1382,22 +1383,6 @@ def undo_vote(activity_log, comment, post, target_ap_id, user):
|
|||
return post
|
||||
|
||||
|
||||
# given an activitypub id for a post or comment, retrieve it and all it's parent objects
|
||||
def backfill_from_ap_id(ap_id: str):
|
||||
if ap_id.startswith(f"https://{current_app.config['SERVER_NAME']}"):
|
||||
...
|
||||
else:
|
||||
try:
|
||||
activity_data = get_request(ap_id, headers={'Accept': 'application/activity+json'})
|
||||
except requests.exceptions.ReadTimeout:
|
||||
time.sleep(randint(3, 10))
|
||||
activity_data = get_request(ap_id, headers={'Accept': 'application/activity+json'})
|
||||
if activity_data.status_code == 200:
|
||||
actor_json = activity_data.json()
|
||||
activity_data.close()
|
||||
return actor_json_to_model(actor_json, address, server)
|
||||
|
||||
|
||||
def lemmy_site_data():
|
||||
site = g.site
|
||||
data = {
|
||||
|
|
Loading…
Add table
Reference in a new issue