Permalink
Browse files

Add a concept of an Instagram user blacklist

  • Loading branch information...
1 parent 5aa26d0 commit 0ed7d5a1133d5d8f0f8272ca9b1929a769c8a101 @mislav committed May 9, 2016
Showing with 9 additions and 0 deletions.
  1. +5 −0 app.rb
  2. +1 −0 config.yml
  3. +3 −0 models.rb
View
@@ -136,6 +136,11 @@ def record(name)
Metriks::Reporter::Logger.new(logger: Logger.new($stdout), interval: settings.metriks_interval).start
use Metriks::Middleware
end
+
+ blacklisted_ids = settings.user_blacklist.to_s.split(',').map(&:to_i)
+ if blacklisted_ids.any?
+ User.blacklist = -> (user) { blacklisted_ids.include?(user.user_id) }
+ end
end
helpers do
View
@@ -18,6 +18,7 @@ default: &defaults
user_page: <%= 60 * 60 %>
search_page: <%= 20 * 60 %>
tag_page: <%= 20 * 60 %>
+ user_blacklist: "<%= ENV['INSTAGRAM_USER_BLACKLIST'] %>"
development:
<<: *defaults
View
@@ -27,6 +27,8 @@ def initialize user
end
class << self
+ attr_accessor :blacklist
+
def lookup(id)
unless user = find_by_username_or_id(id) or id =~ /\D/
# lookup Instagram user by ID
@@ -39,6 +41,7 @@ def lookup(id)
end
end
+ user = nil if blacklist && blacklist.call(user)
user || (block_given? ? yield : nil)
end
alias [] lookup

0 comments on commit 0ed7d5a

Please sign in to comment.