sdffds
This commit is contained in:
parent
54a5727975
commit
5c8759f97a
3 changed files with 8 additions and 10 deletions
|
@ -176,10 +176,8 @@ class User(Base):
|
||||||
def referral_count(self):
|
def referral_count(self):
|
||||||
return len(self.referrals)
|
return len(self.referrals)
|
||||||
|
|
||||||
def has_block(self, target):
|
def is_blocking(self, target):
|
||||||
|
return g.db.query(UserBlock).filter_by(user_id=self.id, target_id=target.id).first()
|
||||||
return g.db.query(UserBlock).filter_by(
|
|
||||||
user_id=self.id, target_id=target.id).first()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
|
|
@ -999,7 +999,7 @@ def submit_post(v):
|
||||||
|
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
|
if not v.is_blocking(snappy):
|
||||||
n = Notification(comment_id=c.id, user_id=v.id)
|
n = Notification(comment_id=c.id, user_id=v.id)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
|
@ -832,7 +832,7 @@ def settings_block_user(v):
|
||||||
if user.id == v.id:
|
if user.id == v.id:
|
||||||
return {"error": "You can't block yourself."}, 409
|
return {"error": "You can't block yourself."}, 409
|
||||||
|
|
||||||
if v.has_block(user):
|
if v.is_blocking(user):
|
||||||
return {"error": f"You have already blocked @{user.username}."}, 409
|
return {"error": f"You have already blocked @{user.username}."}, 409
|
||||||
|
|
||||||
if user.id == NOTIFICATIONS_ID:
|
if user.id == NOTIFICATIONS_ID:
|
||||||
|
@ -863,7 +863,7 @@ def settings_unblock_user(v):
|
||||||
|
|
||||||
user = get_user(request.values.get("username"))
|
user = get_user(request.values.get("username"))
|
||||||
|
|
||||||
x = v.has_block(user)
|
x = v.is_blocking(user)
|
||||||
|
|
||||||
if not x: abort(409)
|
if not x: abort(409)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue