forked from rDrama/rDrama
sdffds
parent
c8447c99cc
commit
2301b11e80
|
@ -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,10 +999,10 @@ 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()
|
||||||
|
|
||||||
v.post_count = g.db.query(Submission.id).filter_by(author_id=v.id, is_banned=False, deleted_utc=0).count()
|
v.post_count = g.db.query(Submission.id).filter_by(author_id=v.id, is_banned=False, deleted_utc=0).count()
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
|
@ -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…
Reference in New Issue