mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
fixes
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
Description=Chatmail dict proxy for IMAP METADATA
|
Description=Chatmail dict proxy for IMAP METADATA
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart={execpath} /run/dovecot/metadata.socket vmail {config_path}
|
ExecStart={execpath} /run/dovecot/metadata.socket vmail {config_path} /home/vmail/metadata
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=30
|
RestartSec=30
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import pwd
|
import pwd
|
||||||
|
|
||||||
|
import pathlib
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from socketserver import (
|
from socketserver import (
|
||||||
@@ -145,12 +146,15 @@ class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
socket, username, config = sys.argv[1:]
|
socket, username, config, metadata_dir = sys.argv[1:]
|
||||||
passwd_entry = pwd.getpwnam(username)
|
passwd_entry = pwd.getpwnam(username)
|
||||||
|
|
||||||
# XXX config is not currently used
|
# XXX config is not currently used
|
||||||
config = read_config(config)
|
config = read_config(config)
|
||||||
notifier = Notifier()
|
metadata_dir = pathlib.Path(metadata_dir)
|
||||||
|
if not metadata_dir.exists():
|
||||||
|
metadata_dir.mkdir()
|
||||||
|
notifier = Notifier(metadata_dir)
|
||||||
|
|
||||||
class Handler(StreamRequestHandler):
|
class Handler(StreamRequestHandler):
|
||||||
def handle(self):
|
def handle(self):
|
||||||
|
|||||||
@@ -16,6 +16,22 @@ def notifier(tmp_path):
|
|||||||
return Notifier(metadata_dir)
|
return Notifier(metadata_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def test_notifier_persistence(tmp_path):
|
||||||
|
metadata_dir = tmp_path.joinpath("metadata")
|
||||||
|
metadata_dir.mkdir()
|
||||||
|
notifier1 = Notifier(metadata_dir)
|
||||||
|
notifier2 = Notifier(metadata_dir)
|
||||||
|
assert notifier1.get_token(guid="guid00") is None
|
||||||
|
assert notifier2.get_token(guid="guid00") is None
|
||||||
|
|
||||||
|
notifier1.set_token("guid00", "01234")
|
||||||
|
notifier1.set_token("guid03", "456")
|
||||||
|
assert notifier2.get_token("guid00") == "01234"
|
||||||
|
assert notifier2.get_token("guid03") == "456"
|
||||||
|
notifier2.del_token("guid00")
|
||||||
|
assert notifier1.get_token("guid00") is None
|
||||||
|
|
||||||
|
|
||||||
def test_handle_dovecot_request_lookup_fails(notifier):
|
def test_handle_dovecot_request_lookup_fails(notifier):
|
||||||
res = handle_dovecot_request("Lpriv/123/chatmail", {}, notifier)
|
res = handle_dovecot_request("Lpriv/123/chatmail", {}, notifier)
|
||||||
assert res == "N\n"
|
assert res == "N\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user