gitlab-org--gitlab-foss/app/serializers/discussion_entity.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
923 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class DiscussionEntity < BaseDiscussionEntity
2018-04-03 12:03:00 -04:00
expose :notes do |discussion, opts|
request.note_entity.represent(
discussion.notes,
opts.merge(
with_base_discussion: false,
discussion: discussion
)
)
2018-06-21 08:22:40 -04:00
end
expose :positions, if: -> (d, _) { display_merge_ref_discussions?(d) } do |discussion|
discussion.diff_note_positions.map(&:position)
end
expose :line_codes, if: -> (d, _) { display_merge_ref_discussions?(d) } do |discussion|
discussion.diff_note_positions.map(&:line_code)
end
expose :resolved?, as: :resolved
2018-06-21 08:22:40 -04:00
expose :resolved_by_push?, as: :resolved_by_push
expose :resolved_by, using: NoteUserEntity
2018-06-21 08:22:40 -04:00
expose :resolved_at
private
def current_user
request.current_user
end
def display_merge_ref_discussions?(discussion)
discussion.diff_discussion? && !discussion.legacy_diff_discussion?
end
end