1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
package backend
import (
"encoding/base64"
"github.com/ProtonMail/gluon/rfc822"
"github.com/google/uuid"
"github.com/henrybear327/go-proton-api"
)
func (b *Backend) createAttData(dataPacket []byte) string {
attDataID := uuid.NewString()
b.attDataLock.Lock()
defer b.attDataLock.Unlock()
b.attData[attDataID] = dataPacket
return attDataID
}
type attachment struct {
attachID string
attDataID string
filename string
mimeType rfc822.MIMEType
disposition proton.Disposition
keyPackets []byte
armSig string
}
func newAttachment(
filename string,
mimeType rfc822.MIMEType,
disposition proton.Disposition,
keyPackets []byte,
dataPacketID string,
armSig string,
) *attachment {
return &attachment{
attachID: uuid.NewString(),
attDataID: dataPacketID,
filename: filename,
mimeType: mimeType,
disposition: disposition,
keyPackets: keyPackets,
armSig: armSig,
}
}
func (att *attachment) toAttachment() proton.Attachment {
return proton.Attachment{
ID: att.attachID,
Name: att.filename,
MIMEType: att.mimeType,
Disposition: att.disposition,
KeyPackets: base64.StdEncoding.EncodeToString(att.keyPackets),
Signature: att.armSig,
}
}
|