Skip to content

Commit

Permalink
Merge pull request #162 from comorebi-notes/develop
Browse files Browse the repository at this point in the history
荒らし対策
  • Loading branch information
comorebi-notes authored May 13, 2023
2 parents dbb4a6b + c5a68f1 commit a8c9a23
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/score.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Score < ApplicationRecord

validates :title, presence: true, length: { maximum: 40 }
validates :content, presence: true, length: { maximum: 1024 }
validates :bpm, numericality: { greater_than: 0 }
validate :anti_attack

before_create do
self.token = SecureRandom.urlsafe_base64(8)
Expand All @@ -55,4 +57,13 @@ def owner?(id)
def browsable?(id)
published? || owner?(id)
end

private def anti_attack
# 以下の荒らし投稿を取り急ぎ防ぐ
# 皆様への大切なお知らせ\n大変申し訳ございませんが、rechord.ccは下記のリンクに移動することとなりました。
# 今後ともrechord.ccをよろしくお願いします。
# 移動先URL: https://www.nekozouneko.net/
# - by るんく
errors.add(:content, :taken) if content.include?('大切なお知らせ') || content.include?('nekozouneko')
end
end

0 comments on commit a8c9a23

Please sign in to comment.