Check that petnames index exists

main
Bob Mottram 2025-08-25 19:17:01 +01:00
parent aece53b151
commit 04841ab471
1 changed files with 30 additions and 27 deletions

View File

@ -973,35 +973,38 @@ def _add_mention(base_dir: str, word_str: str, http_prefix: str,
return True return True
# try replacing petnames with mentions # try replacing petnames with mentions
follow_ctr = 0 follow_ctr = 0
for follow in following: if petnames:
if '@' not in follow: for follow in following:
follow_ctr += 1 if '@' not in follow:
continue
pet = remove_eol(petnames[follow_ctr])
if pet:
if possible_nickname != pet:
follow_ctr += 1 follow_ctr += 1
continue continue
follow_str = remove_eol(follow) pet = None
replace_nickname = follow_str.split('@')[0] if len(petnames) > follow_ctr:
replace_domain = follow_str.split('@')[1] pet = remove_eol(petnames[follow_ctr])
recipient_actor = \ if pet:
_mention_to_url(base_dir, http_prefix, if possible_nickname != pet:
replace_domain, replace_nickname) follow_ctr += 1
if recipient_actor not in recipients: continue
recipients.append(recipient_actor) follow_str = remove_eol(follow)
tags[word_str] = { replace_nickname = follow_str.split('@')[0]
'href': recipient_actor, replace_domain = follow_str.split('@')[1]
'name': word_str, recipient_actor = \
'type': 'Mention' _mention_to_url(base_dir, http_prefix,
} replace_domain, replace_nickname)
replace_mentions[word_str] = \ if recipient_actor not in recipients:
"<span class=\"h-card\"><a href=\"" + \ recipients.append(recipient_actor)
recipient_actor + "\" tabindex=\"10\" " + \ tags[word_str] = {
"class=\"u-url mention\">@<span>" + \ 'href': recipient_actor,
replace_nickname + "</span></a></span>" 'name': word_str,
return True 'type': 'Mention'
follow_ctr += 1 }
replace_mentions[word_str] = \
"<span class=\"h-card\"><a href=\"" + \
recipient_actor + "\" tabindex=\"10\" " + \
"class=\"u-url mention\">@<span>" + \
replace_nickname + "</span></a></span>"
return True
follow_ctr += 1
return False return False
possible_nickname = None possible_nickname = None
possible_domain = None possible_domain = None