forked from External/greenlight
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:
committed by
farhatahmad
parent
8cbfc3f730
commit
967130e57c
@ -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)}"
|
||||
|
Reference in New Issue
Block a user