fix this post not being in my notifications even tho i follow /h/slackernews https://rdrama.net/h/slackernews/post/204394/smartest-marseytrain2-lizfongjones-admits-to-tortious

pull/199/head
Aevann 2023-09-15 01:26:47 +03:00
parent 1b3e59b7a7
commit 8b0daa3aa2
2 changed files with 14 additions and 10 deletions

View File

@ -784,17 +784,19 @@ class User(Base):
@lazy
def post_notifications_count(self):
return g.db.query(Post).filter(
or_(
Post.author_id.in_(self.followed_users),
Post.sub.in_(self.followed_subs)
),
Post.created_utc > self.last_viewed_post_notifs,
or_(
Post.sub.in_(self.followed_subs),
and_(
Post.author_id.in_(self.followed_users),
Post.notify == True,
Post.ghost == False,
),
),
Post.deleted_utc == 0,
Post.is_banned == False,
Post.private == False,
Post.notify == True,
Post.author_id != self.id,
Post.ghost == False,
Post.author_id.notin_(self.userblocks),
or_(Post.sub == None, Post.sub.notin_(self.sub_blocks)),
).count()

View File

@ -166,15 +166,17 @@ def notifications_posts(v):
listing = g.db.query(Post).filter(
or_(
Post.author_id.in_(v.followed_users),
Post.sub.in_(v.followed_subs)
Post.sub.in_(v.followed_subs),
and_(
Post.author_id.in_(v.followed_users),
Post.notify == True,
Post.ghost == False,
),
),
Post.deleted_utc == 0,
Post.is_banned == False,
Post.private == False,
Post.notify == True,
Post.author_id != v.id,
Post.ghost == False,
Post.author_id.notin_(v.userblocks),
or_(Post.sub == None, Post.sub.notin_(v.sub_blocks)),
).options(load_only(Post.id))