Limit the number of shared items shown on profile

merge-requests/30/head
Bob Mottram 2023-08-24 11:55:19 +01:00
parent cc40ad2a40
commit c8a2bee2ed
3 changed files with 46 additions and 15 deletions

View File

@ -3284,6 +3284,8 @@ class PubServer(BaseHTTPRequestHandler):
min_images_for_accounts = \
self.server.min_images_for_accounts
max_shares_on_profile = \
self.server.max_shares_on_profile
profile_str = \
html_profile_after_search(recent_posts_cache,
self.server.max_recent_posts,
@ -3319,7 +3321,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading,
self.server.dogwhistles,
min_images_for_accounts,
self.server.buy_sites)
self.server.buy_sites,
max_shares_on_profile)
if profile_str:
msg = profile_str.encode('utf-8')
msglen = len(msg)
@ -4909,6 +4912,8 @@ class PubServer(BaseHTTPRequestHandler):
min_images_for_accounts = \
self.server.min_images_for_accounts
max_shares_on_profile = \
self.server.max_shares_on_profile
profile_str = \
html_profile_after_search(recent_posts_cache,
self.server.max_recent_posts,
@ -4944,7 +4949,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading,
self.server.dogwhistles,
min_images_for_accounts,
self.server.buy_sites)
self.server.buy_sites,
max_shares_on_profile)
if profile_str:
msg = profile_str.encode('utf-8')
msglen = len(msg)
@ -12382,7 +12388,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.lists_enabled,
self.server.content_license_url,
timezone, bold_reading,
self.server.buy_sites, None)
self.server.buy_sites, None,
self.server.max_shares_on_profile)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -12475,6 +12482,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nick):
bold_reading = True
max_shares_on_profile = \
self.server.max_shares_on_profile
msg = \
html_profile(signing_priv_key_pem,
self.server.rss_icon_at_top,
@ -12510,7 +12519,8 @@ class PubServer(BaseHTTPRequestHandler):
content_license_url,
timezone, bold_reading,
self.server.buy_sites,
None)
None,
max_shares_on_profile)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -15159,7 +15169,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.content_license_url,
timezone, bold_reading,
self.server.buy_sites,
None)
None,
self.server.max_shares_on_profile)
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -15266,6 +15277,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
max_shares_on_profile = \
self.server.max_shares_on_profile
msg = \
html_profile(self.server.signing_priv_key_pem,
self.server.rss_icon_at_top,
@ -15303,7 +15316,8 @@ class PubServer(BaseHTTPRequestHandler):
content_license_url,
timezone, bold_reading,
self.server.buy_sites,
None).encode('utf-8')
None,
max_shares_on_profile).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html',
msglen, cookie, calling_domain, False)
@ -15404,6 +15418,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
max_shares_on_profile = \
self.server.max_shares_on_profile
msg = \
html_profile(self.server.signing_priv_key_pem,
self.server.rss_icon_at_top,
@ -15441,7 +15457,8 @@ class PubServer(BaseHTTPRequestHandler):
content_license_url,
timezone, bold_reading,
self.server.buy_sites,
None).encode('utf-8')
None,
max_shares_on_profile).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html',
msglen, cookie, calling_domain, False)
@ -15546,6 +15563,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
max_shares_on_profile = \
self.server.max_shares_on_profile
msg = \
html_profile(self.server.signing_priv_key_pem,
self.server.rss_icon_at_top,
@ -15583,7 +15602,8 @@ class PubServer(BaseHTTPRequestHandler):
content_license_url,
timezone, bold_reading,
self.server.buy_sites,
None).encode('utf-8')
None,
max_shares_on_profile).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html',
msglen, cookie, calling_domain, False)
@ -15688,6 +15708,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
max_shares_on_profile = \
self.server.max_shares_on_profile
msg = \
html_profile(self.server.signing_priv_key_pem,
self.server.rss_icon_at_top,
@ -15726,7 +15748,8 @@ class PubServer(BaseHTTPRequestHandler):
content_license_url,
timezone, bold_reading,
self.server.buy_sites,
None).encode('utf-8')
None,
max_shares_on_profile).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)
@ -15861,6 +15884,8 @@ class PubServer(BaseHTTPRequestHandler):
bold_reading = False
if self.server.bold_reading.get(nickname):
bold_reading = True
max_shares_on_profile = \
self.server.max_shares_on_profile
msg = \
html_profile(self.server.signing_priv_key_pem,
self.server.rss_icon_at_top,
@ -15894,7 +15919,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.content_license_url,
timezone, bold_reading,
self.server.buy_sites,
None).encode('utf-8')
None,
max_shares_on_profile).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, calling_domain, False)

View File

@ -2255,7 +2255,8 @@ def actor_attached_shares(actor_json: {}) -> []:
return attached_shares
def actor_attached_shares_as_html(actor_json: {}) -> str:
def actor_attached_shares_as_html(actor_json: {},
max_shares_on_profile: int) -> str:
"""Returns html for any shared items attached to an actor
https://codeberg.org/fediverse/fep/src/branch/main/fep/0837/fep-0837.md
"""

View File

@ -203,7 +203,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
onion_domain: str, i2p_domain: str,
bold_reading: bool, dogwhistles: {},
min_images_for_accounts: [],
buy_sites: {}) -> str:
buy_sites: {},
max_shares_on_profile: int) -> str:
"""Show a profile page after a search for a fediverse address
"""
http = False
@ -257,7 +258,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
# shared items attached to the actor
# https://codeberg.org/fediverse/fep/src/branch/main/fep/0837/fep-0837.md
attached_shared_items = actor_attached_shares_as_html(profile_json)
attached_shared_items = \
actor_attached_shares_as_html(profile_json, max_shares_on_profile)
avatar_url = ''
if profile_json.get('icon'):
@ -801,7 +803,8 @@ def html_profile(signing_priv_key_pem: str,
content_license_url: str,
timezone: str, bold_reading: bool,
buy_sites: {},
actor_proxied: str) -> str:
actor_proxied: str,
max_shares_on_profile: int) -> str:
"""Show the profile page as html
"""
show_moved_accounts = False
@ -1139,7 +1142,8 @@ def html_profile(signing_priv_key_pem: str,
# shared items attached to the actor
# https://codeberg.org/fediverse/fep/src/branch/main/fep/0837/fep-0837.md
attached_shared_items = actor_attached_shares_as_html(profile_json)
attached_shared_items = \
actor_attached_shares_as_html(profile_json, max_shares_on_profile)
profile_header_str = \
_get_profile_header(base_dir, http_prefix,