| 1 |
package proton |
| 2 |
|
| 3 |
import ( |
| 4 |
"encoding/json" |
| 5 |
"fmt" |
| 6 |
|
| 7 |
"github.com/ProtonMail/gluon/rfc822" |
| 8 |
) |
| 9 |
|
| 10 |
type ClientType int |
| 11 |
|
| 12 |
const ( |
| 13 |
ClientTypeEmail ClientType = iota + 1 |
| 14 |
ClientTypeVPN |
| 15 |
ClientTypeCalendar |
| 16 |
ClientTypeDrive |
| 17 |
) |
| 18 |
|
| 19 |
type ReportBugReq struct { |
| 20 |
OS string |
| 21 |
OSVersion string |
| 22 |
|
| 23 |
Browser string |
| 24 |
BrowserVersion string |
| 25 |
BrowserExtensions string |
| 26 |
|
| 27 |
Resolution string |
| 28 |
DisplayMode string |
| 29 |
|
| 30 |
Client string |
| 31 |
ClientVersion string |
| 32 |
ClientType ClientType |
| 33 |
|
| 34 |
Title string |
| 35 |
Description string |
| 36 |
|
| 37 |
Username string |
| 38 |
Email string |
| 39 |
|
| 40 |
Country string |
| 41 |
ISP string |
| 42 |
} |
| 43 |
|
| 44 |
func (req ReportBugReq) toFormData() map[string]string { |
| 45 |
b, err := json.Marshal(req) |
| 46 |
if err != nil { |
| 47 |
panic(err) |
| 48 |
} |
| 49 |
|
| 50 |
var raw map[string]any |
| 51 |
|
| 52 |
if err := json.Unmarshal(b, &raw); err != nil { |
| 53 |
panic(err) |
| 54 |
} |
| 55 |
|
| 56 |
res := make(map[string]string) |
| 57 |
|
| 58 |
for key := range raw { |
| 59 |
if val := fmt.Sprint(raw[key]); val != "" { |
| 60 |
res[key] = val |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
return res |
| 65 |
} |
| 66 |
|
| 67 |
type ReportBugAttachment struct { |
| 68 |
Name string |
| 69 |
Filename string |
| 70 |
MIMEType rfc822.MIMEType |
| 71 |
Body []byte |
| 72 |
} |