webmail: less boilerplate code for api functions

open the account at the beginning of the api handler, and close accounts there too
This commit is contained in:
Mechiel Lukkien
2024-04-21 21:32:24 +02:00
parent ed0c520562
commit a3f5fd26a6
5 changed files with 236 additions and 336 deletions

View File

@ -45,7 +45,7 @@ func TestView(t *testing.T) {
api := Webmail{maxMessageSize: 1024 * 1024, cookiePath: "/"}
respRec := httptest.NewRecorder()
reqInfo := requestInfo{"mjl@mox.example", "mjl", "", respRec, &http.Request{RemoteAddr: "127.0.0.1:1234"}}
reqInfo := requestInfo{log, "mjl@mox.example", acc, "", respRec, &http.Request{RemoteAddr: "127.0.0.1:1234"}}
ctx := context.WithValue(ctxbg, requestInfoCtxKey, reqInfo)
// Prepare loginToken.
@ -70,7 +70,7 @@ func TestView(t *testing.T) {
}
sessionToken := store.SessionToken(sct[0])
reqInfo = requestInfo{"mjl@mox.example", "mjl", sessionToken, respRec, &http.Request{}}
reqInfo = requestInfo{log, "mjl@mox.example", acc, sessionToken, respRec, &http.Request{}}
ctx = context.WithValue(ctxbg, requestInfoCtxKey, reqInfo)
api.MailboxCreate(ctx, "Lists/Go/Nuts")