2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-11-10 10:09:14 -05:00
|
|
|
class DiscussionEntity < BaseDiscussionEntity
|
2018-04-03 12:03:00 -04:00
|
|
|
expose :notes do |discussion, opts|
|
2021-03-26 11:09:18 -04:00
|
|
|
request.note_entity.represent(
|
|
|
|
discussion.notes,
|
|
|
|
opts.merge(
|
|
|
|
with_base_discussion: false,
|
|
|
|
discussion: discussion
|
|
|
|
)
|
|
|
|
)
|
2018-06-21 08:22:40 -04:00
|
|
|
end
|
|
|
|
|
2020-04-15 14:09:36 -04:00
|
|
|
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
|
|
|
|
|
2018-02-27 19:10:43 -05:00
|
|
|
expose :resolved?, as: :resolved
|
2018-06-21 08:22:40 -04:00
|
|
|
expose :resolved_by_push?, as: :resolved_by_push
|
2018-10-01 09:53:08 -04:00
|
|
|
expose :resolved_by, using: NoteUserEntity
|
2018-06-21 08:22:40 -04:00
|
|
|
expose :resolved_at
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def current_user
|
|
|
|
request.current_user
|
|
|
|
end
|
2020-04-15 14:09:36 -04:00
|
|
|
|
|
|
|
def display_merge_ref_discussions?(discussion)
|
2020-10-12 11:08:32 -04:00
|
|
|
discussion.diff_discussion? && !discussion.legacy_diff_discussion?
|
2020-04-15 14:09:36 -04:00
|
|
|
end
|
2017-06-09 17:24:54 -04:00
|
|
|
end
|