Class: QueuedPostSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/queued_post_serializer.rb

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Constructor Details

#initialize(object, options = {}) ⇒ QueuedPostSerializer

Returns a new instance of QueuedPostSerializer.



21
22
23
24
# File 'app/serializers/queued_post_serializer.rb', line 21

def initialize(object, options = {})
  Discourse.deprecate("QueuedPostSerializer is deprecated.", drop_from: "3.3.0")
  super
end

Instance Method Details

#approved_by_idObject



38
39
40
# File 'app/serializers/queued_post_serializer.rb', line 38

def approved_by_id
  post_history.approved.last&.created_by_id
end

#can_delete_userObject



54
55
56
# File 'app/serializers/queued_post_serializer.rb', line 54

def can_delete_user
  true
end

#include_can_delete_user?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'app/serializers/queued_post_serializer.rb', line 58

def include_can_delete_user?
  created_by && created_by.trust_level == TrustLevel[0]
end

#post_optionsObject



50
51
52
# File 'app/serializers/queued_post_serializer.rb', line 50

def post_options
  object.payload.except("raw")
end

#queueObject



26
27
28
# File 'app/serializers/queued_post_serializer.rb', line 26

def queue
  "default"
end

#rawObject



46
47
48
# File 'app/serializers/queued_post_serializer.rb', line 46

def raw
  object.payload["raw"]
end

#rejected_by_idObject



42
43
44
# File 'app/serializers/queued_post_serializer.rb', line 42

def rejected_by_id
  post_history.rejected.last&.created_by_id
end

#stateObject



34
35
36
# File 'app/serializers/queued_post_serializer.rb', line 34

def state
  object.status + 1
end

#user_idObject



30
31
32
# File 'app/serializers/queued_post_serializer.rb', line 30

def user_id
  object.created_by_id
end