Skip to content
This repository was archived by the owner on Jan 30, 2018. It is now read-only.

Commit 005173a

Browse files
committed
api: do not include uploads unless specified
1 parent 5517570 commit 005173a

File tree

6 files changed

+7
-5
lines changed

6 files changed

+7
-5
lines changed

app/controllers/api_v1/activities_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def show
1818
authorize!(:show, @activity) if @activity
1919

2020
if @activity
21-
api_respond @activity, :include => [:project, :target, :user, :thread_comments]
21+
api_respond @activity, :include => [:project, :target, :user, :thread_comments, :uploads]
2222
else
2323
api_error :not_found, :type => 'ObjectNotFound', :message => 'Not found'
2424
end

app/controllers/api_v1/api_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def load_references(refs)
136136
case ref_class
137137
when 'Comment'
138138
Comment.where(:id => ref.last).includes(:target).all
139+
when 'Upload'
140+
Upload.where(:id => ref.last).includes(:page_slot).all
139141
when 'Note'
140142
Note.where(:id => ref.last).includes(:page_slot).all
141143
when 'Conversation'

app/controllers/api_v1/comments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def index
1919

2020
def show
2121
authorize! :show, @comment
22-
api_respond @comment, :include => [:user]
22+
api_respond @comment, :include => [:user, :uploads]
2323
end
2424

2525
def create

app/controllers/api_v1/conversations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def add_watchers(hash)
120120
end
121121

122122
def api_include
123-
[:comments, :user] & (params[:include]||{}).map(&:to_sym)
123+
[:comments, :user, :uploads] & (params[:include]||{}).map(&:to_sym)
124124
end
125125

126126
end

app/controllers/api_v1/tasks_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ def api_scope
107107
end
108108

109109
def api_include
110-
[:comments, :user, :assigned] & (params[:include]||{}).map(&:to_sym)
110+
[:comments, :user, :assigned, :uploads] & (params[:include]||{}).map(&:to_sym)
111111
end
112112
end

app/models/comment/conversions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def to_api_hash(options = {})
5454
base[:previous_due_on] = previous_due_on
5555
end
5656

57-
if uploads.any?
57+
if Array(options[:include]).include?(:uploads) && uploads.any?
5858
base[:uploads] = uploads.map {|u| u.to_api_hash(options)}
5959
end
6060

0 commit comments

Comments
 (0)