Completed
Branch v2.4-alpha (b4736b)
by Ahmad
05:54
created

RecordingsController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 41
rs 10
c 1
b 0
f 0
wmc 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 10 2
A delete() 0 6 1
1
# frozen_string_literal: true
2
3
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
4
#
5
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
6
#
7
# This program is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU Lesser General Public License as published by the Free Software
9
# Foundation; either version 3.0 of the License, or (at your option) any later
10
# version.
11
#
12
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
#
16
# You should have received a copy of the GNU Lesser General Public License along
17
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>
18
19
class RecordingsController < ApplicationController
20
  before_action :find_room
21
  before_action :verify_room_ownership
22
23
  META_LISTED = "gl-listed"
24
25
  # POST /:meetingID/:record_id
26
  def update
27
    meta = {
28
      "meta_#{META_LISTED}" => (params[:state] == "public"),
29
    }
30
31
    res = update_recording(params[:record_id], meta)
32
33
    # Redirects to the page that made the initial request
34
    redirect_back fallback_location: root_path if res[:updated]
35
  end
36
37
  # DELETE /:meetingID/:record_id
38
  def delete
39
    delete_recording(params[:record_id])
40
41
    # Redirects to the page that made the initial request
42
    redirect_back fallback_location: root_path
43
  end
44
45
  private
46
47
  def find_room
48
    @room = Room.find_by!(bbb_id: params[:meetingID])
49
  end
50
51
  # Ensure the user is logged into the room they are accessing.
52
  def verify_room_ownership
53
    if !current_user || ([email protected]_by?(current_user) &&
54
           !current_user.highest_priority_role.can_edit_site_settings &&
55
           !current_user.has_role?(:super_admin))
56
      redirect_to root_path
57
    end
58
  end
59
end
60