mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -08:00
ignore Lemmy's superfluous hashtags
This commit is contained in:
parent
4cf4bb45fe
commit
f90d07f470
2 changed files with 5 additions and 5 deletions
|
@ -1539,9 +1539,10 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
|
||||||
if 'tag' in request_json['object'] and isinstance(request_json['object']['tag'], list):
|
if 'tag' in request_json['object'] and isinstance(request_json['object']['tag'], list):
|
||||||
for json_tag in request_json['object']['tag']:
|
for json_tag in request_json['object']['tag']:
|
||||||
if json_tag['type'] == 'Hashtag':
|
if json_tag['type'] == 'Hashtag':
|
||||||
hashtag = find_hashtag_or_create(json_tag['name'])
|
if json_tag['name'][1:].lower() != post.community.name.lower(): # Lemmy adds the community slug as a hashtag on every post in the community, which we want to ignore
|
||||||
if hashtag:
|
hashtag = find_hashtag_or_create(json_tag['name'])
|
||||||
post.tags.append(hashtag)
|
if hashtag:
|
||||||
|
post.tags.append(hashtag)
|
||||||
if 'image' in request_json['object'] and post.image is None:
|
if 'image' in request_json['object'] and post.image is None:
|
||||||
image = File(source_url=request_json['object']['image']['url'])
|
image = File(source_url=request_json['object']['image']['url'])
|
||||||
db.session.add(image)
|
db.session.add(image)
|
||||||
|
|
|
@ -259,10 +259,9 @@ def markdown_to_text(markdown_text) -> str:
|
||||||
|
|
||||||
|
|
||||||
def microblog_content_to_title(html: str) -> str:
|
def microblog_content_to_title(html: str) -> str:
|
||||||
|
title = ''
|
||||||
if '<p>' in html:
|
if '<p>' in html:
|
||||||
soup = BeautifulSoup(html, 'html.parser')
|
soup = BeautifulSoup(html, 'html.parser')
|
||||||
|
|
||||||
title = ''
|
|
||||||
for tag in soup.find_all('p'):
|
for tag in soup.find_all('p'):
|
||||||
title = tag.get_text(separator=" ")
|
title = tag.get_text(separator=" ")
|
||||||
if title and title.strip() != '' and len(title.strip()) >= 5:
|
if title and title.strip() != '' and len(title.strip()) >= 5:
|
||||||
|
|
Loading…
Add table
Reference in a new issue