mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Truncate status strings if needed
							parent
							
								
									351b45b282
								
							
						
					
					
						commit
						9908896ada
					
				
							
								
								
									
										19
									
								
								utils.py
								
								
								
								
							
							
						
						
									
										19
									
								
								utils.py
								
								
								
								
							|  | @ -23,6 +23,8 @@ from cryptography.hazmat.backends import default_backend | ||||||
| from cryptography.hazmat.primitives import hashes | from cryptography.hazmat.primitives import hashes | ||||||
| from followingCalendar import add_person_to_calendar | from followingCalendar import add_person_to_calendar | ||||||
| 
 | 
 | ||||||
|  | MAX_STATUS_LENGTH = 100 | ||||||
|  | 
 | ||||||
| VALID_HASHTAG_CHARS = \ | VALID_HASHTAG_CHARS = \ | ||||||
|     set('_0123456789' + |     set('_0123456789' + | ||||||
|         'abcdefghijklmnopqrstuvwxyz' + |         'abcdefghijklmnopqrstuvwxyz' + | ||||||
|  | @ -5556,10 +5558,17 @@ def get_actor_status(profile_json: {}) -> str: | ||||||
|     """ |     """ | ||||||
|     if not profile_json.get('sm:status'): |     if not profile_json.get('sm:status'): | ||||||
|         return '' |         return '' | ||||||
|  |     status = '' | ||||||
|     if isinstance(profile_json['sm:status'], str): |     if isinstance(profile_json['sm:status'], str): | ||||||
|         return profile_json['sm:status'] |         status = profile_json['sm:status'] | ||||||
|     if isinstance(profile_json['sm:status'], dict): |     elif isinstance(profile_json['sm:status'], dict): | ||||||
|         if profile_json['sm:status'].get('content'): |         if profile_json['sm:status'].get('content'): | ||||||
|             if isinstance(profile_json['sm:status']['content'], str): |             possible_status = profile_json['sm:status']['content'] | ||||||
|                 return profile_json['sm:status']['content'] |             if isinstance(status, str): | ||||||
|     return '' |                 status = possible_status | ||||||
|  |     if status: | ||||||
|  |         status = remove_html(status) | ||||||
|  |         if len(status) > MAX_STATUS_LENGTH: | ||||||
|  |             status = status[:MAX_STATUS_LENGTH] | ||||||
|  |         status = standardize_text(status) | ||||||
|  |     return status | ||||||
|  |  | ||||||
|  | @ -14,7 +14,6 @@ from person import is_person_snoozed | ||||||
| from posts import is_moderator | from posts import is_moderator | ||||||
| from flags import is_featured_writer | from flags import is_featured_writer | ||||||
| from flags import is_dormant | from flags import is_dormant | ||||||
| from utils import standardize_text |  | ||||||
| from utils import data_dir | from utils import data_dir | ||||||
| from utils import quote_toots_allowed | from utils import quote_toots_allowed | ||||||
| from utils import get_full_domain | from utils import get_full_domain | ||||||
|  | @ -403,16 +402,14 @@ def html_person_options(default_timeline: str, | ||||||
|     if status: |     if status: | ||||||
|         # https://codeberg.org/fediverse/fep/src/branch/main/ |         # https://codeberg.org/fediverse/fep/src/branch/main/ | ||||||
|         # fep/82f6/fep-82f6.md |         # fep/82f6/fep-82f6.md | ||||||
|         if len(status) < 100: |         if is_filtered(base_dir, nickname, domain, status, | ||||||
|             status = standardize_text(status) |                        system_language): | ||||||
|             if is_filtered(base_dir, nickname, domain, status, |             status_str = 'Status' | ||||||
|                            system_language): |             if translate.get('Status'): | ||||||
|                 status_str = 'Status' |                 status_str = translate['Status'] | ||||||
|                 if translate.get('Status'): |             options_str += \ | ||||||
|                     status_str = translate['Status'] |                 '  <p class="imText">' + status_str + ': ' + \ | ||||||
|                 options_str += \ |                 remove_html(status) + '</p>\n' | ||||||
|                     '  <p class="imText">' + status_str + ': ' + \ |  | ||||||
|                     remove_html(status) + '</p>\n' |  | ||||||
|     if pronouns: |     if pronouns: | ||||||
|         options_str += \ |         options_str += \ | ||||||
|             '  <p class="imText">' + translate['Pronouns'] + \ |             '  <p class="imText">' + translate['Pronouns'] + \ | ||||||
|  |  | ||||||
|  | @ -364,15 +364,12 @@ def html_profile_after_search(authorized: bool, | ||||||
| 
 | 
 | ||||||
|     profile_status = get_actor_status(profile_json) |     profile_status = get_actor_status(profile_json) | ||||||
|     if profile_status: |     if profile_status: | ||||||
|         profile_status = remove_html(profile_status) |         profile_status = \ | ||||||
|         if len(profile_status) < 100: |             remove_link_trackers_from_content(profile_status) | ||||||
|             profile_status = standardize_text(profile_status) |         profile_status = \ | ||||||
|             profile_status = \ |             add_emoji_to_display_name(session, base_dir, http_prefix, | ||||||
|                 remove_link_trackers_from_content(profile_status) |                                       nickname, domain, | ||||||
|             profile_status = \ |                                       profile_status, False, translate) | ||||||
|                 add_emoji_to_display_name(session, base_dir, http_prefix, |  | ||||||
|                                           nickname, domain, |  | ||||||
|                                           profile_status, False, translate) |  | ||||||
|     profile_description = '' |     profile_description = '' | ||||||
|     if profile_json.get('summary'): |     if profile_json.get('summary'): | ||||||
|         if not dangerous_markup(profile_json['summary'], |         if not dangerous_markup(profile_json['summary'], | ||||||
|  | @ -1124,15 +1121,12 @@ def html_profile(signing_priv_key_pem: str, | ||||||
|     domain_full = get_full_domain(domain, port) |     domain_full = get_full_domain(domain, port) | ||||||
|     profile_status = get_actor_status(profile_json) |     profile_status = get_actor_status(profile_json) | ||||||
|     if profile_status: |     if profile_status: | ||||||
|         profile_status = remove_html(profile_status) |         profile_status = \ | ||||||
|         if len(profile_status) < 100: |             remove_link_trackers_from_content(profile_status) | ||||||
|             profile_status = standardize_text(profile_status) |         profile_status = \ | ||||||
|             profile_status = \ |             add_emoji_to_display_name(session, base_dir, http_prefix, | ||||||
|                 remove_link_trackers_from_content(profile_status) |                                       nickname, domain, | ||||||
|             profile_status = \ |                                       profile_status, False, translate) | ||||||
|                 add_emoji_to_display_name(session, base_dir, http_prefix, |  | ||||||
|                                           nickname, domain, |  | ||||||
|                                           profile_status, False, translate) |  | ||||||
|     if not dangerous_markup(profile_json['summary'], False, []): |     if not dangerous_markup(profile_json['summary'], False, []): | ||||||
|         profile_description = profile_json['summary'] |         profile_description = profile_json['summary'] | ||||||
|     else: |     else: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue