strip post title - activitypub

This commit is contained in:
rimu 2024-09-29 17:15:47 +13:00
parent fd9d744111
commit c9883c07c0

View file

@ -1619,7 +1619,7 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
else: else:
return None return None
else: else:
title = request_json['object']['name'] title = request_json['object']['name'].strip()
nsfl_in_title = '[NSFL]' in title.upper() or '(NSFL)' in title.upper() nsfl_in_title = '[NSFL]' in title.upper() or '(NSFL)' in title.upper()
post = Post(user_id=user.id, community_id=community.id, post = Post(user_id=user.id, community_id=community.id,
@ -1658,9 +1658,9 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
if microblog: if microblog:
autogenerated_title = microblog_content_to_title(post.body_html) autogenerated_title = microblog_content_to_title(post.body_html)
if len(autogenerated_title) < 20: if len(autogenerated_title) < 20:
title = '[Microblog] ' + autogenerated_title title = '[Microblog] ' + autogenerated_title.strip()
else: else:
title = autogenerated_title title = autogenerated_title.strip()
if '[NSFL]' in title.upper() or '(NSFL)' in title.upper(): if '[NSFL]' in title.upper() or '(NSFL)' in title.upper():
post.nsfl = True post.nsfl = True
if '[NSFW]' in title.upper() or '(NSFW)' in title.upper(): if '[NSFW]' in title.upper() or '(NSFW)' in title.upper():