reality/depressionbot — pull request #370 by zuzak (2013-04-17 15:05:57+00:00)
Title: Redditgur

Adds a "This image has been featured on Reddit!" message to imgur's random image function, if appropriate.

It doesn't appear very often: I can't tell if I've made a bug, or whether imgur really doesn't have many reddit submissions (as most images have 0 views, perhaps this is more likely).

Originally, this feature was able to pull subreddit information etcetera. However, due to my unoptimised code (I think), this took ten to twelve seconds to load each query, which is somewhat unacceptable when users flash through images once every two seconds. As such, this code instead checks for a fail response (``"{}"``), and assumes that it's a success -- error codes won't fire the callback, so hopefully this is an okay response until someone actually okay at coding swoops in, adds two lines of code, and swoops out again.

Check the code carefully before pulling this request; I made a reddit api call public to make this, so it's possibly got some security balls-up.