debian-mirror-gitlab/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

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