From 90ddfcfaf0aede21a179ee1bb340c2fd5ccf8ae1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 24 Aug 2023 12:54:16 +0100 Subject: [PATCH] Apply share attachment limit --- shares.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shares.py b/shares.py index 055af05ea..b71ba795f 100644 --- a/shares.py +++ b/shares.py @@ -2260,10 +2260,12 @@ def actor_attached_shares_as_html(actor_json: {}, """Returns html for any shared items attached to an actor https://codeberg.org/fediverse/fep/src/branch/main/fep/0837/fep-0837.md """ - if not actor_json.get('attachment'): + if not actor_json.get('attachment') or \ + max_shares_on_profile == 0: return '' html_str = '' + ctr = 0 for attach_item in actor_json['attachment']: if _is_valueflows_attachment(attach_item): if not html_str: @@ -2271,6 +2273,9 @@ def actor_attached_shares_as_html(actor_json: {}, html_str += \ '
  • ' + \ attach_item['name'] + '
  • \n' + ctr += 1 + if ctr >= max_shares_on_profile: + break if html_str: html_str = html_str.strip() + '\n' return html_str