delete recordings with account

This commit is contained in:
Joshua Arts
2018-07-27 14:14:48 -04:00
parent 5e5f31c375
commit 7b15b84daa
6 changed files with 15 additions and 7 deletions

View File

@ -3,6 +3,8 @@
class Room < ApplicationRecord
before_create :setup
before_destroy :delete_all_recordings
validates :name, presence: true
belongs_to :owner, class_name: 'User', foreign_key: :user_id
@ -155,6 +157,12 @@ class Room < ApplicationRecord
self.bbb_id = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + Time.now.to_i.to_s).to_s
end
# Deletes all recordings associated with the room.
def delete_all_recordings
record_ids = recordings.map { |r| r[:recordID] }
delete_recording(record_ids)
end
# Generates a three character uid chunk.
def uid_chunk
charset = ("a".."z").to_a - %w(b i l o s) + ("2".."9").to_a - %w(5 8)