Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_response(self, source=None, target=None, preview=False,
interactive=False, params=None):
if params is None:
params = {}
params.update({
'source': source or 'http://foo.com/bar',
'target': target or 'https://brid.gy/publish/fake',
'source_key': self.source.key.urlsafe().decode(),
})
appl = app.application
assert not (preview and interactive)
if interactive:
class FakeSendHandler(publish.SendHandler):
def post(fsh_self):
state = (util.encode_oauth_state(self.oauth_state)
if self.oauth_state else None)
fsh_self.finish(self.auth_entity, state)
appl = webapp2.WSGIApplication([('.*', FakeSendHandler)])
return appl.get_response(
'/publish/preview' if preview else '/publish/webmention',
method='POST', text=urllib.parse.urlencode(params))
def error(self, error, html=None, status=400, data=None, report=False, **kwargs):
logging.info(error, stack_info=True)
error = html if html else util.linkify(error)
self.messages.add('%s' % error)
if report:
self.report_error(error)
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class MastodonSendHandler(oauth_mastodon.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
"""
PREVIEW = False
return self.state['target_url']
def include_link(self, item):
return self.state['include_link']
def error(self, error, html=None, status=400, data=None, report=False, **kwargs):
logging.info(error, stack_info=True)
error = html if html else util.linkify(error)
self.messages.add('%s' % error)
if report:
self.report_error(error)
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class MastodonSendHandler(oauth_mastodon.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
self.messages.add('%s' % error)
if report:
self.report_error(error)
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class MastodonSendHandler(oauth_mastodon.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
"""
PREVIEW = False
def post(self):
result = self._run()
if result:
self.response.write(result.content)
def error(self, error, html=None, status=400, data=None, mail=False):
logging.info(error, exc_info=True)
error = html if html else util.linkify(error)
self.messages.add('%s' % error)
if mail or isinstance(self.source, GitHub): # temporary!
self.mail_me(error)
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FacebookSendHandler(oauth_facebook.CallbackHandler, SendHandler):
finish = SendHandler.finish
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
"""
PREVIEW = False
def post(self):
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class MastodonSendHandler(oauth_mastodon.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
"""
PREVIEW = False
def post(self):
result = self._run()
if result:
self.response.write(result.content)
def authorize(self):
"""Check for a backlink to brid.gy/publish/SILO."""
bases = set()
self.messages.add('%s' % error)
if mail or isinstance(self.source, GitHub): # temporary!
self.mail_me(error)
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FacebookSendHandler(oauth_facebook.CallbackHandler, SendHandler):
finish = SendHandler.finish
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
"""
PREVIEW = False
def post(self):
result = self._run()
if result:
self.response.write(result.content)
def include_link(self, item):
return self.state['include_link']
def error(self, error, html=None, status=400, data=None, report=False, **kwargs):
logging.info(error, stack_info=True)
error = html if html else util.linkify(error)
self.messages.add('%s' % error)
if report:
self.report_error(error)
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class MastodonSendHandler(oauth_mastodon.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FacebookSendHandler(oauth_facebook.CallbackHandler, SendHandler):
finish = SendHandler.finish
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
"""
PREVIEW = False
def post(self):
result = self._run()
if result:
self.response.write(result.content)
def authorize(self):
"""Check for a backlink to brid.gy/publish/SILO."""
bases = set()
def error(self, error, html=None, status=400, data=None, mail=False):
logging.info(error, exc_info=True)
error = html if html else util.linkify(error)
self.messages.add('%s' % error)
if mail or isinstance(self.source, GitHub): # temporary!
self.mail_me(error)
# We want CallbackHandler.get() and SendHandler.finish(), so put
# CallbackHandler first and override finish.
class FacebookSendHandler(oauth_facebook.CallbackHandler, SendHandler):
finish = SendHandler.finish
class FlickrSendHandler(oauth_flickr.CallbackHandler, SendHandler):
finish = SendHandler.finish
class GitHubSendHandler(oauth_github.CallbackHandler, SendHandler):
finish = SendHandler.finish
class TwitterSendHandler(oauth_twitter.CallbackHandler, SendHandler):
finish = SendHandler.finish
class WebmentionHandler(Handler):
"""Accepts webmentions and translates them to publish requests.
"""
PREVIEW = False