How to use the publish.SendHandler function in publish

To help you get started, we’ve selected a few publish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snarfed / bridgy / tests / test_publish.py View on Github external
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))
github snarfed / bridgy / publish.py View on Github external
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
github snarfed / bridgy / publish.py View on Github external
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):
github snarfed / bridgy / publish.py View on Github external
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)
github snarfed / bridgy / publish.py View on Github external
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):
github snarfed / bridgy / publish.py View on Github external
# 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()
github snarfed / bridgy / publish.py View on Github external
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)
github snarfed / bridgy / publish.py View on Github external
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.
github snarfed / bridgy / publish.py View on Github external
# 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()
github snarfed / bridgy / publish.py View on Github external
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