Class: BeetleReporter::Report

Inherits:
ApplicationRecord show all
Includes:
AASM, Discard::Model
Defined in:
app/models/beetle_reporter/report.rb

Constant Summary collapse

REASON_TYPES =
%w(垃圾广告营销 侮辱谩骂内容 淫秽色情内容 涉政敏感信息 违法有害信息 内容令人不适 内容存在错误)
PROCESS_REASON_LIST =
%w(
  发布垃圾、无意义内容
  发布恐吓行为/骚扰内容
  发布营销广告内容
  发布谩骂、酸讽、引战内容
  发布令人不适内容
  发布淫秽色情内容
  发布涉政敏感违法有害信息
)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.record_type_optionsObject



119
120
121
# File 'app/models/beetle_reporter/report.rb', line 119

def self.record_type_options
  select(:record_type).where.not(record_type: nil).distinct.map{|t| [t.record_type, t.record_type.downcase]}
end

Instance Method Details

#beetle_forbid(reason) ⇒ Object

Raises:

  • (NoMethodError)


78
79
80
81
82
83
84
85
# File 'app/models/beetle_reporter/report.rb', line 78

def beetle_forbid(reason)
  return if record.blank?
  return if record&.user.blank?
  raise NoMethodError unless record.respond_to?(:beetle_forbid)

  ret = record.beetle_forbid(reason)
  forbid!(reason) if ret
end

#beetle_hide(reason) ⇒ Object

Raises:

  • (NoMethodError)


53
54
55
56
57
58
59
# File 'app/models/beetle_reporter/report.rb', line 53

def beetle_hide(reason)
  return if record.blank?
  raise NoMethodError unless record.respond_to?(:beetle_hide)

  ret = record.beetle_hide
  hide!(reason) if ret
end

#beetle_mute(reason) ⇒ Object

Raises:

  • (NoMethodError)


69
70
71
72
73
74
75
76
# File 'app/models/beetle_reporter/report.rb', line 69

def beetle_mute(reason)
  return if record.blank?
  return if record&.user.blank?
  raise NoMethodError unless record.respond_to?(:beetle_mute)

  ret = record.beetle_mute(reason)
  mute!(reason) if ret
end

#beetle_remove(reason) ⇒ Object

Raises:

  • (NoMethodError)


61
62
63
64
65
66
67
# File 'app/models/beetle_reporter/report.rb', line 61

def beetle_remove(reason)
  return if record.blank?
  raise NoMethodError unless record.respond_to?(:beetle_remove)

  ret = record.beetle_remove
  remove!(reason) if ret
end

#record_partial_pathObject



93
94
95
# File 'app/models/beetle_reporter/report.rb', line 93

def record_partial_path
  record.beetle_record_partial_path
end

#record_pathObject



87
88
89
90
91
# File 'app/models/beetle_reporter/report.rb', line 87

def record_path
  return '#' if record.blank?

  record.beetle_record_path
end

#set_reason(reason) ⇒ Object



115
116
117
# File 'app/models/beetle_reporter/report.rb', line 115

def set_reason(reason)
  update_columns(reason: reason)
end

#undo_callbackObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'app/models/beetle_reporter/report.rb', line 97

def undo_callback
  if hidden?
    ret = record.beetle_undo_hide
    update_columns(reason: nil) if ret
  elsif removed?
    ret = record.beetle_undo_remove
    update_columns(reason: nil) if ret
  elsif muted?
    ret = record.beetle_undo_mute
    update_columns(reason: nil) if ret
  elsif forbiden?
    ret = record.beetle_undo_forbid
    update_columns(reason: nil) if ret
  else
    update_columns(reason: nil)
  end
end