diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-04-25 08:30:43 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-04-27 09:46:11 +0200 |
commit | d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa (patch) | |
tree | 5f0ec8c9ad11a0f638c25dbd896a518e983dc779 /lib/messageview.go | |
parent | afe35839eddfaf43be0f791e97a926a15d91fc02 (diff) | |
download | aerc-d09636ee0b9957ed60fc01224ddfbb03c4f4b7fa.tar.gz |
refactor: refactor pgp implementation
This commit refactors the internal PGP implementation to make way for
GPG integration.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/messageview.go')
-rw-r--r-- | lib/messageview.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/messageview.go b/lib/messageview.go index f221fb2c..a1797d53 100644 --- a/lib/messageview.go +++ b/lib/messageview.go @@ -8,8 +8,8 @@ import ( "github.com/ProtonMail/go-crypto/openpgp" "github.com/emersion/go-message" _ "github.com/emersion/go-message/charset" - "github.com/emersion/go-pgpmail" + "git.sr.ht/~rjarry/aerc/lib/crypto" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/lib" "git.sr.ht/~rjarry/aerc/worker/types" @@ -30,7 +30,7 @@ type MessageView interface { // Fetches a specific body part for this message FetchBodyPart(part []int, cb func(io.Reader)) - PGPDetails() *openpgp.MessageDetails + MessageDetails() *models.MessageDetails } func usePGP(info *models.BodyStructure) bool { @@ -56,12 +56,12 @@ type MessageStoreView struct { messageInfo *models.MessageInfo messageStore *MessageStore message []byte - details *openpgp.MessageDetails + details *models.MessageDetails bodyStructure *models.BodyStructure } func NewMessageStoreView(messageInfo *models.MessageInfo, - store *MessageStore, decryptKeys openpgp.PromptFunction, + store *MessageStore, pgp crypto.Provider, decryptKeys openpgp.PromptFunction, cb func(MessageView, error)) { msv := &MessageStoreView{messageInfo, store, @@ -70,12 +70,12 @@ func NewMessageStoreView(messageInfo *models.MessageInfo, if usePGP(messageInfo.BodyStructure) { store.FetchFull([]uint32{messageInfo.Uid}, func(fm *types.FullMessage) { reader := lib.NewCRLFReader(fm.Content.Reader) - pgpReader, err := pgpmail.Read(reader, Keyring, decryptKeys, nil) + md, err := pgp.Decrypt(reader, decryptKeys) if err != nil { cb(nil, err) return } - msv.message, err = ioutil.ReadAll(pgpReader.MessageDetails.UnverifiedBody) + msv.message, err = ioutil.ReadAll(md.Body) if err != nil { cb(nil, err) return @@ -91,7 +91,7 @@ func NewMessageStoreView(messageInfo *models.MessageInfo, return } msv.bodyStructure = bs - msv.details = pgpReader.MessageDetails + msv.details = md cb(msv, nil) }) } else { @@ -112,7 +112,7 @@ func (msv *MessageStoreView) Store() *MessageStore { return msv.messageStore } -func (msv *MessageStoreView) PGPDetails() *openpgp.MessageDetails { +func (msv *MessageStoreView) MessageDetails() *models.MessageDetails { return msv.details } |