Filter out hidden messages in list of messages as well
authorMagnus Hagander <magnus@hagander.net>
Sat, 1 Jul 2017 12:01:00 +0000 (14:01 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sat, 1 Jul 2017 12:01:00 +0000 (14:01 +0200)
There is no reason to include a link to a page that just says "this
message isn't there". And sometimes the spam is found in the subject as
well.

This should probably have been done as part of
d5df0573710c5e5bf562da193c43e650cb070998, but better late than never.

django/archives/mailarchives/views.py

index a2aa5ecbd4fe6897b9ca730aa0155f85a7b59252..037cff8cedffc4536f5264875a75e0a6cc0887f4 100644 (file)
@@ -177,7 +177,7 @@ def render_datelist_from(request, l, d, title, to=None):
        if to:
                datefilter.add(Q(date__lt=to), Q.AND)
 
-       mlist = Message.objects.defer('bodytxt', 'cc', 'to').select_related().filter(datefilter).extra(where=["threadid IN (SELECT threadid FROM list_threads WHERE listid=%s)" % l.listid]).order_by('date')[:200]
+       mlist = Message.objects.defer('bodytxt', 'cc', 'to').select_related().filter(datefilter, hiddenstatus__isnull=True).extra(where=["threadid IN (SELECT threadid FROM list_threads WHERE listid=%s)" % l.listid]).order_by('date')[:200]
 
        allyearmonths = set([(m.date.year, m.date.month) for m in mlist])
        (yearmonth, daysinmonth) = get_monthday_info(mlist, l, d)
@@ -196,7 +196,7 @@ def render_datelist_to(request, l, d, title):
        # Need to sort this backwards in the database to get the LIMIT applied
        # properly, and then manually resort it in the correct order. We can do
        # the second sort safely in python since it's not a lot of items..
-       mlist = sorted(Message.objects.defer('bodytxt', 'cc', 'to').select_related().filter(date__lte=d).extra(where=["threadid IN (SELECT threadid FROM list_threads WHERE listid=%s)" % l.listid]).order_by('-date')[:200], key=lambda m: m.date)
+       mlist = sorted(Message.objects.defer('bodytxt', 'cc', 'to').select_related().filter(date__lte=d, hiddenstatus__isnull=True).extra(where=["threadid IN (SELECT threadid FROM list_threads WHERE listid=%s)" % l.listid]).order_by('-date')[:200], key=lambda m: m.date)
 
        allyearmonths = set([(m.date.year, m.date.month) for m in mlist])
        (yearmonth, daysinmonth) = get_monthday_info(mlist, l, d)
@@ -409,7 +409,7 @@ def message_mbox(request, msgid):
 
        # Rawmsg is not in the django model, so we have to query it separately
        curs = connection.cursor()
-       curs.execute("SELECT messageid, rawtxt FROM messages WHERE threadid=%(thread)s ORDER BY date", {
+       curs.execute("SELECT messageid, rawtxt FROM messages WHERE threadid=%(thread)s AND hiddenstatus IS NULL ORDER BY date", {
                'thread': msg.threadid,
        })