cached-auth

This commit is contained in:
2024-01-23 21:34:51 +03:00
parent 987eb8c078
commit c41fe8b6c9
3 changed files with 48 additions and 42 deletions

View File

@@ -63,13 +63,15 @@ def followed_communities(follower_id):
def community_follow(follower_id, slug):
try:
with local_session() as session:
community = session.query(Community).where(Community.slug == slug).one()
cf = CommunityAuthor(author=follower_id, community=community.id)
session.add(cf)
session.commit()
return True
community = session.query(Community).where(Community.slug == slug).first()
if isinstance(community, Community):
cf = CommunityAuthor(author=follower_id, community=community.id)
session.add(cf)
session.commit()
return True
except Exception:
return False
pass
return False
# for mutation.field("unfollow")