From 2a2a48c7fafc4a32b1f4a4629e1d5447e29e8d57 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 17 Dec 2019 12:42:04 +0100 Subject: Add a form to set message flags References: https://todo.sr.ht/~sircmpwn/koushin/36 --- plugins/base/imap.go | 10 ++++ plugins/base/public/message.html | 21 +++++++- plugins/base/routes.go | 100 ++++++++++++++++++++++++++++++--------- plugins/base/template.go | 22 +++++++++ 4 files changed, 130 insertions(+), 23 deletions(-) (limited to 'plugins') diff --git a/plugins/base/imap.go b/plugins/base/imap.go index 3ccc73a..433a63e 100644 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -174,6 +174,15 @@ func (msg *IMAPMessage) PartTree() *IMAPPartNode { return imapPartTree(msg.BodyStructure, nil) } +func (msg *IMAPMessage) HasFlag(flag string) bool { + for _, f := range msg.Flags { + if imap.CanonicalFlag(f) == flag { + return true + } + } + return false +} + func listMessages(conn *imapclient.Client, mboxName string, page int) ([]IMAPMessage, error) { if err := ensureMailboxSelected(conn, mboxName); err != nil { return nil, err @@ -295,6 +304,7 @@ func getMessagePart(conn *imapclient.Client, mboxName string, uid uint32, partPa imap.FetchEnvelope, imap.FetchUid, imap.FetchBodyStructure, + imap.FetchFlags, partHeaderSection.FetchItem(), partBodySection.FetchItem(), } diff --git a/plugins/base/public/message.html b/plugins/base/public/message.html index 0b7a8d5..56e6e6f 100644 --- a/plugins/base/public/message.html +++ b/plugins/base/public/message.html @@ -30,6 +30,25 @@ +{{if .Flags}} +
+

Flags:

+ {{range $name, $has := .Flags}} + {{if ismutableflag $name}} + + +
+ {{else}} + {{if $has}} + + {{end}} + {{end}} + {{end}} + +
+{{end}} +