Skip to content

Instantly share code, notes, and snippets.

@misteral
Last active October 15, 2023 19:11
Show Gist options
  • Save misteral/1a44462d4b1a1610084687410881e791 to your computer and use it in GitHub Desktop.
Save misteral/1a44462d4b1a1610084687410881e791 to your computer and use it in GitHub Desktop.
Service to set archive status for not properly closed meetings with Amazon Chime service.
# frozen_string_literal: true
# It take current open meetings and change state for other
# to achenved
class ChimeFinishMeetingsService
def self.call
new.call
end
def call
current_active_meetings = ChimeSdk::MeetingCoordinator.list_meetings
list_ids = current_active_meetings.map { |m| m[:Meeting][:MeetingId] }
Meeting.not_finished.where.not(aws_id: list_ids).map(&:system_finish_call!)
end
end
# frozen_string_literal: true
require 'test_helper'
class ChimeFinishMeetingsServiceTest < ActiveSupport::TestCase
def setup
chime_active_meeting = stub_chime
@meeting0 = meetings(:queued)
@meeting0.update(aws_id: chime_active_meeting[:meeting_id])
@meeting1 = meetings(:active)
@meeting2 = meetings(:one)
end
test 'it change old meetins to acheved' do
ChimeFinishMeetingsService.call
assert_equal 'queued', @meeting0.reload.state
assert_equal 'archived', @meeting1.reload.state
assert_equal 'archived', @meeting2.reload.state
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment