If summary is not available then try name field

merge-requests/30/head
Bob Mottram 2024-11-11 10:07:51 +00:00
parent 79e14e2f79
commit b1c4c26cdd
2 changed files with 11 additions and 5 deletions

View File

@ -97,7 +97,7 @@ def meta_data_node_info(base_dir: str,
"text/markdown", "text/x.misskeymarkdown"], "text/markdown", "text/x.misskeymarkdown"],
"FEPs": ["c648", "521a", "8fcf", "4ccd", "c118", "fffd", "FEPs": ["c648", "521a", "8fcf", "4ccd", "c118", "fffd",
"1970", "0837", "7628", "2677", "5e53", "c16b", "1970", "0837", "7628", "2677", "5e53", "c16b",
"5e53", "268d"] "5e53", "268d", "b2b8"]
} }
} }
return nodeinfo return nodeinfo

View File

@ -573,11 +573,17 @@ def _valid_summary(possible_summary: str) -> bool:
def get_summary_from_post(post_json_object: {}, system_language: str, def get_summary_from_post(post_json_object: {}, system_language: str,
languages_understood: []) -> str: languages_understood: []) -> str:
"""Returns the summary from the post in the given language """Returns the summary from the post in the given language
including searching for a matching entry within summaryMap including searching for a matching entry within summaryMap.
Also try the "name" field if summary is not available. See
https://codeberg.org/fediverse/fep/src/branch/main/fep/b2b8/fep-b2b8.md
""" """
summary_str = ''
for summary_fieldname in ('summary', 'name'):
summary_str = \ summary_str = \
get_content_from_post(post_json_object, system_language, get_content_from_post(post_json_object, system_language,
languages_understood, "summary") languages_understood, summary_fieldname)
if summary_str:
break
if summary_str: if summary_str:
summary_str = summary_str.strip() summary_str = summary_str.strip()
if not _valid_summary(summary_str): if not _valid_summary(summary_str):