cant-follow-catch-fix
All checks were successful
Deploy on push / deploy (push) Successful in 23s

This commit is contained in:
Untone 2024-05-05 20:44:57 +03:00
parent ac5674d18f
commit 13d144f838

View File

@ -2,7 +2,6 @@ import json
import time import time
from typing import List from typing import List
from psycopg2.errors import UniqueViolation
from sqlalchemy import or_, select from sqlalchemy import or_, select
from sqlalchemy.sql import and_ from sqlalchemy.sql import and_
@ -176,12 +175,9 @@ def topic_follow(follower_id, slug):
topic = session.query(Topic).where(Topic.slug == slug).one() topic = session.query(Topic).where(Topic.slug == slug).one()
_following = TopicFollower(topic=topic.id, follower=follower_id) _following = TopicFollower(topic=topic.id, follower=follower_id)
return None return None
except UniqueViolation as error: except Exception as error:
logger.warn(error) logger.warn(error)
return "already followed" return "cant follow"
except Exception as exc:
logger.error(exc)
return exc
def topic_unfollow(follower_id, slug): def topic_unfollow(follower_id, slug):
@ -197,12 +193,9 @@ def topic_unfollow(follower_id, slug):
session.delete(sub) session.delete(sub)
session.commit() session.commit()
return None return None
except UniqueViolation as error: except Exception as error:
logger.warn(error) logger.warn(error)
return "already unfollowed" return "cant unfollow"
except Exception as ex:
logger.debug(ex)
return ex
def reactions_follow(author_id, shout_id, auto=False): def reactions_follow(author_id, shout_id, auto=False):
@ -228,11 +221,9 @@ def reactions_follow(author_id, shout_id, auto=False):
session.add(following) session.add(following)
session.commit() session.commit()
return None return None
except UniqueViolation as error: except Exception as error:
logger.warn(error) logger.warn(error)
return "already followed" return "cant follow"
except Exception as exc:
return exc
def reactions_unfollow(author_id, shout_id: int): def reactions_unfollow(author_id, shout_id: int):
@ -255,14 +246,9 @@ def reactions_unfollow(author_id, shout_id: int):
session.delete(following) session.delete(following)
session.commit() session.commit()
return None return None
except UniqueViolation as error: except Exception as error:
logger.warn(error) logger.warn(error)
return "already unfollowed" return "cant unfollow"
except Exception as ex:
import traceback
traceback.print_exc()
return ex
# for mutation.field("follow") # for mutation.field("follow")
@ -274,14 +260,9 @@ def author_follow(follower_id, slug):
session.add(af) session.add(af)
session.commit() session.commit()
return None return None
except UniqueViolation as error: except Exception as error:
logger.warn(error) logger.warn(error)
return "already followed" return "cant follow"
except Exception as exc:
import traceback
traceback.print_exc()
return exc
# for mutation.field("unfollow") # for mutation.field("unfollow")
@ -300,11 +281,9 @@ def author_unfollow(follower_id, slug):
session.delete(flw) session.delete(flw)
session.commit() session.commit()
return None return None
except UniqueViolation as error: except Exception as error:
logger.warn(error) logger.warn(error)
return "already unfollowed" return "cant unfollow"
except Exception as exc:
return exc
@query.field("get_topic_followers") @query.field("get_topic_followers")