def remove_needs_reply_comment(repo_username, repo_id, number, issue_comments=None, needs_reply_content_id=cvar['NEEDS_REPLY_CONTENT_ID'], is_debug=cvar['DEBUG']): try: if issue_comments is None: issue_comments = github_api.fetch_issue_comments(repo_username, repo_id, number) if not issue_comments or not isinstance(issue_comments, list): return 'invalid comments' for issue_comment in issue_comments: body = issue_comment.get('body') comment_id = issue_comment.get('id') if body and needs_reply_content_id in body and comment_id: if not is_debug: github_api.delete_issue_comment(repo_username, repo_id, comment_id, number=number) return 'removed auto comment' return 'no comment to remove' except Exception as ex: return 'remove_needs_reply_comment: %s' % ex
def remove_flag_when_closed(repo_username, repo_id, issue, issue_comments=None, needs_resubmit_content_id=cvar['NEEDS_RESUBMIT_CONTENT_ID'], is_debug=cvar['DEBUG']): if not issue: return False number = issue.get('number') if not number: return False if has_content_from_custom_submit_form(issue): return False comment = get_needs_resubmit_comment(repo_username, repo_id, issue, issue_comments=issue_comments, needs_resubmit_content_id=needs_resubmit_content_id) if comment is None: return False comment_id = comment.get('id') if comment_id is None: return False if not is_debug: github_api.delete_issue_comment(repo_username, repo_id, comment_id, number=number) return True