From b3f77993c780dfd85f9e0f2e8cbb4dc8802918b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Tue, 23 May 2023 10:20:35 +0200 Subject: [PATCH] fedora messaging callback: fix buffering and message headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Bompard --- callback_plugins/fedora_messaging_callback.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/callback_plugins/fedora_messaging_callback.py b/callback_plugins/fedora_messaging_callback.py index 2211bf0082..7eec50971d 100644 --- a/callback_plugins/fedora_messaging_callback.py +++ b/callback_plugins/fedora_messaging_callback.py @@ -51,10 +51,15 @@ def getlogin(): def send_message(msg): msg["id"] = str(uuid.uuid4()) + msg["headers"] = { + "fedora_messaging_schema": "base.message", + "fedora_messaging_severity": None, + } env = os.environ.copy() env["FEDORA_MESSAGING_CONF"] = FEDORA_MESSAGING_CONF - with NamedTemporaryFile(mode="w+") as msg_file: + with NamedTemporaryFile(mode="w+", buffering=1) as msg_file: json.dump(msg, msg_file) + msg_file.write("\n") result = run( ["fedora-messaging", "publish", msg_file.name], stdout=PIPE, stderr=STDOUT, text=True, env=env,