GRN2-253: Added the ability to share rooms across multiple users (#912)

* Added ability to share rooms with other users

* Fixed testcases
This commit is contained in:
Ahmad Farhat
2020-01-23 09:04:41 -05:00
committed by farhatahmad
parent 8cbfc3f730
commit 967130e57c
36 changed files with 748 additions and 55 deletions

View File

@ -26,6 +26,7 @@ class Room < ApplicationRecord
validates :name, presence: true
belongs_to :owner, class_name: 'User', foreign_key: :user_id
has_many :shared_access
def self.admins_search(string)
active_database = Rails.configuration.database_configuration[Rails.env]["adapter"]
@ -59,6 +60,15 @@ class Room < ApplicationRecord
user.rooms.include?(self)
end
def shared_users
User.where(id: shared_access.pluck(:user_id))
end
def shared_with?(user)
return false if user.nil?
shared_users.include?(user)
end
# Determines the invite path for the room.
def invite_path
"#{Rails.configuration.relative_url_root}/#{CGI.escape(uid)}"