Example #1
0
    def comment_to_object(self, comment):
        """Converts a GitHub comment to ActivityStreams.

    Handles both v4 GraphQL and v3 REST API issue objects.

    https://developer.github.com/v4/object/issue/
    https://developer.github.com/v3/issues/

    Args:
      comment: dict, decoded JSON GitHub issue

    Returns:
      an ActivityStreams comment dict, ready to be JSON-encoded
    """
        obj = self._to_object(comment, repo_id=True)
        if not obj:
            return obj

        obj.update({
            'objectType': 'comment',
            # url is e.g. https://github.com/foo/bar/pull/123#issuecomment-456
            'inReplyTo': [{
                'url': util.fragmentless(obj['url'])
            }],
        })
        return self.postprocess_object(obj)
Example #2
0
  def comment_to_object(cls, comment):
    """Converts a GitHub comment to ActivityStreams.

    Handles both v4 GraphQL and v3 REST API issue objects.

    https://developer.github.com/v4/object/issue/
    https://developer.github.com/v3/issues/

    Args:
      comment: dict, decoded JSON GitHub issue

    Returns:
      an ActivityStreams comment dict, ready to be JSON-encoded
    """
    obj = cls._to_object(comment, repo_id=True)
    if not obj:
      return obj

    obj.update({
      'objectType': 'comment',
      # url is e.g. https://github.com/foo/bar/pull/123#issuecomment-456
      'inReplyTo': [{'url': util.fragmentless(obj['url'])}],
    })
    return cls.postprocess_object(obj)