Don't issue xkey headers for private archives
authorMagnus Hagander <magnus@hagander.net>
Thu, 20 Jun 2019 11:05:51 +0000 (13:05 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 20 Jun 2019 11:05:51 +0000 (13:05 +0200)
django/archives/mailarchives/api.py
django/archives/mailarchives/views.py

index 1409576423ef7fa01f64572c502918248159e20c..3e55fc17eae64eaa391ed9ef5e8fdf2488a975c1 100644 (file)
@@ -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
 
 
index ce5a304087c5c157ca9be088e8859396c55e0d04..6f714da8356ac8261f2d192321015135d9563ec4 100644 (file)
@@ -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