Skip to content

Commit 2521daa

Browse files
Merge pull request #82 from dontcallmedom/msgid
Add msgid systematically
2 parents aa653a6 + 950539b commit 2521daa

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-python@v5
1515
with:
16-
python-version: '3.7'
16+
python-version: '3.11'
1717
- name: Install dependencies
1818
run: |
1919
python -m pip install --upgrade pip
2020
pip install -r requirements.txt
2121
- name: test WebHook
2222
run: python test_webhook.py
2323
- name: test Digest
24-
run: python test_digest.py
24+
run: python test_digest.py

index.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from email.mime.text import MIMEText
1717
from email.mime.multipart import MIMEMultipart
1818
from email.header import Header
19-
from email.utils import formataddr
19+
from email.utils import formataddr, make_msgid
2020
from email.generator import Generator
2121
import email.charset
2222
from io import StringIO
@@ -756,8 +756,10 @@ def sendMail(
756756
msg["From"] = formataddr((from_name, from_addr))
757757
msg["To"] = ",".join(to_addr)
758758
msg["Subject"] = Header(subject)
759-
if msgid:
760-
msg["Message-ID"] = msgid
759+
if not msgid:
760+
msgid = make_msgid()
761+
msg["Message-ID"] = msgid
762+
761763
if inreplyto:
762764
msg["In-Reply-To"] = inreplyto
763765

test_digest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
config = {
1616
"SMTP_HOST": "localhost",
17+
"SMTP_PORT": "8080",
1718
"EMAIL_FROM": "test@localhost",
1819
"TEMPLATES_DIR": "tests/templates",
1920
"DIGEST_SENDER":"W3C Webmaster via GitHub API",

test_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
config = {
1010
"SMTP_HOST": "localhost",
11+
"SMTP_PORT": "8080",
1112
"EMAIL_FROM": "test@localhost",
1213
"TEMPLATES_DIR": "tests/templates",
1314
"GH_OAUTH_TOKEN": "foo",

test_webhook.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from mock import patch, call
22
import email
3+
import email.utils
34
import unittest
45
import smtplib
56
import json
@@ -42,8 +43,9 @@ def test_ip_check_403(self):
4243
)
4344
assert rv.status_code == 403
4445

46+
@patch("index.make_msgid", return_value="<test@example.com>")
4547
@patch("smtplib.SMTP", autospec=True)
46-
def test_w3c_tr_published(self, mock_smtp):
48+
def test_w3c_tr_published(self, mock_smtp, mock_make_msgid):
4749
data = self.read_file("tests/trpublished-notif.json")
4850
rv = requests.post(
4951
"http://localhost:8000/",

tests/trpublished-notif.msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ Content-Type: text/plain; charset="utf-8"; format="flowed"
44
From: W3C Webmaster via W3C API <test@localhost>
55
To: dom@localhost
66
Subject: "SHACL Use Cases and Requirements" published as a Working Draft
7+
Message-ID: <test@example.com>
78

89
"SHACL Use Cases and Requirements" has just been published as a W3C Working Draft dated 2016-01-22 at http://www.w3.org/TR/2016/WD-shacl-ucr-20160122/.

0 commit comments

Comments
 (0)