From 8c67a663651f1f4f9eaaaa7fa4377fc18d8a26a4 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Thu, 20 Jun 2019 13:05:51 +0200 Subject: [PATCH] Don't issue xkey headers for private archives --- django/archives/mailarchives/api.py | 5 +++-- django/archives/mailarchives/views.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/django/archives/mailarchives/api.py b/django/archives/mailarchives/api.py index 1409576..3e55fc1 100644 --- a/django/archives/mailarchives/api.py +++ b/django/archives/mailarchives/api.py @@ -84,7 +84,7 @@ def latest(request, listname): # Make sure this expires from the varnish cache when new entries show # up in this month. # XXX: need to deal with the global view, but for now API callers come in directly - if list: + if list and settings.PUBLIC_ARCHIVES: resp['xkey'] = ' '.join(['pgam_{0}/{1}/{2}'.format(l.listid, year, month) for year, month in allyearmonths]) return resp @@ -112,7 +112,8 @@ def thread(request, msgid): 'atts': [{'id': a.id, 'name': a.filename} for a in m.attachment_set.all()], } for m in mlist], resp) - resp['xkey'] = 'pgat_{0}'.format(msg.threadid) + if settings.PUBLIC_ARCHIVES: + resp['xkey'] = 'pgat_{0}'.format(msg.threadid) return resp diff --git a/django/archives/mailarchives/views.py b/django/archives/mailarchives/views.py index ce5a304..6f714da 100644 --- a/django/archives/mailarchives/views.py +++ b/django/archives/mailarchives/views.py @@ -285,7 +285,8 @@ def _render_datelist(request, l, d, datefilter, title, queryproc): 'daysinmonth': daysinmonth, 'yearmonth': yearmonth, }) - r['xkey'] = ' '.join(['pgam_{0}/{1}/{2}'.format(l.listid, year, month) for year, month in allyearmonths]) + if settings.PUBLIC_ARCHIVES: + r['xkey'] = ' '.join(['pgam_{0}/{1}/{2}'.format(l.listid, year, month) for year, month in allyearmonths]) return r @@ -490,7 +491,8 @@ def message(request, msgid): 'lists': lists, 'nextprev': nextprev, }) - r['xkey'] = 'pgat_{0}'.format(m.threadid) + if settings.PUBLIC_ARCHIVES: + r['xkey'] = 'pgat_{0}'.format(m.threadid) r['Last-Modified'] = http_date(newest) return r @@ -520,7 +522,8 @@ def message_flat(request, msgid): 'lists': lists, 'isfirst': isfirst, }) - r['xkey'] = 'pgat_{0}'.format(msg.threadid) + if settings.PUBLIC_ARCHIVES: + r['xkey'] = 'pgat_{0}'.format(msg.threadid) r['Last-Modified'] = http_date(newest) return r @@ -542,7 +545,8 @@ def message_raw(request, msgid): r = HttpResponse('This message has been hidden.', content_type='text/plain') else: r = HttpResponse(row[0][2], content_type='text/plain') - r['xkey'] = 'pgat_{0}'.format(row[0][0]) + if settings.PUBLIC_ARCHIVES: + r['xkey'] = 'pgat_{0}'.format(row[0][0]) return r -- 2.39.5