make modmail appear in /search/messages

pull/134/head
Aevann 2023-02-26 11:22:42 +02:00
parent 890fedf1f3
commit 8085fa3351
4 changed files with 11 additions and 3 deletions

View File

@ -53,7 +53,10 @@ def notifications_modmail(v):
try: page = max(int(request.values.get("page", 1)), 1)
except: page = 1
comments = g.db.query(Comment).filter(Comment.sentto==2).order_by(Comment.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE+1).all()
comments = g.db.query(Comment).filter_by(
sentto=MODMAIL_ID,
level=1,
).order_by(Comment.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE+1).all()
next_exists = (len(comments) > PAGE_SIZE)
listing = comments[:PAGE_SIZE]

View File

@ -297,11 +297,15 @@ def searchmessages(v:User):
criteria = searchparse(query)
dm_conditions = [Comment.author_id == v.id, Comment.sentto == v.id]
if v.admin_level >= PERMS['VIEW_MODMAIL']:
dm_conditions.append(Comment.sentto == MODMAIL_ID),
comments = g.db.query(Comment.id) \
.filter(
Comment.sentto != None,
or_(Comment.author_id == v.id, Comment.sentto == v.id),
Comment.parent_submission == None,
or_(*dm_conditions),
)
if 'author' in criteria:

View File

@ -605,7 +605,7 @@ def messagereply(v:User):
parent_comment_id=id,
top_comment_id=parent.top_comment_id,
level=parent.level + 1,
sentto=user_id,
sentto=parent.sentto,
body=body,
body_html=body_html,
)

View File

@ -0,0 +1 @@
select id from comments where parent_submission is null and sentto is null and (top_comment_id in (select id from comments where sentto = 2) or parent_comment_id in (select id from comments where sentto = 2));