mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
Path-ify config.mailboxes_dir
This commit is contained in:
@@ -23,7 +23,7 @@ class Config:
|
|||||||
self.password_min_length = int(params["password_min_length"])
|
self.password_min_length = int(params["password_min_length"])
|
||||||
self.passthrough_senders = params["passthrough_senders"].split()
|
self.passthrough_senders = params["passthrough_senders"].split()
|
||||||
self.passthrough_recipients = params["passthrough_recipients"].split()
|
self.passthrough_recipients = params["passthrough_recipients"].split()
|
||||||
self.mailboxes_dir = params["mailboxes_dir"].strip().rstrip("/")
|
self.mailboxes_dir = Path(params["mailboxes_dir"].strip())
|
||||||
self.passdb_path = params["passdb_path"].strip().rstrip("/")
|
self.passdb_path = params["passdb_path"].strip().rstrip("/")
|
||||||
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
|
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
|
||||||
self.postfix_reinject_port = int(params["postfix_reinject_port"])
|
self.postfix_reinject_port = int(params["postfix_reinject_port"])
|
||||||
@@ -38,7 +38,7 @@ class Config:
|
|||||||
|
|
||||||
def get_user_maildir(self, addr):
|
def get_user_maildir(self, addr):
|
||||||
if addr and addr != "." and "/" not in addr:
|
if addr and addr != "." and "/" not in addr:
|
||||||
res = Path(self.mailboxes_dir).joinpath(addr).resolve()
|
res = self.mailboxes_dir.joinpath(addr).resolve()
|
||||||
if res.is_relative_to(self.mailboxes_dir):
|
if res.is_relative_to(self.mailboxes_dir):
|
||||||
return str(res)
|
return str(res)
|
||||||
raise ValueError(f"invalid address {addr!r}")
|
raise ValueError(f"invalid address {addr!r}")
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
|
||||||
from socketserver import (
|
from socketserver import (
|
||||||
StreamRequestHandler,
|
StreamRequestHandler,
|
||||||
ThreadingMixIn,
|
ThreadingMixIn,
|
||||||
@@ -133,7 +132,7 @@ def main():
|
|||||||
config = read_config(config_path)
|
config = read_config(config_path)
|
||||||
iroh_relay = config.iroh_relay
|
iroh_relay = config.iroh_relay
|
||||||
|
|
||||||
vmail_dir = Path(config.mailboxes_dir)
|
vmail_dir = config.mailboxes_dir
|
||||||
if not vmail_dir.exists():
|
if not vmail_dir.exists():
|
||||||
logging.error("vmail dir does not exist: %r", vmail_dir)
|
logging.error("vmail dir does not exist: %r", vmail_dir)
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ def test_read_config_testrun(make_config):
|
|||||||
|
|
||||||
def test_config_userstate_paths(make_config, tmp_path):
|
def test_config_userstate_paths(make_config, tmp_path):
|
||||||
config = make_config("something.testrun.org")
|
config = make_config("something.testrun.org")
|
||||||
mailboxes_dir = Path(config.mailboxes_dir)
|
mailboxes_dir = config.mailboxes_dir
|
||||||
passdb_path = Path(config.passdb_path)
|
passdb_path = Path(config.passdb_path)
|
||||||
assert mailboxes_dir.name == "something.testrun.org"
|
assert mailboxes_dir.name == "something.testrun.org"
|
||||||
assert passdb_path.name == "passdb.sqlite"
|
assert passdb_path.name == "passdb.sqlite"
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ def test_remove_stale_users(db, example_config):
|
|||||||
|
|
||||||
delete_inactive_users(db, example_config)
|
delete_inactive_users(db, example_config)
|
||||||
|
|
||||||
for p in Path(example_config.mailboxes_dir).iterdir():
|
for p in example_config.mailboxes_dir.iterdir():
|
||||||
assert not p.name.startswith("old")
|
assert not p.name.startswith("old")
|
||||||
|
|
||||||
for addr in to_remove:
|
for addr in to_remove:
|
||||||
|
|||||||
Reference in New Issue
Block a user