mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 21:45:25 +08:00
Followup bd3906ce64
Converts the new endpoints made in the original PR into
service classes, using AI to drive implementation based
on the service authoring skill:
* CustomEmoji::Export
* CustomEmoji::PreviewImport
* CustomEmoji::ConfirmImport
In addition, some supporting action, lib, and serializer
classes have been added. This fixed a couple of
bugs as well:
* Import names now go through `Emoji.sanitize_emoji_name` like
single-emoji create
* No-group imports no longer persist a literal "default" string
* Two 500s (suspicious zip entries, malformed CSV) became proper 422s
* Duplicate CSV names are flagged at preview instead of exploding the
confirm transaction
*` Emoji.clear_cache `moved outside the transaction
37 lines
684 B
Ruby
Vendored
37 lines
684 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class CustomEmoji::ImportRowSerializer < ApplicationSerializer
|
|
attributes :index,
|
|
:name,
|
|
:group,
|
|
:filename,
|
|
:category,
|
|
:errors,
|
|
:incoming_url,
|
|
:existing_url,
|
|
:existing_group
|
|
|
|
def group
|
|
object.display_group
|
|
end
|
|
|
|
def existing_group
|
|
object.display_existing_group
|
|
end
|
|
|
|
def include_errors?
|
|
object.invalid?
|
|
end
|
|
|
|
def include_incoming_url?
|
|
object.incoming_url.present?
|
|
end
|
|
|
|
def include_existing_url?
|
|
object.conflict? && object.existing_url.present?
|
|
end
|
|
|
|
def include_existing_group?
|
|
object.conflict?
|
|
end
|
|
end
|