mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 12:46:46 +00:00
GODT-1175: report bug
This commit is contained in:
@ -27,17 +27,23 @@ func (m *manager) ReportBug(ctx context.Context, rep ReportBugReq) error {
|
|||||||
rep.ClientType = EmailClientType
|
rep.ClientType = EmailClientType
|
||||||
}
|
}
|
||||||
|
|
||||||
r := m.r(ctx)
|
if rep.Client == "" {
|
||||||
if len(rep.Attachments) == 0 {
|
rep.Client = m.cfg.GetUserAgent()
|
||||||
r = r.SetBody(rep)
|
}
|
||||||
} else {
|
|
||||||
r = r.SetMultipartFormData(rep.GetMultipartFormData())
|
if rep.ClientVersion == "" {
|
||||||
|
rep.ClientVersion = m.cfg.AppVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
r := m.r(ctx).SetMultipartFormData(rep.GetMultipartFormData())
|
||||||
|
|
||||||
for _, att := range rep.Attachments {
|
for _, att := range rep.Attachments {
|
||||||
r = r.SetMultipartField(att.name, att.filename, "application/octet-stream", att.body)
|
r = r.SetMultipartField(att.name, att.filename, "application/octet-stream", att.body)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if _, err := wrapNoConnection(r.Post("/reports/bug")); err != nil {
|
if _, err := wrapNoConnection(r.Post("/reports/bug")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,6 @@ package pmapi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -85,22 +84,3 @@ func TestClient_BugReportWithAttachment(t *testing.T) {
|
|||||||
err := cm.ReportBug(context.Background(), rep)
|
err := cm.ReportBug(context.Background(), rep)
|
||||||
r.NoError(t, err)
|
r.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_BugReport(t *testing.T) {
|
|
||||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
r.NoError(t, checkMethodAndPath(req, "POST", "/reports/bug"))
|
|
||||||
|
|
||||||
var bugsReportReq ReportBugReq
|
|
||||||
r.NoError(t, json.NewDecoder(req.Body).Decode(&bugsReportReq))
|
|
||||||
r.Equal(t, testBugReportReq, bugsReportReq)
|
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
fmt.Fprint(w, testBugsBody)
|
|
||||||
}))
|
|
||||||
defer s.Close()
|
|
||||||
|
|
||||||
cm := newManager(newTestConfig(s.URL))
|
|
||||||
|
|
||||||
err := cm.ReportBug(context.Background(), testBugReportReq)
|
|
||||||
r.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user