~sircmpwn/sr.ht-dev

lists.sr.ht: Add Archived-At header to list copies v1 PROPOSED

Do we need to URL-encode?
Good catch, it looks like we do. RFC 3986 [1] indicates that the '@'
symbol and the '<'/'>' characters that appear in Message-Ids might need
to be encoded to not conflict with the delimiters in the syntax of
Archived-At. I'll post a v2 patch soon, please correct me if I'm wrong.

[1] https://tools.ietf.org/html/rfc3986#section-2.2
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/sr.ht-dev/%3C20190918003135.26622-1-svmhdvn%40fastmail.com%3E/mbox | git am -3
Learn more about email & git

[PATCH lists.sr.ht] Add Archived-At header to list copies Export this patch

Closes https://todo.sr.ht/~sircmpwn/lists.sr.ht/122
---
 listssrht/process.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/listssrht/process.py b/listssrht/process.py
index 13e0a2d..e6c8ae1 100644
--- a/listssrht/process.py
+++ b/listssrht/process.py
@@ -36,6 +36,7 @@ policy = email.policy.SMTPUTF8.clone(max_line_length=998)
 def _forward(dest, mail):
     domain = cfg("lists.sr.ht", "posting-domain")
     list_name = "{}/{}".format(dest.owner.canonical_name, dest.name)
+    archive_url = "{}/{}".format(cfg("lists.sr.ht", "origin"), list_name)
     list_unsubscribe = list_name + "+unsubscribe@" + domain
     list_subscribe = list_name + "+subscribe@" + domain
     for overwrite in ["List-Unsubscribe", "List-Subscribe", "List-Archive",
@@ -46,8 +47,8 @@ def _forward(dest, mail):
             "<mailto:{}?subject=unsubscribe>".format(list_unsubscribe))
     mail["List-Subscribe"] = (
             "<mailto:{}?subject=subscribe>".format(list_subscribe))
-    mail["List-Archive"] = "<{}/{}>".format(
-            cfg("lists.sr.ht", "origin"), list_name)
+    mail["List-Archive"] = "<{}>".format(archive_url)
+    mail["Archived-At"] = "<{}/{}>".format(archive_url, mail["Message-ID"])
     mail["List-Post"] = "<mailto:{}@{}>".format(list_name, domain)
     mail["List-ID"] = "{} <{}.{}>".format(list_name, list_name, domain)
     mail["Sender"] = "{} <{}@{}>".format(list_name, list_name, domain)
-- 
2.23.0
Do we need to URL-encode?

[PATCH lists.sr.ht v2] Add Archived-At header to list copies Export this patch

Closes https://todo.sr.ht/~sircmpwn/lists.sr.ht/122
---
v2:
  - URL-encoded Message-Id header in the archived message URL

 listssrht/process.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/listssrht/process.py b/listssrht/process.py
index 13e0a2d..253f486 100644
--- a/listssrht/process.py
+++ b/listssrht/process.py
@@ -23,6 +23,7 @@ from datetime import datetime
 from email.mime.text import MIMEText
 from email.utils import parseaddr, getaddresses, formatdate, make_msgid
 from email.utils import parsedate_to_datetime
+from urllib.parse import quote
 
 dispatch = Celery("lists.sr.ht", broker=cfg("lists.sr.ht", "redis"))
 
@@ -36,6 +37,7 @@ policy = email.policy.SMTPUTF8.clone(max_line_length=998)
 def _forward(dest, mail):
     domain = cfg("lists.sr.ht", "posting-domain")
     list_name = "{}/{}".format(dest.owner.canonical_name, dest.name)
+    archive_url = "{}/{}".format(cfg("lists.sr.ht", "origin"), list_name)
     list_unsubscribe = list_name + "+unsubscribe@" + domain
     list_subscribe = list_name + "+subscribe@" + domain
     for overwrite in ["List-Unsubscribe", "List-Subscribe", "List-Archive",
@@ -46,8 +48,8 @@ def _forward(dest, mail):
             "<mailto:{}?subject=unsubscribe>".format(list_unsubscribe))
     mail["List-Subscribe"] = (
             "<mailto:{}?subject=subscribe>".format(list_subscribe))
-    mail["List-Archive"] = "<{}/{}>".format(
-            cfg("lists.sr.ht", "origin"), list_name)
+    mail["List-Archive"] = "<{}>".format(archive_url)
+    mail["Archived-At"] = "<{}/{}>".format(archive_url, quote(mail["Message-ID"]))
     mail["List-Post"] = "<mailto:{}@{}>".format(list_name, domain)
     mail["List-ID"] = "{} <{}.{}>".format(list_name, list_name, domain)
     mail["Sender"] = "{} <{}@{}>".format(list_name, list_name, domain)
-- 
2.23.0
Thanks! I've pushed both of your patches:

To git.sr.ht:~sircmpwn/lists.sr.ht
   0a6420d..3d16202  master -> master
 * [new tag]         0.37.0 -> 0.37.0
View this thread in the archives