21 lines
758 B
Python
21 lines
758 B
Python
from zope import component
|
|
from zope.interface import implementer
|
|
|
|
from ..interfaces import IMailmanService, IConfig, IHTTPClient
|
|
|
|
|
|
@implementer(IMailmanService)
|
|
class RemoteMailmanService:
|
|
def __init__(self):
|
|
cfg = component.getUtility(IConfig)
|
|
self.mailman_host = cfg.get('ceod_mailman_host')
|
|
self.http_client = component.getUtility(IHTTPClient)
|
|
|
|
def subscribe(self, address: str, mailing_list: str):
|
|
resp = self.http_client.post(self.mailman_host, f'/api/mailman/{mailing_list}/{address}')
|
|
resp.raise_for_status()
|
|
|
|
def unsubscribe(self, address: str, mailing_list: str):
|
|
resp = self.http_client.delete(self.mailman_host, f'/api/mailman/{mailing_list}/{address}')
|
|
resp.raise_for_status()
|