mirror of https://gitlab.com/bashrc2/epicyon
Show novel fields
parent
ef60035949
commit
9325da91a6
10
epicyon.py
10
epicyon.py
|
@ -28,6 +28,7 @@ from bookmarks import send_bookmark_via_server
|
|||
from bookmarks import send_undo_bookmark_via_server
|
||||
from conversation import download_conversation_posts
|
||||
from keys import get_instance_actor_key
|
||||
from posts import novel_fields
|
||||
from posts import set_post_expiry_days
|
||||
from posts import send_mute_via_server
|
||||
from posts import send_undo_mute_via_server
|
||||
|
@ -544,6 +545,11 @@ def _command_options() -> None:
|
|||
const=True, default=False,
|
||||
help="Notification daemon does not wait for " +
|
||||
"keypresses")
|
||||
parser.add_argument("--novel",
|
||||
dest='novel_fields',
|
||||
type=str2bool, nargs='?',
|
||||
const=True, default=False,
|
||||
help="Show any novel fields within posts")
|
||||
parser.add_argument("--notifyShowNewPosts",
|
||||
dest='notifyShowNewPosts',
|
||||
type=str2bool, nargs='?',
|
||||
|
@ -3113,6 +3119,10 @@ def _command_options() -> None:
|
|||
print('Passwords file not found')
|
||||
sys.exit()
|
||||
|
||||
if argb.novel_fields:
|
||||
novel_fields(base_dir)
|
||||
sys.exit()
|
||||
|
||||
if argb.archive:
|
||||
archive_lower = argb.archive.lower()
|
||||
if string_ends_with(archive_lower, ('null', 'delete', 'none')):
|
||||
|
|
49
posts.py
49
posts.py
|
@ -4988,6 +4988,55 @@ def _expire_posts_cache_for_person(base_dir: str,
|
|||
return expired_post_count
|
||||
|
||||
|
||||
def _novel_fields_for_person(nickname: str, domain: str,
|
||||
base_dir: str, boxname: str) -> None:
|
||||
"""Check posts for a person to report any novel fields
|
||||
"""
|
||||
if boxname not in ('inbox'):
|
||||
return
|
||||
box_dir = create_person_dir(nickname, domain, base_dir, boxname)
|
||||
posts_in_box = os.scandir(box_dir)
|
||||
|
||||
posts_ctr = 0
|
||||
fields = []
|
||||
# TODO
|
||||
expected_fields = []
|
||||
for post_filename in posts_in_box:
|
||||
post_filename = post_filename.name
|
||||
if not post_filename.endswith('.json'):
|
||||
continue
|
||||
full_filename = os.path.join(box_dir, post_filename)
|
||||
if not os.path.isfile(full_filename):
|
||||
continue
|
||||
post_json_object = load_json(full_filename)
|
||||
if not has_object_dict(post_json_object):
|
||||
continue
|
||||
for fieldname, _ in post_json_object['object']:
|
||||
if fieldname in expected_fields:
|
||||
continue
|
||||
if fieldname not in fields:
|
||||
fields.append(fieldname)
|
||||
print(fieldname + ' ' + full_filename)
|
||||
posts_ctr += 1
|
||||
|
||||
print('Checked ' + str(posts_ctr) + ' ' + boxname +
|
||||
' posts for ' + nickname + '@' + domain)
|
||||
|
||||
|
||||
def novel_fields(base_dir: str) -> None:
|
||||
"""Reports any unexpected fields within posts
|
||||
"""
|
||||
dir_str = data_dir(base_dir)
|
||||
for _, dirs, _ in os.walk(dir_str):
|
||||
for handle in dirs:
|
||||
if '@' in handle:
|
||||
nickname = handle.split('@')[0]
|
||||
domain = handle.split('@')[1]
|
||||
_novel_fields_for_person(nickname, domain, base_dir,
|
||||
'inbox')
|
||||
break
|
||||
|
||||
|
||||
def archive_posts(base_dir: str, http_prefix: str, archive_dir: str,
|
||||
recent_posts_cache: {},
|
||||
max_posts_in_box: int,
|
||||
|
|
Loading…
Reference in New Issue