Skip to content

Commit 1c276cc

Browse files
committed
when flagged, mark as spam
1 parent a0f7e46 commit 1c276cc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/controllers/application_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ def is_admin?
202202
signed_in? && current_user.role == 'admin'
203203
end
204204

205+
def is_moderator?
206+
signed_in? && current_user.role.in?(%w(admin moderator))
207+
end
208+
205209
def iphone_user_agent?
206210
request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile\/.+Safari)/]
207211
end

app/controllers/protips_controller.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,12 @@ def report_inappropriate
241241
end
242242
end
243243
244-
def flag
245-
times_to_flag = is_admin? ? Protip::MIN_FLAG_THRESHOLD : 1
244+
def flag
245+
times_to_flag = is_moderator? ? Protip::MIN_FLAG_THRESHOLD : 1
246246
times_to_flag.times do
247247
@protip.flag
248248
end
249+
@protip.mark_as_spam
249250
respond_to do |format|
250251
if @protip.save
251252
format.json { head :ok }
@@ -256,7 +257,7 @@ def flag
256257
end
257258
258259
def unflag
259-
times_to_flag = is_admin? ? Protip::MIN_FLAG_THRESHOLD : 1
260+
times_to_flag = is_moderator? ? Protip::MIN_FLAG_THRESHOLD : 1
260261
times_to_flag.times do
261262
@protip.unflag
262263
end

0 commit comments

Comments
 (0)