From 43c9825e49d25fbd2c19abcdeb8f73aee8be2a4c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 14 May 2025 10:50:27 +0200 Subject: ... --- user-profiles/feeds/imm-notmuch-insert.py | 52 ------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 user-profiles/feeds/imm-notmuch-insert.py (limited to 'user-profiles/feeds/imm-notmuch-insert.py') diff --git a/user-profiles/feeds/imm-notmuch-insert.py b/user-profiles/feeds/imm-notmuch-insert.py deleted file mode 100644 index b7eed292..00000000 --- a/user-profiles/feeds/imm-notmuch-insert.py +++ /dev/null @@ -1,52 +0,0 @@ -#!@python@/bin/python - -import json -import sys -import subprocess -from io import BytesIO -from email.message import EmailMessage -import configparser -from os import environ -from datetime import * -from dateutil.tz import * -from dateutil.parser import isoparse -from html2text import html2text - -def main(): - notmuchConfig = configparser.ConfigParser() - notmuchConfig.read(environ.get('NOTMUCH_CONFIG')) - - callbackMessage = json.load(sys.stdin) - - msg = EmailMessage() - authors = ', '.join(map(lambda author: author['name'], callbackMessage['feed_item']['authors'])) - if authors: - msg['From'] = f"{callbackMessage['feed_definition']['title']} ({authors}) " - else: - msg['From'] = f"{callbackMessage['feed_definition']['title']} " - msg['To'] = f"{notmuchConfig['user']['name']} <{notmuchConfig['user']['primary_email']}>" - if 'title' in callbackMessage['feed_item'] and callbackMessage['feed_item']['title']: - msg['Subject'] = callbackMessage['feed_item']['title'] - msg['Item-Identifier'] = f"{callbackMessage['feed_item']['identifier']}" - for link in callbackMessage['feed_item']['links']: - msg.add_header('Link', link['uri']) - date = None - if 'date' in callbackMessage['feed_item']: - date = isoparse(callbackMessage['feed_item']['date']) - else: - date = datetime.now(tzlocal()) - msg['Date'] = date.strftime('%a, %e %b %Y %T %z') - - if 'content' in callbackMessage['feed_item'] and callbackMessage['feed_item']['content']: - msg.set_content(html2text(callbackMessage['feed_item']['content'])) - msg.add_alternative(callbackMessage['feed_item']['content'], subtype='html') - - - subprocess.run( - args=['notmuch', 'insert'], - check=True, - input=bytes(msg) - ) - -if __name__ == '__main__': - sys.exit(main()) -- cgit v1.2.3