From 7a603e9d7e8fa80842e68a2699574ced29ef8366 Mon Sep 17 00:00:00 2001 From: Tim <roadscape@users.noreply.github.com> Date: Tue, 12 Sep 2017 16:14:25 -0400 Subject: [PATCH] ensure community always names an existing account. allow posting in unregistered communities. --- hive/indexer/community.py | 5 ++--- hive/indexer/core.py | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hive/indexer/community.py b/hive/indexer/community.py index 306959c36..98b5eb015 100644 --- a/hive/indexer/community.py +++ b/hive/indexer/community.py @@ -144,9 +144,8 @@ def is_community_post_valid(community, comment: dict) -> str: community_props = get_community(community) if not community_props: - # TODO: if a community is not found, assume it's completely open? - # all we need to do at that point is validate that its a valid acct name. - return False + # if this is not a defined community, it's free to post in. + return True if is_author_muted(author, community): return False diff --git a/hive/indexer/core.py b/hive/indexer/core.py index 05483bc15..317b9f5ec 100755 --- a/hive/indexer/core.py +++ b/hive/indexer/core.py @@ -115,8 +115,16 @@ def register_posts(ops, date): parent_id, parent_depth, category, community = parent_data depth = parent_depth + 1 + # community must be an existing account + if not get_account_id(community): + print("Invalid community @{}/{} -- {}".format(op['author'], op['permlink'], community)) + community = op['author'] + + # validated community; will return None if invalid & defaults to author. is_valid = int(is_community_post_valid(community, op)) + if not is_valid: + print("Invalid post @{}/{} in @{}".format(op['author'], op['permlink'], community)) # if we're reusing a previously-deleted post (rare!), update it if id: -- GitLab