google mail API [[FIN]]
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m28s

This commit is contained in:
2023-12-04 13:48:11 +01:00
parent 8f13eb2f16
commit 358c238f3d
9 changed files with 549 additions and 131 deletions

View File

@@ -7,35 +7,40 @@ import (
type MailAttachment struct {
IsInline bool
ContentType *string
Filename *string
ContentType string
Filename string
Data []byte
}
func (a MailAttachment) dump() []string {
res := make([]string, 0, 4)
if a.ContentType != nil {
res = append(res, "Content-Type: "+*a.ContentType+"; charset=UTF-8")
if a.ContentType != "" {
res = append(res, "Content-Type: "+a.ContentType+"; charset=UTF-8")
}
res = append(res, "Content-Transfer-Encoding: base64")
if a.IsInline {
if a.Filename != nil {
res = append(res, fmt.Sprintf("Content-Disposition: inline;filename=\"%s\"", *a.Filename))
if a.Filename != "" {
res = append(res, fmt.Sprintf("Content-Disposition: inline;filename=\"%s\"", a.Filename))
} else {
res = append(res, "Content-Disposition: inline")
}
} else {
if a.Filename != nil {
res = append(res, fmt.Sprintf("Content-Disposition: attachment;filename=\"%s\"", *a.Filename))
if a.Filename != "" {
res = append(res, fmt.Sprintf("Content-Disposition: attachment;filename=\"%s\"", a.Filename))
} else {
res = append(res, "Content-Disposition: attachment")
}
}
res = append(res, base64.URLEncoding.EncodeToString(a.Data))
b64 := base64.StdEncoding.EncodeToString(a.Data)
for i := 0; i < len(b64); i += 80 {
res = append(res, b64[i:min(i+80, len(b64))])
}
res = append(res)
return res
}