mirror of https://gitlab.com/bashrc2/epicyon
Get understood languages for actor making new post
parent
c7f257380d
commit
b659627d44
73
daemon.py
73
daemon.py
|
@ -242,6 +242,7 @@ from categories import set_hashtag_category
|
|||
from categories import update_hashtag_categories
|
||||
from languages import get_actor_languages
|
||||
from languages import set_actor_languages
|
||||
from languages import get_understood_languages
|
||||
from like import update_likes_collection
|
||||
from reaction import update_reaction_collection
|
||||
from utils import undo_reaction_collection_entry
|
||||
|
@ -499,6 +500,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
city = get_spoofed_city(self.server.city,
|
||||
self.server.base_dir,
|
||||
nickname, self.server.domain)
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
|
||||
message_json = \
|
||||
create_public_post(self.server.base_dir,
|
||||
|
@ -520,7 +527,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
self.server.languages_understood)
|
||||
languages_understood)
|
||||
if message_json:
|
||||
# name field contains the answer
|
||||
message_json['object']['name'] = answer
|
||||
|
@ -16812,6 +16819,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id = None
|
||||
if fields.get('conversationId'):
|
||||
conversation_id = fields['conversationId']
|
||||
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
|
||||
message_json = \
|
||||
create_public_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -16833,7 +16848,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
self.server.languages_understood)
|
||||
languages_understood)
|
||||
if message_json:
|
||||
if fields['schedulePost']:
|
||||
return 1
|
||||
|
@ -16900,6 +16915,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id = None
|
||||
if fields.get('conversationId'):
|
||||
conversation_id = fields['conversationId']
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
message_json = \
|
||||
create_blog_post(self.server.base_dir, nickname,
|
||||
self.server.domain, self.server.port,
|
||||
|
@ -16920,7 +16941,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
self.server.languages_understood)
|
||||
languages_understood)
|
||||
if message_json:
|
||||
if fields['schedulePost']:
|
||||
return 1
|
||||
|
@ -17052,6 +17073,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields.get('conversationId'):
|
||||
conversation_id = fields['conversationId']
|
||||
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
|
||||
message_json = \
|
||||
create_unlisted_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -17074,7 +17102,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
self.server.languages_understood)
|
||||
languages_understood)
|
||||
if message_json:
|
||||
if fields['schedulePost']:
|
||||
return 1
|
||||
|
@ -17104,7 +17132,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id = fields['conversationId']
|
||||
|
||||
mentions_message = mentions_str + fields['message']
|
||||
languages_understood = self.server.languages_understood
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
message_json = \
|
||||
create_followers_only_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -17162,7 +17195,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id = fields['conversationId']
|
||||
content_license_url = self.server.content_license_url
|
||||
|
||||
languages_understood = self.server.languages_understood
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
|
||||
message_json = \
|
||||
create_direct_message_post(self.server.base_dir,
|
||||
|
@ -17226,7 +17264,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
comments_enabled = False
|
||||
conversation_id = None
|
||||
mentions_message = mentions_str + fields['message']
|
||||
languages_understood = self.server.languages_understood
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
message_json = \
|
||||
create_direct_message_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -17273,6 +17316,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.base_dir,
|
||||
nickname,
|
||||
self.server.domain)
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
message_json = \
|
||||
create_report_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -17287,7 +17336,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.system_language,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
self.server.languages_understood)
|
||||
languages_understood)
|
||||
if message_json:
|
||||
if self._post_to_outbox(message_json,
|
||||
self.server.project_version,
|
||||
|
@ -17312,6 +17361,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname,
|
||||
self.server.domain)
|
||||
int_duration = int(fields['duration'])
|
||||
languages_understood = \
|
||||
get_understood_languages(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
message_json = \
|
||||
create_question_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -17329,7 +17384,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.system_language,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
self.server.languages_understood)
|
||||
languages_understood)
|
||||
if message_json:
|
||||
if self.server.debug:
|
||||
print('DEBUG: new Question')
|
||||
|
|
14
languages.py
14
languages.py
|
@ -33,6 +33,20 @@ def get_actor_languages(actor_json: {}) -> str:
|
|||
return languages_str
|
||||
|
||||
|
||||
def get_understood_languages(base_dir: str, http_prefix: str,
|
||||
nickname: str, domain_full: str,
|
||||
person_cache: {}) -> []:
|
||||
"""Returns a list of understood languages for the given account
|
||||
"""
|
||||
person_url = local_actor_url(http_prefix, nickname, domain_full)
|
||||
actor_json = \
|
||||
get_person_from_cache(base_dir, person_url, person_cache, False)
|
||||
if not actor_json:
|
||||
print('WARN: unable to load actor to obtain languages ' + person_url)
|
||||
return []
|
||||
return get_actor_languages_list(actor_json)
|
||||
|
||||
|
||||
def set_actor_languages(base_dir: str, actor_json: {},
|
||||
languages_str: str) -> None:
|
||||
"""Sets the languages used by the given actor
|
||||
|
|
Loading…
Reference in New Issue