@@ -25,12 +25,9 @@ from utils.logger import root_logger as logger
|
|||||||
|
|
||||||
def get_entity_field_name(entity_type: str) -> str:
|
def get_entity_field_name(entity_type: str) -> str:
|
||||||
"""Возвращает имя поля для связи с сущностью в модели подписчика"""
|
"""Возвращает имя поля для связи с сущностью в модели подписчика"""
|
||||||
entity_field_mapping = {
|
entity_field_mapping = {"author": "following", "topic": "topic", "community": "community", "shout": "shout"}
|
||||||
"author": "following",
|
if entity_type not in entity_field_mapping:
|
||||||
"topic": "topic",
|
raise ValueError(f"Unknown entity_type: {entity_type}")
|
||||||
"community": "community",
|
|
||||||
"shout": "shout"
|
|
||||||
}
|
|
||||||
return entity_field_mapping[entity_type]
|
return entity_field_mapping[entity_type]
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +97,8 @@ async def follow(
|
|||||||
|
|
||||||
if entity_id is not None and isinstance(entity_id, int):
|
if entity_id is not None and isinstance(entity_id, int):
|
||||||
entity_field = get_entity_field_name(entity_type)
|
entity_field = get_entity_field_name(entity_type)
|
||||||
|
logger.debug(f"entity_type: {entity_type}, entity_field: {entity_field}")
|
||||||
|
|
||||||
existing_sub = (
|
existing_sub = (
|
||||||
session.query(follower_class)
|
session.query(follower_class)
|
||||||
.where(
|
.where(
|
||||||
@@ -223,7 +221,7 @@ async def unfollow(
|
|||||||
|
|
||||||
logger.debug(f"entity_id: {entity_id}")
|
logger.debug(f"entity_id: {entity_id}")
|
||||||
entity_field = get_entity_field_name(entity_type)
|
entity_field = get_entity_field_name(entity_type)
|
||||||
|
|
||||||
sub = (
|
sub = (
|
||||||
session.query(follower_class)
|
session.query(follower_class)
|
||||||
.where(
|
.where(
|
||||||
|
|||||||
Reference in New Issue
Block a user