Skip to content

Commit

Permalink
Merge pull request #1 from hw-cs-reps/master
Browse files Browse the repository at this point in the history
Pulling new code
  • Loading branch information
Akilan1999 authored Dec 10, 2020
2 parents e181370 + 56103b5 commit 604a17e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
config.toml
.vscode
data.db
main
platform
2 changes: 2 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
15 changes: 12 additions & 3 deletions routes/complaints.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package routes

import (
"log"

"github.com/go-emmanuel/csrf"
"github.com/go-emmanuel/emmanuel"
"github.com/go-emmanuel/session"
Expand Down Expand Up @@ -63,22 +65,29 @@ func PostComplaintsHandler(ctx *emmanuel.Context, sess session.Store, f *session
}
}

mailer.Email(recipients, "Complaint submission", `A complaint submission
err := mailer.Email(recipients, "Complaint submission", `A complaint submission
From: `+sender+`
Category: `+ctx.QueryTrim("category")+`
Subject: `+ctx.QueryTrim("subject")+`
Message:
`+ctx.QueryTrim("message"))

f.Success("Your complaint was sent!")
if err != nil {
f.Error("There was an error sending the complaint!")
log.Println("Failed to send email")
log.Println(err)
} else {
f.Success("Your complaint was sent!")
}

ctx.Redirect("/complaints")
return
}

ctx.Data["Category"] = ctx.QueryTrim("category")
ctx.Data["Subject"] = ctx.QueryTrim("subject")
ctx.Data["Message"] = ctx.QueryTrim("message")
ctx.Data["Email"] = ctx.QueryTrim("Email")
ctx.Data["Email"] = ctx.QueryTrim("email")
ctx.Data["csrf_token"] = x.GetToken()

var recipients []string
Expand Down
9 changes: 3 additions & 6 deletions routes/tickets.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ func PostTicketPageHandler(ctx *emmanuel.Context, sess session.Store, f *session
ctx.Redirect("/tickets")
return
}
if ticket.IsResolved {
ctx.Redirect("/tickets/" + ctx.Params("id"))
return
}

text := strings.TrimFunc(ctx.QueryTrim("text"), IsImproperChar)
if len(text) == 0 {
Expand Down Expand Up @@ -273,7 +269,8 @@ func PostNewTicketHandler(ctx *emmanuel.Context, sess session.Store, f *session.

func userHash(ip string, useragent string) string {
h := sha256.New()
h.Write([]byte(ip + useragent + config.Config.VoterPepper))
//h.Write([]byte(ip + useragent + config.Config.VoterPepper))
h.Write([]byte(ip + config.Config.VoterPepper))
return fmt.Sprintf("%x", h.Sum(nil))
}

Expand Down Expand Up @@ -441,7 +438,7 @@ func PostTicketDeleteHandler(ctx *emmanuel.Context, sess session.Store, f *sessi

// PostCommentDeleteHandler response for deleting a ticket's comment.
func PostCommentDeleteHandler(ctx *emmanuel.Context, sess session.Store, f *session.Flash) {
c, err := models.GetComment(ctx.ParamsInt64("id"))
c, err := models.GetComment(ctx.ParamsInt64("cid"))
if err != nil {
f.Error("Comment not found!")
ctx.Redirect("/tickets")
Expand Down

0 comments on commit 604a17e

Please sign in to comment.