Compare commits

...

2 Commits

Author SHA1 Message Date
Bilal
848c02d88f add log when broadcast is ignored 2020-06-29 17:10:06 +02:00
Bilal
56b66bbf67 handle webhook request for unknown broadcast 2020-06-29 15:18:31 +02:00
2 changed files with 15 additions and 2 deletions

View File

@@ -60,10 +60,16 @@ class StreamNotificationsController < ApplicationController
def set_broadcast
if notification_type == "video.asset.static_renditions.ready"
live_stream_id = notification.dig(:stream_notification, :data, :live_stream_id)
@broadcast = Broadcast.find_by!(stream_uid: live_stream_id)
@broadcast = Broadcast.find_by(stream_uid: live_stream_id)
else
@broadcast = Broadcast.find_by!(stream_uid: notification_object_id)
@broadcast = Broadcast.find_by(stream_uid: notification_object_id)
end
if @broadcast.nil?
logger.info "Ignoring broadcast from other environment. Type = #{notification_type}. Id = #{live_stream_id} / #{notification_object_id}"
head :ok
end
head :ok if @broadcast.nil?
end
def notify_users

View File

@@ -7,6 +7,7 @@ RSpec.describe StreamNotificationsController, type: :controller do
let(:active_status) { {type: "video.live_stream.active", object: { id: "mux_stream" }} }
let(:disconnected_status) { {type: "video.live_stream.disconnected", object: { id: "mux_stream" }} }
let(:idle_status) { {type: "video.live_stream.idle", object: { id: "mux_stream" }} }
let(:idle_status_for_unknown_broadcast) { {type: "video.live_stream.idle", object: { id: "unknown-id" }} }
let(:asset_ready) { {
type: "video.asset.static_renditions.ready",
object: { id: "asset_uid" },
@@ -59,6 +60,12 @@ RSpec.describe StreamNotificationsController, type: :controller do
expect(BroadcastsChannel).to have_received(:stream_recording_ready)
end
it "returns OK response even for non-existing broadcast" do
post :create, params: idle_status_for_unknown_broadcast
expect(response).to be_successful
end
end
after do