From aa8cc3fc4b695caf87aa8b8e2f4a5224e5973575 Mon Sep 17 00:00:00 2001 From: Jakub Date: Wed, 16 Feb 2022 11:38:06 +0100 Subject: [PATCH] GODT-1503 GODT-1492: Improve email validation and username in bug report. --- internal/bridge/bug_report.go | 6 ++++++ internal/frontend/qml/BugReportView.qml | 2 +- internal/frontend/qt/frontend_help.go | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/bridge/bug_report.go b/internal/bridge/bug_report.go index 389145f6..2a41c08d 100644 --- a/internal/bridge/bug_report.go +++ b/internal/bridge/bug_report.go @@ -39,6 +39,12 @@ var ErrSizeTooLarge = errors.New("file is too big") // ReportBug reports a new bug from the user. func (b *Bridge) ReportBug(osType, osVersion, description, accountName, address, emailClient string, attachLogs bool) error { + if user, err := b.GetUser(address); err == nil { + accountName = user.Username() + } else if users := b.GetUsers(); len(users) > 0 { + accountName = users[0].Username() + } + report := pmapi.ReportBugReq{ OS: osType, OSVersion: osVersion, diff --git a/internal/frontend/qml/BugReportView.qml b/internal/frontend/qml/BugReportView.qml index 6b16dbc0..a29c9d14 100644 --- a/internal/frontend/qml/BugReportView.qml +++ b/internal/frontend/qml/BugReportView.qml @@ -181,7 +181,7 @@ SettingsView { } function isValidEmail(text){ - var reEmail = /\w+@\w+\.\w+/ + var reEmail = /^[^@]+@[^@]+\.[A-Za-z]+\s*$/ return reEmail.test(text) } diff --git a/internal/frontend/qt/frontend_help.go b/internal/frontend/qt/frontend_help.go index 34313204..547e577c 100644 --- a/internal/frontend/qt/frontend_help.go +++ b/internal/frontend/qt/frontend_help.go @@ -53,7 +53,7 @@ func (f *FrontendQt) reportBug(description, address, emailClient string, include core.QSysInfo_ProductType(), core.QSysInfo_PrettyProductName(), description, - "Unknown account", + address, address, emailClient, includeLogs,