From fe62d511d926ce5cdd4d9a3699f5688c02bba0f7 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Fri, 22 Nov 2024 16:14:59 +0100 Subject: [PATCH] feat (event) : register to user-domain-changed --- .../user-domain-changed/10configure_module | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 imageroot/events/user-domain-changed/10configure_module diff --git a/imageroot/events/user-domain-changed/10configure_module b/imageroot/events/user-domain-changed/10configure_module new file mode 100755 index 00000000..fa540f26 --- /dev/null +++ b/imageroot/events/user-domain-changed/10configure_module @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +# +# Copyright (C) 2022 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import sys +import json +import os +import webtop +import agent + + +event_input = json.load(sys.stdin) + +rdb = agent.redis_connect(use_replica=True) + +providers = agent.list_service_providers(rdb, 'imap', 'tcp', { + 'module_uuid': os.environ.get('MAIL_MODULE_UUID', '') +}) + +user_domain = providers[0]['user_domain'] + +if event_input.get('domain') == user_domain: + webtop.configure_module(providers[0]['module_id'], os.environ)