Created
May 7, 2016 21:10
-
-
Save iduuck/48887a69e31fa41d58ffcfc9be1a2f47 to your computer and use it in GitHub Desktop.
How to reject a post based on some attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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