mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
fix a potential 500 when a universe is prompted
This commit is contained in:
parent
6ca4bfe76c
commit
f767fa50c2
@ -83,10 +83,21 @@ class MainController < ApplicationController
|
||||
|
||||
def set_random_content
|
||||
@activated_content_types.shuffle.each do |content_type|
|
||||
if @universe_scope.present?
|
||||
@content = content_type.constantize.where(user: current_user, universe: @universe_scope).sample
|
||||
if content_type.downcase == "universe"
|
||||
if @universe_scope.present?
|
||||
# when we want to enable prompts for contributing universes we can remove the user:
|
||||
# selector here, but we will need to verify the user has permission to see the universe
|
||||
# when we do that, or else prompts could open leak
|
||||
@content = content_type.constantize.where(user: current_user, id: @universe_scope.id).sample
|
||||
else
|
||||
@content = content_type.constantize.where(user: current_user).sample
|
||||
end
|
||||
else
|
||||
@content = content_type.constantize.where(user: current_user).sample
|
||||
if @universe_scope.present?
|
||||
@content = content_type.constantize.where(user: current_user, universe: @universe_scope).sample
|
||||
else
|
||||
@content = content_type.constantize.where(user: current_user).sample
|
||||
end
|
||||
end
|
||||
|
||||
return if @content.present?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user