2017-06-09 17:24:54 -04:00
|
|
|
class NoteEntity < API::Entities::Note
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :type
|
|
|
|
|
2017-08-17 13:27:11 -04:00
|
|
|
expose :author, using: NoteUserEntity
|
2017-06-09 17:24:54 -04:00
|
|
|
|
|
|
|
unexpose :note, as: :body
|
|
|
|
expose :note
|
|
|
|
|
|
|
|
expose :redacted_note_html, as: :note_html
|
|
|
|
|
2017-08-30 04:43:10 -04:00
|
|
|
expose :last_edited_at, if: -> (note, _) { note.edited? }
|
|
|
|
expose :last_edited_by, using: NoteUserEntity, if: -> (note, _) { note.edited? }
|
2017-06-09 17:24:54 -04:00
|
|
|
|
2017-06-26 20:39:40 -04:00
|
|
|
expose :current_user do
|
|
|
|
expose :can_edit do |note|
|
2018-04-02 13:05:47 -04:00
|
|
|
Ability.allowed?(request.current_user, :admin_note, note)
|
2017-06-26 20:39:40 -04:00
|
|
|
end
|
2018-04-06 14:19:37 -04:00
|
|
|
|
|
|
|
expose :can_award_emoji do |note|
|
|
|
|
Ability.allowed?(request.current_user, :award_emoji, note)
|
|
|
|
end
|
2017-06-09 17:24:54 -04:00
|
|
|
end
|
|
|
|
|
2018-02-27 19:10:43 -05:00
|
|
|
expose :resolved?, as: :resolved
|
|
|
|
expose :resolvable?, as: :resolvable
|
|
|
|
expose :resolved_by, using: NoteUserEntity
|
|
|
|
|
2017-06-09 17:24:54 -04:00
|
|
|
expose :system_note_icon_name, if: -> (note, _) { note.system? } do |note|
|
|
|
|
SystemNoteHelper.system_note_icon_name(note)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :discussion_id do |note|
|
|
|
|
note.discussion_id(request.noteable)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :emoji_awardable?, as: :emoji_awardable
|
|
|
|
expose :award_emoji, if: -> (note, _) { note.emoji_awardable? }, using: AwardEmojiEntity
|
|
|
|
|
|
|
|
expose :report_abuse_path do |note|
|
|
|
|
new_abuse_report_path(user_id: note.author.id, ref_url: Gitlab::UrlBuilder.build(note))
|
|
|
|
end
|
|
|
|
|
2017-08-17 09:00:10 -04:00
|
|
|
expose :attachment, using: NoteAttachmentEntity, if: -> (note, _) { note.attachment? }
|
2017-06-09 17:24:54 -04:00
|
|
|
end
|