forked from MarseyWorld/MarseyWorld
fds
parent
4e10e05dbb
commit
67d9629eac
|
@ -187,11 +187,6 @@ class User(Base):
|
||||||
def csslazy(self):
|
def csslazy(self):
|
||||||
return self.css
|
return self.css
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def notifications(self):
|
|
||||||
return g.db.query(Notification).filter_by(user_id=self.id)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def created_date(self):
|
def created_date(self):
|
||||||
|
|
|
@ -9,7 +9,8 @@ defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
|
||||||
@app.post("/clear")
|
@app.post("/clear")
|
||||||
@auth_required
|
@auth_required
|
||||||
def clear(v):
|
def clear(v):
|
||||||
for n in v.notifications.filter_by(read=False).all():
|
notifs = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(Notification.read == False, Notification.user_id == v.id).all()
|
||||||
|
for n in notifs:
|
||||||
n.read = True
|
n.read = True
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -18,7 +19,7 @@ def clear(v):
|
||||||
@app.get("/unread")
|
@app.get("/unread")
|
||||||
@auth_required
|
@auth_required
|
||||||
def unread(v):
|
def unread(v):
|
||||||
listing = g.db.query(Comment).join(Notification.comment).filter(
|
listing = g.db.query(Notification, Comment).join(Comment, Notification.comment_id == Comment.id).filter(
|
||||||
Notification.read == False,
|
Notification.read == False,
|
||||||
Notification.user_id == v.id,
|
Notification.user_id == v.id,
|
||||||
Comment.is_banned == False,
|
Comment.is_banned == False,
|
||||||
|
@ -26,12 +27,12 @@ def unread(v):
|
||||||
Comment.author_id != AUTOJANNY_ID,
|
Comment.author_id != AUTOJANNY_ID,
|
||||||
).order_by(Notification.created_utc.desc()).all()
|
).order_by(Notification.created_utc.desc()).all()
|
||||||
|
|
||||||
for n in v.notifications.filter_by(read=False).all():
|
for n, c in listing:
|
||||||
n.read = True
|
n.read = True
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return {"data":[x.json for x in listing]}
|
return {"data":[x[1].json for x in listing]}
|
||||||
|
|
||||||
|
|
||||||
@app.get("/notifications")
|
@app.get("/notifications")
|
||||||
|
@ -58,7 +59,8 @@ def notifications(v):
|
||||||
|
|
||||||
listing = []
|
listing = []
|
||||||
|
|
||||||
for index, n. c in enumerate(notifications[:100]):
|
for index, x in enumerate(notifications[:100]):
|
||||||
|
n, c = x
|
||||||
if n.read and index > 24: break
|
if n.read and index > 24: break
|
||||||
elif not n.read:
|
elif not n.read:
|
||||||
n.read = True
|
n.read = True
|
||||||
|
@ -75,7 +77,8 @@ def notifications(v):
|
||||||
|
|
||||||
listing = []
|
listing = []
|
||||||
|
|
||||||
for index, n, c in enumerate(notifications[:100]):
|
for index, x in enumerate(notifications[:100]):
|
||||||
|
n, c = x
|
||||||
if n.read and index > 24: break
|
if n.read and index > 24: break
|
||||||
elif not n.read:
|
elif not n.read:
|
||||||
n.read = True
|
n.read = True
|
||||||
|
|
Loading…
Reference in New Issue