Skip to content
Snippets Groups Projects
Select Git revision
  • f2da403135e2b2f641cf0f8219ad5b72083b7dfd
  • master default protected
  • streebog
  • gost28147
  • master-updates
  • ed448
  • shake256
  • curve448
  • ecc-sqrt
  • gosthash94cp
  • cmac64
  • block16-refactor
  • siv-mode
  • cmac-layout
  • delete-des-compat
  • delete-rsa_blind
  • aes-struct-layout
  • release-3.4-fixes
  • struct-layout
  • attribute-deprecated
  • rename-data-symbols
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
  • nettle_3.5rc1
  • nettle_3.4.1_release_20181204
  • nettle_3.4.1rc1
  • nettle_3.4_release_20171119
  • nettle_3.4rc2
  • nettle_3.4rc1
  • nettle_3.3_release_20161001
  • nettle_3.2_release_20160128
  • nettle_3.1.1_release_20150424
  • nettle_3.1_release_20150407
  • nettle_3.1rc3
  • nettle_3.1rc2
  • nettle_3.1rc1
  • nettle_3.0_release_20140607
  • nettle_2.7.1_release_20130528
  • nettle_2.7_release_20130424
  • nettle_2.6_release_20130116
  • nettle_2.5_release_20120707
41 results

base16dec.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    main.py 1.40 KiB
    #!/usr/bin/env python3
    
    import smtpd
    import asyncore
    from email import message_from_bytes
    import email.policy
    from dateutil.parser import parse
    import subprocess
    import re
    
    class CustomSMTPServer(smtpd.SMTPServer):
        def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
            msg = message_from_bytes(data, policy=email.policy.default)
            body = msg.get_content()
            d = parse(msg.get('Date'))
            title = msg.get('Subject')
    
            if not title:
                print("Title missing")
                return
    
            valid_destinations = [
                    'massutskick@vastgota.nation.liu.se',
                    'massutskick@vastgota.lysator.liu.se',
                    ]
    
            for destination in valid_destinations:
                if destination in msg.get('To'):
                    break
            else:
                print('Will only publish massutskick')
                return
    
            title = re.sub('^\[.*\] *', '', title)
    
            subprocess.run(['wp', 'post', 'create',
                    '--post_author=2'
                    f'--post_date={d:%Y-%m-%d}',
                    f"--post_title={title}",
                    '--post_status=publish',
                    '--post_category=Veckomail',
                    f"--post_content=<pre>{body}</pre>"],
                    cwd='/usr/share/wordpress',
                    shell=False)
            return
    
    
    server = CustomSMTPServer(('0.0.0.0', 1025), None,
            decode_data=False)
    asyncore.loop()