Esempio n. 1
0
def proxy_comments(number):
    """XHR endpoint for GitHub issue comments.

    * GET an issue comments
    * POST a comment on an issue (only as an authorized GitHub user)
    """
    params = request.args.copy()
    path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
    if request.method == 'POST' and g.user:
        new_comment = api_request('post',
                                  path,
                                  params=params,
                                  data=get_comment_data(request.data),
                                  mime_type=JSON_MIME_HTML)
        return get_html_comments(new_comment)
    else:
        # TODO: handle the (rare) case for more than 1 page of comments
        # for now, we just get the first 100 and rely on the client to
        # fetch more
        params.update({'per_page': 100})
        comments_data = api_request('get',
                                    path,
                                    params=params,
                                    mime_type=JSON_MIME_HTML)
        comments_status = comments_data[1:2]
        if comments_status != 304:
            return get_html_comments(comments_data)
        else:
            # in the case of a 304, the browser cache will handle it.
            return '', 304, get_response_headers(comments_data, HTML_MIME)
Esempio n. 2
0
def proxy_comments(number):
    '''XHR endpoint to get issues comments from GitHub.

    Either as an authed user, or as one of our proxy bots.
    '''
    if request.method == 'POST':
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('post', path, data=get_comment_data(request.data))
    else:
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('get', path)
Esempio n. 3
0
def proxy_comments(number):
    '''XHR endpoint to get issues comments from GitHub.

    Either as an authed user, or as one of our proxy bots.
    '''
    if request.method == 'POST':
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('post', path, data=get_comment_data(request.data))
    else:
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('get', path)
Esempio n. 4
0
def proxy_comments(number):
    """XHR endpoint to get issues comments from GitHub.

    Either as an authed user, or as one of our proxy bots.
    """
    params = request.args.copy()
    if request.method == 'POST' and g.user:
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('post', path, params=params,
                           data=get_comment_data(request.data))
    else:
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('get', path, params=params)
Esempio n. 5
0
def proxy_comments(number):
    """XHR endpoint to get issues comments from GitHub.

    Either as an authed user, or as one of our proxy bots.
    """
    params = request.args.copy()
    if request.method == 'POST' and g.user:
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('post', path, params=params,
                           data=get_comment_data(request.data))
    else:
        path = 'repos/{0}/{1}/comments'.format(ISSUES_PATH, number)
        return api_request('get', path, params=params)