summaryrefslogtreecommitdiff
path: root/app/models/snippet.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-02-01 18:15:59 +0000
committerSean McGivern <sean@gitlab.com>2017-02-02 10:23:51 +0000
commitc63194ce6f952173649d7de4038aa96348e90565 (patch)
treea9622e1e5ffc86bf35fc9556152cc03cf2841ef5 /app/models/snippet.rb
parentf799585c41d801bc657f992adf3d4b201af927d2 (diff)
downloadgitlab-ce-c63194ce6f952173649d7de4038aa96348e90565.tar.gz
Check public snippets for spam
Apply the same spam checks to public snippets (either personal snippets that are public, or public snippets on public projects) as to issues on public projects.
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 960f1521be9..2665a7249a3 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -7,6 +7,7 @@ class Snippet < ActiveRecord::Base
include Sortable
include Awardable
include Mentionable
+ include Spammable
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :content
@@ -46,6 +47,9 @@ class Snippet < ActiveRecord::Base
participant :author
participant :notes_with_associations
+ attr_spammable :title, spam_title: true
+ attr_spammable :content, spam_description: true
+
def self.reference_prefix
'$'
end
@@ -127,6 +131,14 @@ class Snippet < ActiveRecord::Base
notes.includes(:author)
end
+ def check_for_spam?
+ public?
+ end
+
+ def spammable_entity_type
+ 'snippet'
+ end
+
class << self
# Searches for snippets with a matching title or file name.
#