following-error
This commit is contained in:
parent
4c0f3087db
commit
1dd34d5818
|
@ -2,6 +2,7 @@ import json
|
||||||
import time
|
import time
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
from psycopg2.errors import UniqueViolation
|
||||||
from sqlalchemy import select, or_
|
from sqlalchemy import select, or_
|
||||||
from sqlalchemy.sql import and_
|
from sqlalchemy.sql import and_
|
||||||
|
|
||||||
|
@ -162,6 +163,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:
|
||||||
|
logger.warn(error)
|
||||||
|
return 'already followed'
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(exc)
|
logger.error(exc)
|
||||||
return exc
|
return exc
|
||||||
|
@ -180,6 +184,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:
|
||||||
|
logger.warn(error)
|
||||||
|
return 'already unfollowed'
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.debug(ex)
|
logger.debug(ex)
|
||||||
return ex
|
return ex
|
||||||
|
@ -208,6 +215,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:
|
||||||
|
logger.warn(error)
|
||||||
|
return 'already followed'
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return exc
|
return exc
|
||||||
|
|
||||||
|
@ -232,6 +242,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:
|
||||||
|
logger.warn(error)
|
||||||
|
return 'already unfollowed'
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
@ -248,6 +261,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:
|
||||||
|
logger.warn(error)
|
||||||
|
return 'already followed'
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
@ -269,6 +285,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:
|
||||||
|
logger.warn(error)
|
||||||
|
return 'already unfollowed'
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return exc
|
return exc
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user