Commit graph

11 commits

Author SHA1 Message Date
Simon Ser e54a359acb
Export Server.{Sessions,Plugins}
And unexport a few internal functions.
2019-12-11 13:03:31 +01:00
Simon Ser 86359156ee
Export Context.SetSession, unexport Session.Token
I'm uneasy exposing the token to plugins, I prefer to hide it if
possible to prevent mis-use.

This change allows plugins to logout users.
2019-12-11 12:54:03 +01:00
Simon Ser d8f411176f
Export Context
This allows plugins to access it.
2019-12-11 12:48:20 +01:00
Simon Ser 835e9e5033
go fmt 2019-12-10 17:39:42 +01:00
Simon Ser 3748b4413e
Introduce GlobalRenderData and RenderData
GlobalRenderData contains some global metadata that can be obtained from
any template.

RenderData is a base type for template data. It contains a Global field
with global metadata and an Extra field for plugins.
2019-12-10 17:36:21 +01:00
Simon Ser c5afd1a61b
Reconnect to IMAP server when logged out
The session manager has been upgraded to deal with reconnections.

Each session has its own expiration timer. Each time a request is
received, the expiration timer is reset.

A session can be closed (this is used when the user wants to logout).

When the IMAP connection is closed by the server, it's set to nil in the
session. The next time an IMAP command needs to be issued, the
connection is re-established.

Closes: https://todo.sr.ht/~sircmpwn/koushin/30
2019-12-09 19:35:15 +01:00
Simon Ser 7702925497
Make SessionManager create the IMAP client
This will allow SessionManager to re-connect when the IMAP server logs
the user out.
2019-12-09 18:35:51 +01:00
Simon Ser efd401bfbf
Rename ConnPool to SessionManager 2019-12-09 18:16:31 +01:00
Simon Ser 9617b412e8
Make render data static
This makes sure fields filled by vanilla koushin keep the right type. A
new Extra field allows plugins to attach their own data.

This also makes it easier to write Go plugins, which would have trouble
working with interface{}.
2019-12-09 16:17:36 +01:00
Simon Ser 61ffc105fd
Use imap.BodyStructure.Filename and imap.Address.Address
The former fixes encoding issues in filenames. The latter is just for
brevity.
2019-12-09 13:45:15 +01:00
Simon Ser d1d4380957
Extract HTTP handlers in separate file 2019-12-04 20:55:08 +01:00