How to reject a post based on some attributes
# We are using the default ruby http client for the request to the | |
# shortened url, because otherwise a Gemfile or something different | |
# would be necessary | |
require 'net/http' | |
# I am using an example url from webdesignshare.com (with url shortener) | |
uri = URI('http://url.tusiad.org/make-people-stay-website') | |
res = Net::HTTP.get_response(uri) | |
# Here you could also countercheck a blacklist array or something | |
# Just check for the domain name, because otherwise wds will change to https | |
if res.code === '301' && res.read_header['Location'].include?('webdesignshare.com') { | |
# Reject or do something different | |
@post.reject! | |
} else { | |
# Accept the posting here posting | |
@post.accept! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment