diff --git a/koji-rocketmessaging/koji-rocketmessaging.py b/koji-rocketmessaging/koji-rocketmessaging.py index c466531..9b58ead 100644 --- a/koji-rocketmessaging/koji-rocketmessaging.py +++ b/koji-rocketmessaging/koji-rocketmessaging.py @@ -3,18 +3,21 @@ # Koji callback plugin for sending notifications about events to fedora-messaging # Copyright (c) 2009-2023 Red Hat, Inc. # -# Source: https://github.com/fedora-infra/koji-fedoramessaging +# Source: https://src.koozali.org/infra/koji-rocketamessaging # # Authors: # Ralph Bean # Mike Bonnet # Aurelien Bompard +# +# Amended to fit RocketChat: +# Trevor Batley import logging import re -import fedora_messaging.api -import fedora_messaging.exceptions +import rocket_messaging.api +import rocket_messaging.exceptions import kojihub import pkg_resources from jsonschema.exceptions import ValidationError @@ -315,19 +318,19 @@ def send_messages(cbtype, *args, **kws): log.info(f"Publishing message on topic {topic}") log.debug(f"Message body {message['msg']}") try: - fedora_messaging.api.publish(msg) + rocket_messaging.api.publish(msg) except ValidationError as e: log.exception( f"Schema for {topic} message (id {msg.id}) from Koji not valid " - f"trying to send message as generic fedoramessaging message. " + f"trying to send message as generic rocketmessaging message. " f"Error: {e}" ) - newmsg = fedora_messaging.api.Message(topic=topic, body=message["msg"]) + newmsg = rocket_messaging.api.Message(topic=topic, body=message["msg"]) newmsg.id = msg.id - fedora_messaging.api.publish(newmsg) - except fedora_messaging.exceptions.PublishReturned as e: + rocket_messaging.api.publish(newmsg) + except rocket_messaging.exceptions.PublishReturned as e: log.warning("Fedora Messaging broker rejected message %s: %s", msg.id, e) - except fedora_messaging.exceptions.ConnectionException as e: + except rocket_messaging.exceptions.ConnectionException as e: log.warning("Error sending message %s: %s", msg.id, e) except Exception: log.exception("Un-expected error sending fedora-messaging message")