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

Add a Link button to messages

Allows users to copy the URL for a specific message and send it to
another person.
This commit is contained in:
James Hillyerd
2013-10-25 13:29:26 -07:00
parent ea7274e5dd
commit 47cba08c33
4 changed files with 33 additions and 14 deletions

View File

@@ -31,6 +31,8 @@ type JsonMessageBody struct {
func MailboxIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
name := req.FormValue("name")
selected := req.FormValue("id")
if len(name) == 0 {
ctx.Session.AddFlash("Account name is required", "errors")
http.Redirect(w, req, reverse("RootIndex"), http.StatusSeeOther)
@@ -40,9 +42,19 @@ func MailboxIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err e
return RenderTemplate("mailbox/index.html", w, map[string]interface{}{
"ctx": ctx,
"name": name,
"selected": selected,
})
}
func MailboxLink(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
name := ctx.Vars["name"]
id := ctx.Vars["id"]
uri := fmt.Sprintf("%s?name=%s&id=%s", reverse("MailboxIndex"), name, id)
http.Redirect(w, req, uri, http.StatusSeeOther)
return nil
}
func MailboxList(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
// Don't have to validate these aren't empty, Gorilla returns 404
name := ctx.Vars["name"]