2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-01-19 07:57:55 +08:00
|
|
|
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
|
|
|
|
|
2017-08-05 02:04:26 +08:00
|
|
|
def error
|
|
|
|
@object.error.presence || I18n.t("emails.incoming.unrecognized_error")
|
|
|
|
end
|
2016-01-19 07:57:55 +08:00
|
|
|
end
|