Commit fd668663 authored by Paulina Czempiel's avatar Paulina Czempiel
Browse files

Merge branch 'develop' of into pczempiel_community_roles

parents 82f2370e 354569d1
......@@ -8,6 +8,7 @@ from hive.server.common.helpers import (
from hive.utils.account import safe_db_profile_metadata
......@@ -250,7 +251,7 @@ async def get_ranked_posts(context, sort:str, start_author:str='', start_permlin
result = await _get_ranked_posts_for_observer_communities(db, sort, start_author, start_permlink, limit, observer)
return await process_query_results(result)
if tag and tag[:5] == 'hive-':
if tag and check_community(tag):
result = await _get_ranked_posts_for_communities(db, sort, tag, start_author, start_permlink, limit, observer)
return await process_query_results(result)
......@@ -8,6 +8,7 @@ import datetime
from dateutil.relativedelta import relativedelta
from psycopg2.errors import RaiseException
from jsonrpcserver.exceptions import ApiError as RPCApiError
from import Community
log = logging.getLogger(__name__)
......@@ -81,6 +82,14 @@ def get_hive_accounts_info_view_query_string(names, lite = False):
""".format( ( 'hive_accounts_info_view_lite' if lite else 'hive_accounts_info_view' ), values_str )
return sql
def check_community(name) -> bool:
return Community.validated_name(name) is not None
def valid_community(name):
"""Checks is given name of community matches community regex, if not asserts"""
assert check_community(name), "given community name is not valid"
return name
def valid_account(name, allow_empty=False):
"""Returns validated account name or throws Assert."""
if not name:
......@@ -2338,7 +2338,7 @@
"permlink": "introduce",
"title": "My introduce post",
"body": "This is a cross post of [@test-creator/introduce](/introduceyourself/@test-creator/introduce) by @test-creator.<br><br>crosspost test",
"json_metadata": "{\"app\":\"peakd/2021.01.3\",\"tags\":[\"cross-post\"],\"image\":[],\"original_author\":\"test-creator\",\"original_permlink\":\"introduce\"}"
"json_metadata": "{\"app\":\"peakd/2021.01.3\",\"tags\":[\"cross-post\", \"hive-engine\"],\"image\":[],\"original_author\":\"test-creator\",\"original_permlink\":\"introduce\"}"
Subproject commit 88caa692f239eb4a35754b0168673a131c3c7ab2
Subproject commit 0730539dc6d6b90cd04e2e9d91334c4916b051ea
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment