mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 12:35:26 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
39 lines
749 B
Ruby
39 lines
749 B
Ruby
# frozen_string_literal: true
|
|
|
|
class IncomingEmailSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
:created_at,
|
|
:from_address,
|
|
:to_addresses,
|
|
:cc_addresses,
|
|
:subject,
|
|
:error,
|
|
:post_url
|
|
|
|
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
|
|
|
def post_url
|
|
object.post.url
|
|
end
|
|
|
|
def include_post_url?
|
|
object.post.present?
|
|
end
|
|
|
|
def to_addresses
|
|
return if object.to_addresses.blank?
|
|
object.to_addresses.split(";")
|
|
end
|
|
|
|
def cc_addresses
|
|
return if object.cc_addresses.blank?
|
|
object.cc_addresses.split(";")
|
|
end
|
|
|
|
def error
|
|
@object.error.presence || I18n.t("emails.incoming.unrecognized_error")
|
|
end
|
|
|
|
end
|