mirror of https://gitlab.com/bashrc2/epicyon
Extra check for edition tag
parent
f27cc4d66e
commit
4e59beab16
16
outbox.py
16
outbox.py
|
@ -63,6 +63,7 @@ from shares import outbox_undo_share_upload
|
||||||
from webapp_post import individual_post_as_html
|
from webapp_post import individual_post_as_html
|
||||||
from speaker import update_speaker
|
from speaker import update_speaker
|
||||||
from reading import store_book_events
|
from reading import store_book_events
|
||||||
|
from reading import has_edition_tag
|
||||||
|
|
||||||
|
|
||||||
def _person_receive_update_outbox(base_dir: str, http_prefix: str,
|
def _person_receive_update_outbox(base_dir: str, http_prefix: str,
|
||||||
|
@ -502,13 +503,14 @@ def post_message_to_outbox(session, translate: {},
|
||||||
theme, system_language,
|
theme, system_language,
|
||||||
outbox_name)
|
outbox_name)
|
||||||
|
|
||||||
store_book_events(base_dir,
|
if has_edition_tag(message_json):
|
||||||
message_json,
|
store_book_events(base_dir,
|
||||||
system_language, [],
|
message_json,
|
||||||
translate, debug,
|
system_language, [],
|
||||||
max_recent_books,
|
translate, debug,
|
||||||
books_cache,
|
max_recent_books,
|
||||||
max_cached_readers)
|
books_cache,
|
||||||
|
max_cached_readers)
|
||||||
|
|
||||||
# save all instance blogs to the news actor
|
# save all instance blogs to the news actor
|
||||||
if post_to_nickname != 'news' and outbox_name == 'tlblogs':
|
if post_to_nickname != 'news' and outbox_name == 'tlblogs':
|
||||||
|
|
27
reading.py
27
reading.py
|
@ -89,6 +89,30 @@ def _get_book_image_from_post(post_json_object: {}) -> str:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def has_edition_tag(post_json_object: {}) -> bool:
|
||||||
|
"""Checks whether the given post has an Edition tag
|
||||||
|
indicating that it contains a book event
|
||||||
|
"""
|
||||||
|
post_obj = post_json_object
|
||||||
|
if has_object_dict(post_json_object):
|
||||||
|
post_obj = post_json_object['object']
|
||||||
|
|
||||||
|
if not post_obj.get('tag'):
|
||||||
|
return False
|
||||||
|
if not isinstance(post_obj['tag'], list):
|
||||||
|
return False
|
||||||
|
for tag in post_obj['tag']:
|
||||||
|
if not isinstance(tag, dict):
|
||||||
|
continue
|
||||||
|
if not tag.get('type'):
|
||||||
|
continue
|
||||||
|
if not isinstance(tag['type'], str):
|
||||||
|
continue
|
||||||
|
if tag['type'] == 'Edition':
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_reading_status(post_json_object: {},
|
def get_reading_status(post_json_object: {},
|
||||||
system_language: str,
|
system_language: str,
|
||||||
languages_understood: [],
|
languages_understood: [],
|
||||||
|
@ -169,6 +193,9 @@ def get_reading_status(post_json_object: {},
|
||||||
book_dict['image_url'] = book_image_url
|
book_dict['image_url'] = book_image_url
|
||||||
return book_dict
|
return book_dict
|
||||||
|
|
||||||
|
if not has_edition_tag(post_json_object):
|
||||||
|
return {}
|
||||||
|
|
||||||
# get the book details from a post tag
|
# get the book details from a post tag
|
||||||
book_dict = get_book_from_post(post_json_object, debug)
|
book_dict = get_book_from_post(post_json_object, debug)
|
||||||
if not book_dict:
|
if not book_dict:
|
||||||
|
|
Loading…
Reference in New Issue