mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
47dfe27dd8
commit
895a5a121b
29
daemon.py
29
daemon.py
|
@ -301,6 +301,7 @@ from languages import set_actor_languages
|
||||||
from languages import get_understood_languages
|
from languages import get_understood_languages
|
||||||
from like import update_likes_collection
|
from like import update_likes_collection
|
||||||
from reaction import update_reaction_collection
|
from reaction import update_reaction_collection
|
||||||
|
from utils import post_summary_contains_links
|
||||||
from utils import resembles_url
|
from utils import resembles_url
|
||||||
from utils import get_url_from_post
|
from utils import get_url_from_post
|
||||||
from utils import date_from_string_format
|
from utils import date_from_string_format
|
||||||
|
@ -2277,33 +2278,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return 3
|
return 3
|
||||||
# check that the summary does not contain links
|
# check that the summary does not contain links
|
||||||
if message_json['object'].get('type') and \
|
if post_summary_contains_links(message_json):
|
||||||
message_json['object'].get('summary'):
|
|
||||||
if message_json['object']['type'] != 'Person' and \
|
|
||||||
message_json['object']['type'] != 'Application' and \
|
|
||||||
message_json['object']['type'] != 'Group':
|
|
||||||
if len(message_json['object']['summary']) > 1024:
|
|
||||||
actor_url = get_actor_from_post(message_json)
|
|
||||||
print('INBOX: summary is too long ' +
|
|
||||||
actor_url + ' ' +
|
|
||||||
message_json['object']['summary'])
|
|
||||||
self._400()
|
|
||||||
self.server.postreq_busy = False
|
|
||||||
return 3
|
|
||||||
if '://' in message_json['object']['summary']:
|
|
||||||
actor_url = get_actor_from_post(message_json)
|
|
||||||
print('INBOX: summary should not contain links ' +
|
|
||||||
actor_url + ' ' +
|
|
||||||
message_json['object']['summary'])
|
|
||||||
self._400()
|
|
||||||
self.server.postreq_busy = False
|
|
||||||
return 3
|
|
||||||
else:
|
|
||||||
if len(message_json['object']['summary']) > 4096:
|
|
||||||
actor_url = get_actor_from_post(message_json)
|
|
||||||
print('INBOX: person summary is too long ' +
|
|
||||||
actor_url + ' ' +
|
|
||||||
message_json['object']['summary'])
|
|
||||||
self._400()
|
self._400()
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return 3
|
return 3
|
||||||
|
|
30
utils.py
30
utils.py
|
@ -4959,3 +4959,33 @@ def local_only_is_local(message_json: {}, domain_full: str) -> bool:
|
||||||
str(message_json))
|
str(message_json))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def post_summary_contains_links(message_json: {}) -> bool:
|
||||||
|
"""check if the json post summary contains links
|
||||||
|
"""
|
||||||
|
if message_json['object'].get('type') and \
|
||||||
|
message_json['object'].get('summary'):
|
||||||
|
if message_json['object']['type'] != 'Person' and \
|
||||||
|
message_json['object']['type'] != 'Application' and \
|
||||||
|
message_json['object']['type'] != 'Group':
|
||||||
|
if len(message_json['object']['summary']) > 1024:
|
||||||
|
actor_url = get_actor_from_post(message_json)
|
||||||
|
print('INBOX: summary is too long ' +
|
||||||
|
actor_url + ' ' +
|
||||||
|
message_json['object']['summary'])
|
||||||
|
return True
|
||||||
|
if '://' in message_json['object']['summary']:
|
||||||
|
actor_url = get_actor_from_post(message_json)
|
||||||
|
print('INBOX: summary should not contain links ' +
|
||||||
|
actor_url + ' ' +
|
||||||
|
message_json['object']['summary'])
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
if len(message_json['object']['summary']) > 4096:
|
||||||
|
actor_url = get_actor_from_post(message_json)
|
||||||
|
print('INBOX: person summary is too long ' +
|
||||||
|
actor_url + ' ' +
|
||||||
|
message_json['object']['summary'])
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue