From 21e8fd8a6d398479f33314e78a529c879fbc2095 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 3 May 2023 10:54:11 +0100 Subject: [PATCH] Combine with setting hashtags from bio --- daemon.py | 4 ++++ person.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/daemon.py b/daemon.py index 2f702e314..7ddeae331 100644 --- a/daemon.py +++ b/daemon.py @@ -7155,6 +7155,7 @@ class PubServer(BaseHTTPRequestHandler): actor_changed = True # change user bio + featured_tags = get_featured_hashtags(actor_json) + ' ' actor_json['tag'] = [] if fields.get('bio'): if fields['bio'] != actor_json['summary']: @@ -7172,6 +7173,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.translate) if actor_tags: for _, tag in actor_tags.items(): + if tag['name'] + ' ' in featured_tags: + continue actor_json['tag'].append(tag) actor_changed = True else: @@ -7180,6 +7183,7 @@ class PubServer(BaseHTTPRequestHandler): else: if check_name_and_bio: redirect_path = 'previewAvatar' + set_featured_hashtags(actor_json, featured_tags, True) admin_nickname = \ get_config_param(base_dir, 'admin') diff --git a/person.py b/person.py index e56d60f46..6af21f31a 100644 --- a/person.py +++ b/person.py @@ -1946,7 +1946,8 @@ def get_featured_hashtags(actor_json: {}) -> str: return result.strip() -def set_featured_hashtags(actor_json: {}, hashtags: str) -> None: +def set_featured_hashtags(actor_json: {}, hashtags: str, + append: bool = False) -> None: """sets featured hashtags """ separator_str = ' ' @@ -1986,4 +1987,7 @@ def set_featured_hashtags(actor_json: {}, hashtags: str) -> None: continue if tag_dict['type'] != 'Hashtag': result.append(tag_dict) - actor_json['tag'] = result + if not append: + actor_json['tag'] = result + else: + actor_json['tag'] += result