Handle message/news

This commit is contained in:
Peter J. Holzer 2019-03-10 22:47:10 +01:00
parent d32c60a318
commit df7fcb5777
2 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,7 @@ def render_message(msg):
msgtmpl = jenv.get_template("message2.html") msgtmpl = jenv.get_template("message2.html")
bodyhtml = render_body(msg) bodyhtml = render_body(msg)
context = { context = {
"msg": msg,
"message_id": msg["Message-Id"], "message_id": msg["Message-Id"],
"subject": msg["Subject"], "subject": msg["Subject"],
"from": msg["From"], "from": msg["From"],
@ -243,6 +244,16 @@ def render_body(msg):
elif content_type == "application/x-gzip": elif content_type == "application/x-gzip":
bodyhtml = save_part(msg) bodyhtml = save_part(msg)
elif content_type == "message/news":
partshtml = []
for part in msg.get_payload():
partshtml.append(render_message(part))
bodytmpl = jenv.get_template("body_message_news.html")
context = {
"msg": msg,
"parts": partshtml,
}
bodyhtml = bodytmpl.render(context)
else: else:
raise RuntimeError("Content-type " + content_type + " not implemented yet") raise RuntimeError("Content-type " + content_type + " not implemented yet")

View File

@ -4,6 +4,7 @@
</div> </div>
<div class="partinner"> <div class="partinner">
<table> <table>
<tr> <th>Newsgroups</th> <td>{{msg.newsgroups}} </td> </tr>
<tr> <th>Message-Id </th> <td>{{message_id}} </td> </tr> <tr> <th>Message-Id </th> <td>{{message_id}} </td> </tr>
<tr> <th>Subject </th> <td class="subject">{{subject}}</td> </tr> <tr> <th>Subject </th> <td class="subject">{{subject}}</td> </tr>
<tr> <th>From </th> <td>{{from}} </td> </tr> <tr> <th>From </th> <td>{{from}} </td> </tr>