mirror of
https://github.com/chatmail/relay.git
synced 2026-05-16 03:24:48 +00:00
introduce basic config file
This commit is contained in:
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