Pass project to Entities::Label to check if user is subscribed

This commit is contained in:
Douglas Barbosa Alexandre 2016-11-01 14:06:05 -02:00
parent 091efb3152
commit b34c063ec4
2 changed files with 7 additions and 7 deletions

View File

@ -454,7 +454,7 @@ module API
end
expose :subscribed do |label, options|
label.subscribed?(options[:current_user])
label.subscribed?(options[:current_user], options[:project])
end
end

View File

@ -24,11 +24,11 @@ module API
post ":id/#{type}/:subscribable_id/subscription" do
resource = instance_exec(params[:subscribable_id], &finder)
if resource.subscribed?(current_user)
if resource.subscribed?(current_user, user_project)
not_modified!
else
resource.subscribe(current_user)
present resource, with: entity_class, current_user: current_user
resource.subscribe(current_user, user_project)
present resource, with: entity_class, current_user: current_user, project: user_project
end
end
@ -38,11 +38,11 @@ module API
delete ":id/#{type}/:subscribable_id/subscription" do
resource = instance_exec(params[:subscribable_id], &finder)
if !resource.subscribed?(current_user)
if !resource.subscribed?(current_user, user_project)
not_modified!
else
resource.unsubscribe(current_user)
present resource, with: entity_class, current_user: current_user
resource.unsubscribe(current_user, user_project)
present resource, with: entity_class, current_user: current_user, project: user_project
end
end
end