diff options
author | Robin Jarry <robin@jarry.cc> | 2023-02-02 00:48:51 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-02-20 14:40:59 +0100 |
commit | 9fa296fb762231d386db88913d1c2ea521bd813c (patch) | |
tree | 445bf6554084bb37e6aed479c9942b5afecb2149 /models/templates.go | |
parent | 28483808727fd288b95b9dd26a716f6cf7c02b5a (diff) | |
download | aerc-9fa296fb762231d386db88913d1c2ea521bd813c.tar.gz |
templates: unify data interface
Require that all aerc template data objects implement the same
TemplateData interface.
Implement that interface in two different places:
1) state.TemplateData (renamed/moved from templates.TemplateData).
This structure (along with all its methods) needs to be decoupled
from the templates package to break the import cycle with the config
package. This allows much simpler construction of this object and
ensure that values are calculated only when requested.
2) config.dummyData (extracted from templates).
This is only used in the config package to validate user templates.
Putting it here allows also to break an import cycle.
Use state.TemplateData everywhere (including for account tabs title
rendering).
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'models/templates.go')
-rw-r--r-- | models/templates.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/models/templates.go b/models/templates.go new file mode 100644 index 00000000..84f68c21 --- /dev/null +++ b/models/templates.go @@ -0,0 +1,36 @@ +package models + +import ( + "time" + + "github.com/emersion/go-message/mail" +) + +// This interface needs to be implemented for compliance with aerc-templates(7) +type TemplateData interface { + Account() string + Folder() string + To() []*mail.Address + Cc() []*mail.Address + Bcc() []*mail.Address + From() []*mail.Address + Peer() []*mail.Address + ReplyTo() []*mail.Address + Date() time.Time + DateAutoFormat(date time.Time) string + Header(name string) string + Subject() string + Number() int + Labels() []string + Flags() []string + MessageId() string + Size() int + OriginalText() string + OriginalDate() time.Time + OriginalFrom() []*mail.Address + OriginalMIMEType() string + OriginalHeader(name string) string + Recent() int + Unread() int + Exists() int +} |