From d03f6de89038a8c8e48179a5152c013cb0febcfe Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <alexander.olofsson@liu.se> Date: Thu, 15 Dec 2022 11:22:15 +0100 Subject: [PATCH] Fix some broken code from the restructuring --- .../foreman_notification_send/sender_base.rb | 2 +- .../foreman_notification_send/sender_matrix.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/services/foreman_notification_send/sender_base.rb b/app/services/foreman_notification_send/sender_base.rb index fba35c5..98574e6 100644 --- a/app/services/foreman_notification_send/sender_base.rb +++ b/app/services/foreman_notification_send/sender_base.rb @@ -3,7 +3,7 @@ module ForemanNotificationSend class SenderBase def self.create_sender(backend:, **args) - return SenderMatrix.new(args) if backend == :matrix + return SenderMatrix.new(**args) if backend == :matrix raise NotImplementedError, 'Only Matrix backend implemented at the moment' end diff --git a/app/services/foreman_notification_send/sender_matrix.rb b/app/services/foreman_notification_send/sender_matrix.rb index a5e6bf8..c25a6ac 100644 --- a/app/services/foreman_notification_send/sender_matrix.rb +++ b/app/services/foreman_notification_send/sender_matrix.rb @@ -1,10 +1,12 @@ # frozen_string_literal: true -require 'matrix_sdk/api' +require 'matrix_sdk' module ForemanNotificationSend class SenderMatrix < SenderBase def initialize(hs_url:, access_token:, room:, msgtype: 'm.notice') + super() + room = MatrixSdk::MXID.new room unless room.is_a?(MatrixSdk::MXID) raise ArgumentError, 'room must be a Matrix room ID/Alias' unless room.room? @@ -12,12 +14,10 @@ module ForemanNotificationSend @access_token = access_token @room_id = room @msgtype = msgtype - - super end def send_notification(notification) - room.send_html(notification.to_html, notification.to_body, msgtype: @msgtype) + room.send_html(notification.to_html, notification.to_markdown, msgtype: @msgtype) end private @@ -28,9 +28,9 @@ module ForemanNotificationSend def room @room ||= if @room_id.room_id? - @client.ensure_room(@room_id) + client.ensure_room(@room_id) else - @client.fetch_room(@room_id) || @client.join_room(@room_id) + client.fetch_room(@room_id) || client.join_room(@room_id) end end end -- GitLab