RecordingsController.rename()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
  # PATCH /:meetingID/:record_id
38
  def rename
39
    update_recording(params[:record_id], "meta_name" => params[:record_name])
40
41
    redirect_back fallback_location: room_path(@room)
42
  end
43
44
  # DELETE /:meetingID/:record_id
45
  def delete
46
    delete_recording(params[:record_id])
47
48
    # Redirects to the page that made the initial request
49
    redirect_back fallback_location: root_path
50
  end
51
52
  private
53
54
  def find_room
55
    @room = Room.find_by!(bbb_id: params[:meetingID])
56
  end
57
58
  # Ensure the user is logged into the room they are accessing.
59
  def verify_room_ownership
60
    if !current_user || ([email protected]_by?(current_user) &&
61
           !current_user.highest_priority_role.get_permission("can_edit_site_settings") &&
62
           !current_user.has_role?(:super_admin))
63
      redirect_to root_path
64
    end
65
  end
66
end
67