2018-09-07 21:19:20 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
|
|
|
class ActivitySerializer < ActiveModel::Serializer
|
2019-04-08 21:07:45 +08:00
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
include ApplicationHelper
|
|
|
|
include GlobalActivitiesHelper
|
|
|
|
|
|
|
|
def self.serializer_for(model, options)
|
|
|
|
return TaskSerializer if model.class == MyModule
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2018-09-07 21:19:20 +08:00
|
|
|
type :activities
|
2018-10-07 17:49:11 +08:00
|
|
|
attributes :id, :type_of, :message
|
|
|
|
belongs_to :project, serializer: ProjectSerializer
|
2019-04-08 21:07:45 +08:00
|
|
|
belongs_to :subject, polymorphic: true
|
|
|
|
belongs_to :owner, key: :user, serializer: UserSerializer
|
|
|
|
|
|
|
|
def message
|
|
|
|
if object.old_activity?
|
|
|
|
object.message
|
|
|
|
else
|
2021-02-25 18:58:15 +08:00
|
|
|
generate_activity_content(object, no_links: true)
|
2019-04-08 21:07:45 +08:00
|
|
|
end
|
|
|
|
end
|
2018-09-07 21:19:20 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|