mirror of
https://github.com/chatmail/relay.git
synced 2026-05-16 15:48:57 +00:00
introduce basic config file
This commit is contained in:
@@ -4,9 +4,10 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "chatmaild"
|
||||
version = "0.1"
|
||||
version = "0.2"
|
||||
dependencies = [
|
||||
"aiosmtpd",
|
||||
"iniconfig",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
||||
26
chatmaild/src/chatmaild/config.py
Normal file
26
chatmaild/src/chatmaild/config.py
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
from fnmatch import fnmatch
|
||||
import iniconfig
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self, mailname, section):
|
||||
self.mailname = mailname
|
||||
self.privacy_postal = section.get("privacy_postal")
|
||||
self.privacy_mail = section.get("privacy_mail")
|
||||
self.privacy_pdo = section.get("privacy_pdo")
|
||||
self.privacy_supervisor = section.get("privacy_supervisor")
|
||||
self.has_privacy_policy = self.privacy_mail != None
|
||||
|
||||
|
||||
def read_config(inipath, mailname):
|
||||
ini = iniconfig.IniConfig(inipath)
|
||||
privacy = None
|
||||
for section in ini:
|
||||
if section.name.startswith("privacy:"):
|
||||
domain = section["domain"]
|
||||
if fnmatch(mailname, domain):
|
||||
privacy = section
|
||||
break
|
||||
|
||||
return Config(mailname, privacy or {})
|
||||
Reference in New Issue
Block a user