forked from rDrama/rDrama
1
0
Fork 0

trying to fix exiling

master
Aevann1 2022-08-20 22:24:20 +02:00
parent b71d55cfb9
commit a36c0f9dd3
3 changed files with 7 additions and 3 deletions

View File

@ -169,7 +169,7 @@ class User(Base):
@lazy
def exiled_from(self, sub):
return self.admin_level < 2 and bool(g.db.query(Exile.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
return bool(g.db.query(Exile.user_id).filter_by(user_id=self.id, sub=sub).one_or_none())
@property
@lazy

View File

@ -45,6 +45,10 @@ def flag_post(pid, v):
sub_to = sub_to.name if sub_to else None
if sub_from == sub_to: abort(400)
if post.author.exiled_from(sub_to):
return {"error": f"User is exiled from this {HOLE_NAME}!"}
post.sub = sub_to
g.db.add(post)

View File

@ -23,7 +23,7 @@ def exile_post(v, pid):
if u.mods(sub): abort(403)
if u.admin_level < 2 and not u.exiled_from(sub):
if not u.exiled_from(sub):
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
g.db.add(exile)
@ -50,7 +50,7 @@ def exile_comment(v, cid):
if u.mods(sub): abort(403)
if u.admin_level < 2 and not u.exiled_from(sub):
if not u.exiled_from(sub):
exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id)
g.db.add(exile)