just changed fedora to rocket

This commit is contained in:
Trevor Batley 2024-10-03 16:57:33 +10:00
parent 68417f8226
commit f1d7dadac4

View File

@ -3,18 +3,21 @@
# Koji callback plugin for sending notifications about events to fedora-messaging # Koji callback plugin for sending notifications about events to fedora-messaging
# Copyright (c) 2009-2023 Red Hat, Inc. # Copyright (c) 2009-2023 Red Hat, Inc.
# #
# Source: https://github.com/fedora-infra/koji-fedoramessaging # Source: https://src.koozali.org/infra/koji-rocketamessaging
# #
# Authors: # Authors:
# Ralph Bean <rbean@redhat.com> # Ralph Bean <rbean@redhat.com>
# Mike Bonnet <mikeb@redhat.com> # Mike Bonnet <mikeb@redhat.com>
# Aurelien Bompard <abompard@fedoraproject.org> # Aurelien Bompard <abompard@fedoraproject.org>
#
# Amended to fit RocketChat:
# Trevor Batley <trevor@batley.id.au>
import logging import logging
import re import re
import fedora_messaging.api import rocket_messaging.api
import fedora_messaging.exceptions import rocket_messaging.exceptions
import kojihub import kojihub
import pkg_resources import pkg_resources
from jsonschema.exceptions import ValidationError from jsonschema.exceptions import ValidationError
@ -315,19 +318,19 @@ def send_messages(cbtype, *args, **kws):
log.info(f"Publishing message on topic {topic}") log.info(f"Publishing message on topic {topic}")
log.debug(f"Message body {message['msg']}") log.debug(f"Message body {message['msg']}")
try: try:
fedora_messaging.api.publish(msg) rocket_messaging.api.publish(msg)
except ValidationError as e: except ValidationError as e:
log.exception( log.exception(
f"Schema for {topic} message (id {msg.id}) from Koji not valid " 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}" 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 newmsg.id = msg.id
fedora_messaging.api.publish(newmsg) rocket_messaging.api.publish(newmsg)
except fedora_messaging.exceptions.PublishReturned as e: except rocket_messaging.exceptions.PublishReturned as e:
log.warning("Fedora Messaging broker rejected message %s: %s", msg.id, 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) log.warning("Error sending message %s: %s", msg.id, e)
except Exception: except Exception:
log.exception("Un-expected error sending fedora-messaging message") log.exception("Un-expected error sending fedora-messaging message")