1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-19 02:27:03 +00:00

Add a view source button to see raw text of message

This commit is contained in:
James Hillyerd
2012-10-13 14:37:11 -07:00
parent a0ab84abb5
commit eb363aa670
4 changed files with 44 additions and 1 deletions

View File

@@ -78,3 +78,27 @@ func (c Mailbox) Delete(name string, id string) rev.Result {
}
return c.RenderText("OK")
}
func (c Mailbox) Source(name string, id string) rev.Result {
ds := inbucket.NewDataStore()
mb, err := ds.MailboxFor(name)
if err != nil {
rev.ERROR.Printf(err.Error())
c.Flash.Error(err.Error())
return c.Redirect(Application.Index)
}
message, err := mb.GetMessage(id)
if err != nil {
rev.ERROR.Printf(err.Error())
c.Flash.Error(err.Error())
return c.Redirect(Application.Index)
}
raw, err := message.ReadRaw()
if err != nil {
rev.ERROR.Printf(err.Error())
c.Flash.Error(err.Error())
return c.Redirect(Application.Index)
}
return c.RenderText(*raw)
}