Include short instance description in nodeinfo

merge-requests/30/head
Bob Mottram 2024-06-04 19:52:03 +01:00
parent c50be1c807
commit 3eb9a66e7a
5 changed files with 17 additions and 3 deletions

View File

@ -589,6 +589,8 @@ class EpicyonServer(ThreadingHTTPServer):
thrFederatedSharesWatchdog = None thrFederatedSharesWatchdog = None
thrFederatedBlocksDaemon = None thrFederatedBlocksDaemon = None
qrcode_scale = 6 qrcode_scale = 6
instance_description = ''
instance_description_short = 'Epicyon'
def handle_error(self, request, client_address): def handle_error(self, request, client_address):
# surpress connection reset errors # surpress connection reset errors
@ -806,6 +808,12 @@ def run_daemon(accounts_data_dir: str,
if os.path.isfile(hide_announces_filename): if os.path.isfile(hide_announces_filename):
httpd.hide_announces = load_json(hide_announces_filename) httpd.hide_announces = load_json(hide_announces_filename)
# short description of the instance
httpd.instance_description_short = \
get_config_param(base_dir, 'instanceDescriptionShort')
if httpd.instance_description_short is None:
httpd.instance_description_short = 'Epicyon'
# description of the instance # description of the instance
httpd.instance_description = \ httpd.instance_description = \
get_config_param(base_dir, 'instanceDescription') get_config_param(base_dir, 'instanceDescription')

View File

@ -348,6 +348,7 @@ def daemon_http_get(self) -> None:
self.server.show_node_info_accounts, self.server.show_node_info_accounts,
self.server.registration, self.server.registration,
self.server.domain, self.server.domain,
self.server.instance_description_short,
self.server.instance_description): self.server.instance_description):
return return

View File

@ -38,6 +38,7 @@ def get_nodeinfo(self, ua_str: str, calling_domain: str,
show_node_info_version: bool, show_node_info_version: bool,
show_node_info_accounts: bool, show_node_info_accounts: bool,
registration: bool, domain: str, registration: bool, domain: str,
instance_description_short: str,
instance_description: str) -> bool: instance_description: str) -> bool:
if path.startswith('/nodeinfo/1.0'): if path.startswith('/nodeinfo/1.0'):
http_400(self) http_400(self)
@ -126,6 +127,7 @@ def get_nodeinfo(self, ua_str: str, calling_domain: str,
node_info_version, node_info_version,
show_node_info_accounts, show_node_info_accounts,
domain, domain,
instance_description_short,
instance_description) instance_description)
if info: if info:
msg_str = json.dumps(info) msg_str = json.dumps(info)

View File

@ -1973,7 +1973,7 @@ def _profile_post_instance_desc(self, base_dir: str, fields: {}) -> None:
self.server.instance_description = '' self.server.instance_description = ''
def _profile_post_instance_short_desc(base_dir: str, fields: {}) -> None: def _profile_post_instance_short_desc(self, base_dir: str, fields: {}) -> None:
""" HTTP POST change instance short description """ HTTP POST change instance short description
""" """
curr_instance_description_short = \ curr_instance_description_short = \
@ -1984,10 +1984,12 @@ def _profile_post_instance_short_desc(base_dir: str, fields: {}) -> None:
idesc = fields['instanceDescriptionShort'] idesc = fields['instanceDescriptionShort']
set_config_param(base_dir, set_config_param(base_dir,
'instanceDescriptionShort', idesc) 'instanceDescriptionShort', idesc)
self.server.instance_description_short = idesc
else: else:
if curr_instance_description_short: if curr_instance_description_short:
set_config_param(base_dir, set_config_param(base_dir,
'instanceDescriptionShort', '') 'instanceDescriptionShort', '')
self.server.instance_description_short = 'Epicyon'
def _profile_post_content_license(base_dir: str, fields: {}, self) -> None: def _profile_post_content_license(base_dir: str, fields: {}, self) -> None:
@ -2754,7 +2756,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
_profile_post_content_license(base_dir, fields, self) _profile_post_content_license(base_dir, fields, self)
_profile_post_instance_short_desc(base_dir, fields) _profile_post_instance_short_desc(self, base_dir, fields)
_profile_post_instance_desc(self, base_dir, fields) _profile_post_instance_desc(self, base_dir, fields)

View File

@ -19,6 +19,7 @@ def meta_data_node_info(base_dir: str,
registration: bool, version: str, registration: bool, version: str,
show_accounts: bool, show_accounts: bool,
domain: str, domain: str,
instance_description_short: str,
instance_description: str) -> {}: instance_description: str) -> {}:
""" /nodeinfo/2.2 endpoint """ /nodeinfo/2.2 endpoint
Also see https://socialhub.activitypub.rocks/t/ Also see https://socialhub.activitypub.rocks/t/
@ -49,7 +50,7 @@ def meta_data_node_info(base_dir: str,
'terms': terms_of_service_url 'terms': terms_of_service_url
}, },
"instance": { "instance": {
"name": "Epicyon", "name": instance_description_short,
"description": instance_description "description": instance_description
}, },
"software": { "software": {