mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Apply pixelfed style capabilities for announce permission
							parent
							
								
									3d5d508533
								
							
						
					
					
						commit
						025ec98673
					
				|  | @ -2259,8 +2259,13 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, | ||||||
|                     attachment = [] |                     attachment = [] | ||||||
|                     if post_json_object['object'].get('attachment'): |                     if post_json_object['object'].get('attachment'): | ||||||
|                         attachment = post_json_object['object']['attachment'] |                         attachment = post_json_object['object']['attachment'] | ||||||
|  |                     capabilities = {} | ||||||
|  |                     if post_json_object['object'].get('capabilities'): | ||||||
|  |                         capabilities = \ | ||||||
|  |                             post_json_object['object']['capabilities'] | ||||||
|                     if not disallow_announce(post_summary + ' ' + |                     if not disallow_announce(post_summary + ' ' + | ||||||
|                                              post_content, attachment): |                                              post_content, attachment, | ||||||
|  |                                              capabilities): | ||||||
|                         if post_json_object.get('id'): |                         if post_json_object.get('id'): | ||||||
|                             post_id = post_json_object['id'] |                             post_id = post_json_object['id'] | ||||||
|                             announce_actor = \ |                             announce_actor = \ | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								inbox.py
								
								
								
								
							
							
						
						
									
										4
									
								
								inbox.py
								
								
								
								
							|  | @ -3241,9 +3241,9 @@ def json_post_allows_comments(post_json_object: {}) -> bool: | ||||||
|     if reply_control: |     if reply_control: | ||||||
|         if isinstance(reply_control, str): |         if isinstance(reply_control, str): | ||||||
|             if not reply_control.endswith('#Public'): |             if not reply_control.endswith('#Public'): | ||||||
|                 return False |  | ||||||
|                 # TODO handle non-public reply permissions |                 # TODO handle non-public reply permissions | ||||||
|         print('DEBUG: non-public replies ' + str(reply_control)) |                 print('CAPABILITIES: replies ' + str(reply_control)) | ||||||
|  |                 return False | ||||||
| 
 | 
 | ||||||
|     if 'commentsEnabled' in post_json_object: |     if 'commentsEnabled' in post_json_object: | ||||||
|         return post_json_object['commentsEnabled'] |         return post_json_object['commentsEnabled'] | ||||||
|  |  | ||||||
							
								
								
									
										11
									
								
								utils.py
								
								
								
								
							
							
						
						
									
										11
									
								
								utils.py
								
								
								
								
							|  | @ -4013,9 +4013,18 @@ def is_i2p_request(calling_domain: str, referer_domain: str, | ||||||
|     return False |     return False | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def disallow_announce(content: str, attachment: []) -> bool: | def disallow_announce(content: str, attachment: [], capabilities: {}) -> bool: | ||||||
|     """Are announces/boosts not allowed for the given post? |     """Are announces/boosts not allowed for the given post? | ||||||
|     """ |     """ | ||||||
|  |     # pixelfed style capabilities | ||||||
|  |     if capabilities.get('announce'): | ||||||
|  |         if isinstance(capabilities['announce'], str): | ||||||
|  |             if not capabilities['announce'].endswith('#Public'): | ||||||
|  |                 # TODO handle non-public announce permissions | ||||||
|  |                 print('CAPABILITIES: announce ' + capabilities['announce']) | ||||||
|  |                 return True | ||||||
|  | 
 | ||||||
|  |     # emojis | ||||||
|     disallow_strings = ( |     disallow_strings = ( | ||||||
|         ':boost_no:', |         ':boost_no:', | ||||||
|         ':noboost:', |         ':noboost:', | ||||||
|  |  | ||||||
|  | @ -2637,7 +2637,10 @@ def individual_post_as_html(signing_priv_key_pem: str, | ||||||
|         attachment = [] |         attachment = [] | ||||||
|         if post_json_object['object'].get('attachment'): |         if post_json_object['object'].get('attachment'): | ||||||
|             attachment = post_json_object['object']['attachment'] |             attachment = post_json_object['object']['attachment'] | ||||||
|         if disallow_announce(content_all_str, attachment): |         capabilities = {} | ||||||
|  |         if post_json_object['object'].get('capabilities'): | ||||||
|  |             capabilities = post_json_object['object']['capabilities'] | ||||||
|  |         if disallow_announce(content_all_str, attachment, capabilities): | ||||||
|             announce_str = '' |             announce_str = '' | ||||||
|         # does an emoji indicate a no replies preference? |         # does an emoji indicate a no replies preference? | ||||||
|         # if so then don't show the reply icon |         # if so then don't show the reply icon | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue