aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-16 15:46:29 +0100
committerSimon Ser <contact@emersion.fr>2019-12-16 15:46:29 +0100
commit4449416357a2990dbaf2bf26ece4a910bb3d6a61 (patch)
tree2669e9d514f8e13ac51f9b941c4fa74144dab3ce
parent08b259bd50155c53259ae60042c8626a3615a993 (diff)
downloadalps-4449416357a2990dbaf2bf26ece4a910bb3d6a61.tar.gz
alps-4449416357a2990dbaf2bf26ece4a910bb3d6a61.zip
Export IMAPMessage
This is a public type other plugins and templates may want to access.
-rw-r--r--plugins/base/handlers.go10
-rw-r--r--plugins/base/imap.go22
2 files changed, 16 insertions, 16 deletions
diff --git a/plugins/base/handlers.go b/plugins/base/handlers.go
index e939cc5..8e9971a 100644
--- a/plugins/base/handlers.go
+++ b/plugins/base/handlers.go
@@ -21,7 +21,7 @@ type MailboxRenderData struct {
koushin.RenderData
Mailbox *imap.MailboxStatus
Mailboxes []*imap.MailboxInfo
- Messages []imapMessage
+ Messages []IMAPMessage
PrevPage, NextPage int
Query string
}
@@ -45,7 +45,7 @@ func handleGetMailbox(ectx echo.Context) error {
query := ctx.FormValue("query")
var mailboxes []*imap.MailboxInfo
- var msgs []imapMessage
+ var msgs []IMAPMessage
var mbox *imap.MailboxStatus
err = ctx.Session.DoIMAP(func(c *imapclient.Client) error {
var err error
@@ -121,7 +121,7 @@ func handleLogout(ectx echo.Context) error {
type MessageRenderData struct {
koushin.RenderData
Mailbox *imap.MailboxStatus
- Message *imapMessage
+ Message *IMAPMessage
Body string
PartPath string
MailboxPage int
@@ -138,7 +138,7 @@ func handleGetPart(ctx *koushin.Context, raw bool) error {
return echo.NewHTTPError(http.StatusBadRequest, err)
}
- var msg *imapMessage
+ var msg *IMAPMessage
var part *message.Entity
var mbox *imap.MailboxStatus
err = ctx.Session.DoIMAP(func(c *imapclient.Client) error {
@@ -219,7 +219,7 @@ func handleCompose(ectx echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, err)
}
- var inReplyTo *imapMessage
+ var inReplyTo *IMAPMessage
var part *message.Entity
err = ctx.Session.DoIMAP(func(c *imapclient.Client) error {
var err error
diff --git a/plugins/base/imap.go b/plugins/base/imap.go
index b1e36a6..3ccc73a 100644
--- a/plugins/base/imap.go
+++ b/plugins/base/imap.go
@@ -45,7 +45,7 @@ func ensureMailboxSelected(conn *imapclient.Client, mboxName string) error {
return nil
}
-type imapMessage struct {
+type IMAPMessage struct {
*imap.Message
}
@@ -94,7 +94,7 @@ func textPartPath(bs *imap.BodyStructure) ([]int, bool) {
return nil, false
}
-func (msg *imapMessage) TextPartName() string {
+func (msg *IMAPMessage) TextPartName() string {
if msg.BodyStructure == nil {
return ""
}
@@ -166,7 +166,7 @@ func imapPartTree(bs *imap.BodyStructure, path []int) *IMAPPartNode {
return node
}
-func (msg *imapMessage) PartTree() *IMAPPartNode {
+func (msg *IMAPMessage) PartTree() *IMAPPartNode {
if msg.BodyStructure == nil {
return nil
}
@@ -174,7 +174,7 @@ func (msg *imapMessage) PartTree() *IMAPPartNode {
return imapPartTree(msg.BodyStructure, nil)
}
-func listMessages(conn *imapclient.Client, mboxName string, page int) ([]imapMessage, error) {
+func listMessages(conn *imapclient.Client, mboxName string, page int) ([]IMAPMessage, error) {
if err := ensureMailboxSelected(conn, mboxName); err != nil {
return nil, err
}
@@ -200,9 +200,9 @@ func listMessages(conn *imapclient.Client, mboxName string, page int) ([]imapMes
done <- conn.Fetch(&seqSet, fetch, ch)
}()
- msgs := make([]imapMessage, 0, to-from)
+ msgs := make([]IMAPMessage, 0, to-from)
for msg := range ch {
- msgs = append(msgs, imapMessage{msg})
+ msgs = append(msgs, IMAPMessage{msg})
}
if err := <-done; err != nil {
@@ -218,7 +218,7 @@ func listMessages(conn *imapclient.Client, mboxName string, page int) ([]imapMes
return msgs, nil
}
-func searchMessages(conn *imapclient.Client, mboxName, query string) ([]imapMessage, error) {
+func searchMessages(conn *imapclient.Client, mboxName, query string) ([]IMAPMessage, error) {
if err := ensureMailboxSelected(conn, mboxName); err != nil {
return nil, err
}
@@ -249,13 +249,13 @@ func searchMessages(conn *imapclient.Client, mboxName, query string) ([]imapMess
done <- conn.Fetch(&seqSet, fetch, ch)
}()
- msgs := make([]imapMessage, len(nums))
+ msgs := make([]IMAPMessage, len(nums))
for msg := range ch {
i, ok := indexes[msg.SeqNum]
if !ok {
continue
}
- msgs[i] = imapMessage{msg}
+ msgs[i] = IMAPMessage{msg}
}
if err := <-done; err != nil {
@@ -265,7 +265,7 @@ func searchMessages(conn *imapclient.Client, mboxName, query string) ([]imapMess
return msgs, nil
}
-func getMessagePart(conn *imapclient.Client, mboxName string, uid uint32, partPath []int) (*imapMessage, *message.Entity, error) {
+func getMessagePart(conn *imapclient.Client, mboxName string, uid uint32, partPath []int) (*IMAPMessage, *message.Entity, error) {
if err := ensureMailboxSelected(conn, mboxName); err != nil {
return nil, nil, err
}
@@ -320,5 +320,5 @@ func getMessagePart(conn *imapclient.Client, mboxName string, uid uint32, partPa
return nil, nil, fmt.Errorf("failed to create message reader: %v", err)
}
- return &imapMessage{msg}, part, nil
+ return &IMAPMessage{msg}, part, nil
}