def __init__(self, *args, **kwargs): super(BugReportController, self).__init__(*args, **kwargs) self.redis_issue_handler = RedisIssueHandler(self.user_manager.redis, self.user_manager.cork, self.get_email_view()) # if GitHub settings provided, use the GitHub Issue Importer gh_auth = os.environ.get('GH_ISSUE_AUTH') gh_repo = os.environ.get('GH_ISSUE_REPO') if gh_auth and gh_repo: owner, repo = gh_repo.split('/') username, token_or_pass = gh_auth.split(':') self.issue_handler = GitHubIssueImporter(username, token_or_pass, owner, repo) else: self.issue_handler = self.redis_issue_handler
class BugReportController(BaseController): def __init__(self, *args, **kwargs): super(BugReportController, self).__init__(*args, **kwargs) self.redis_issue_handler = RedisIssueHandler(self.user_manager.redis, self.user_manager.cork, self.get_email_view()) # if GitHub settings provided, use the GitHub Issue Importer gh_auth = os.environ.get('GH_ISSUE_AUTH') gh_repo = os.environ.get('GH_ISSUE_REPO') if gh_auth and gh_repo: owner, repo = gh_repo.split('/') username, token_or_pass = gh_auth.split(':') self.issue_handler = GitHubIssueImporter(username, token_or_pass, owner, repo) else: self.issue_handler = self.redis_issue_handler def init_routes(self): wr_api_spec.set_curr_tag('Bug Reporting') @self.app.post('/api/v1/report/dnlr') def report_issues(): useragent = request.headers.get('User-Agent') data = request.json or {} self.do_report(data, useragent) return {} @self.app.post('/api/v1/report/ui') def report_issues(): useragent = request.headers.get('User-Agent') data = request.json or {} data['state'] = 'ui-report' self.do_report(data, useragent) return {} wr_api_spec.set_curr_tag(None) def do_report(self, params, ua=''): report = {} for key in params: report[key] = params.get(key) now = str(datetime.utcnow()) user = self.access.session_user report['user'] = user.name report['time'] = now report['ua'] = ua report['user_email'] = self.user_manager.get_user_email(user.name) if not report.get('email'): report['email'] = report['user_email'] res = self.issue_handler.add_bug_report(report) # fallback on redis handler if GH handler failed if not res and self.issue_handler != self.redis_issue_handler: self.redis_issue_handler.add_bug_report(report) def get_email_view(self): @self.jinja2_view('email_error.html') def error_email(params): ua = UserAgent(params.get('ua')) if ua.browser: browser = '{0} {1} {2} {3}' lang = ua.language or '' browser = browser.format(ua.platform, ua.browser, ua.version, lang) params['browser'] = browser else: params['browser'] = ua.string params['time'] = params['time'][:19] return params return error_email
class BugReportController(BaseController): def __init__(self, app, jinja_env, manager, config): super(BugReportController, self).__init__(app, jinja_env, manager, config) self.redis_issue_handler = RedisIssueHandler(manager.redis, manager.cork, self.get_email_view()) # if GitHub settings provided, use the GitHub Issue Importer gh_auth = os.environ.get('GH_ISSUE_AUTH') gh_repo = os.environ.get('GH_ISSUE_REPO') if gh_auth and gh_repo: owner, repo = gh_repo.split('/') username, token_or_pass = gh_auth.split(':') self.issue_handler = GitHubIssueImporter(username, token_or_pass, owner, repo) else: self.issue_handler = self.redis_issue_handler def init_routes(self): @self.app.post('/_reportissues') def report_issues(): useragent = request.headers.get('User-Agent') self.do_report(request.POST, useragent) return {} def do_report(self, params, ua=''): report = {} for key in params.iterkeys(): report[key] = params.getunicode(key) now = str(datetime.utcnow()) user = self.manager.get_curr_user() report['user'] = user report['time'] = now report['ua'] = ua report['user_email'] = self.manager.get_user_email(user) if not report.get('email'): report['email'] = report['user_email'] res = self.issue_handler.add_bug_report(report) # fallback on redis handler if GH handler failed if not res and self.issue_handler != self.redis_issue_handler: self.redis_issue_handler.add_bug_report(report) def get_email_view(self): @self.jinja2_view('email_error.html') def error_email(params): ua = UserAgent(params.get('ua')) if ua.browser: browser = '{0} {1} {2} {3}' lang = ua.language or '' browser = browser.format(ua.platform, ua.browser, ua.version, lang) params['browser'] = browser else: params['browser'] = ua.string params['time'] = params['time'][:19] return params return error_email
class BugReportController(BaseController): def __init__(self, *args, **kwargs): super(BugReportController, self).__init__(*args, **kwargs) self.redis_issue_handler = RedisIssueHandler(self.user_manager.redis, self.user_manager.cork, self.get_email_view()) # if GitHub settings provided, use the GitHub Issue Importer gh_auth = os.environ.get('GH_ISSUE_AUTH') gh_repo = os.environ.get('GH_ISSUE_REPO') if gh_auth and gh_repo: owner, repo = gh_repo.split('/') username, token_or_pass = gh_auth.split(':') self.issue_handler = GitHubIssueImporter(username, token_or_pass, owner, repo) else: self.issue_handler = self.redis_issue_handler def init_routes(self): wr_api_spec.set_curr_tag('Bug Reporting') # LOGIN @self.app.post('/api/v1/contact/support') def sendContact(): """Send Contact form to admin""" result = request.json or {} mail = MIMEMultipart() Body = {"name": "", "subject": "", "msg": ""} if result.get('email'): mail['FROM'] = result['email'] else: self._raise_error(401, 'Email sender unspecified') if result.get('msg'): Body['msg'] = result['msg'] else: self._raise_error(401, 'emty message not allowed') if result.get('name'): Body['name'] = result['name'] if result.get('subject'): Body['subject'] = result['subject'] reviewerMailText = template( 'webrecorder/templates/email_contact.html', sender_name=Body['name'], subject=Body['subject'], msg=Body['msg']) mail['TO'] = '*****@*****.**' mail['subject'] = Body['subject'] host = "relays.uni-heidelberg.de" mailServer = smtplib.SMTP(host) mail.attach(MIMEText(reviewerMailText, "html")) msgBody = mail.as_string() mailServer.sendmail(result['email'], '*****@*****.**', msgBody) mailServer.quit() #self._raise_error(401, result.get('error', '')) response.status = 200 return {} @self.app.post('/api/v1/report/dnlr') def report_issues(): useragent = request.headers.get('User-Agent') data = request.json or {} self.do_report(data, useragent) return {} @self.app.post('/api/v1/report/ui') def report_issues(): useragent = request.headers.get('User-Agent') data = request.json or {} data['state'] = 'ui-report' self.do_report(data, useragent) return {} wr_api_spec.set_curr_tag(None) def do_report(self, params, ua=''): report = {} for key in params: report[key] = params.get(key) now = str(datetime.utcnow()) user = self.access.session_user report['user'] = user.name report['time'] = now report['ua'] = ua report['user_email'] = self.user_manager.get_user_email(user.name) if not report.get('email'): report['email'] = report['user_email'] res = self.issue_handler.add_bug_report(report) # fallback on redis handler if GH handler failed if not res and self.issue_handler != self.redis_issue_handler: self.redis_issue_handler.add_bug_report(report) def get_email_view(self): @self.jinja2_view('email_error.html') def error_email(params): ua = UserAgent(params.get('ua')) if ua.browser: browser = '{0} {1} {2} {3}' lang = ua.language or '' browser = browser.format(ua.platform, ua.browser, ua.version, lang) params['browser'] = browser else: params['browser'] = ua.string params['time'] = params['time'][:19] return params return error_email
class BugReportController(BaseController): def __init__(self, *args, **kwargs): super(BugReportController, self).__init__(*args, **kwargs) self.redis_issue_handler = RedisIssueHandler(self.user_manager.redis, self.user_manager.cork, self.get_email_view()) # if GitHub settings provided, use the GitHub Issue Importer gh_auth = os.environ.get('GH_ISSUE_AUTH') gh_repo = os.environ.get('GH_ISSUE_REPO') if gh_auth and gh_repo: owner, repo = gh_repo.split('/') username, token_or_pass = gh_auth.split(':') self.issue_handler = GitHubIssueImporter(username, token_or_pass, owner, repo) else: self.issue_handler = self.redis_issue_handler def init_routes(self): wr_api_spec.set_curr_tag('Bug Reporting') @self.app.post('/api/v1/report/dnlr') def report_issues(): useragent = request.headers.get('User-Agent') data = request.json or {} self.do_report(data, useragent) return {} @self.app.post('/api/v1/report/ui') def report_issues(): useragent = request.headers.get('User-Agent') data = request.json or {} data['state'] = 'ui-report' self.do_report(data, useragent) return {} def do_report(self, params, ua=''): report = {} for key in params: report[key] = params.get(key) now = str(datetime.utcnow()) user = self.access.session_user report['user'] = user.name report['time'] = now report['ua'] = ua report['user_email'] = self.user_manager.get_user_email(user.name) if not report.get('email'): report['email'] = report['user_email'] res = self.issue_handler.add_bug_report(report) # fallback on redis handler if GH handler failed if not res and self.issue_handler != self.redis_issue_handler: self.redis_issue_handler.add_bug_report(report) def get_email_view(self): @self.jinja2_view('email_error.html') def error_email(params): ua = UserAgent(params.get('ua')) if ua.browser: browser = '{0} {1} {2} {3}' lang = ua.language or '' browser = browser.format(ua.platform, ua.browser, ua.version, lang) params['browser'] = browser else: params['browser'] = ua.string params['time'] = params['time'][:19] return params return error_email