Skip to content

Commit

Permalink
Fixed room remove task (bigbluebutton#1695)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored May 28, 2020
1 parent fe363e7 commit 8444b2c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/tasks/room.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ require 'bigbluebutton_api'
namespace :room do
desc "Removes all rooms for users that can't create rooms"
task :remove, [:include_used] => :environment do |_task, args|
roles = Role.where(role_permissions: { name: "can_create_rooms", value: "false" }).pluck(:name)
users = User.with_role(roles)
roles = Role.where(role_permissions: { name: "can_create_rooms", value: "false" }).pluck(:name, :priority)
other_roles = Role.where(role_permissions: { name: "can_create_rooms", value: "", enabled: "false" }).pluck(:name, :priority)

roles_without_rooms = roles + other_roles
roles_arr = []

roles_without_rooms.each do |role|
roles_arr << role[0]
end

users = User.with_role(roles_arr)
users.each do |user|
puts "Destroying #{user.uid} rooms"
puts "Destroying #{user.uid} rooms - role: #{user.role.name}"
user.rooms.each do |room|
if room.sessions.positive? && args[:include_used] != "true"
puts "Skipping room #{room.uid}"
Expand Down

0 comments on commit 8444b2c

Please sign in to comment.