From 7e32008c589b61234679517854a2c6488c8707f3 Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Wed, 14 Oct 2020 18:27:26 +0400 Subject: [PATCH 1/8] Resolve email for complaints not included --- routes/complaints.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/complaints.go b/routes/complaints.go index fa9fe11..613a950 100644 --- a/routes/complaints.go +++ b/routes/complaints.go @@ -78,7 +78,7 @@ Message: 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 From 063095e46e78655dad69a7e00c7a3e384e0ef9cf Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Wed, 14 Oct 2020 18:36:04 +0400 Subject: [PATCH 2/8] Add binary to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c592497..f66326e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ config.toml .vscode data.db +main +platform From 27a37209e73cc146bce64409ffe53a8aa50b9ddb Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Wed, 14 Oct 2020 19:28:11 +0400 Subject: [PATCH 3/8] Add robots.txt to prevent indexing by search engines. --- public/robots.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 public/robots.txt diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / From d71ad817fa2a29ccac29aad07e03fb0a1c7e1421 Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Wed, 14 Oct 2020 21:25:25 +0400 Subject: [PATCH 4/8] Add instance to the complaint email --- routes/complaints.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/complaints.go b/routes/complaints.go index 613a950..f163aa4 100644 --- a/routes/complaints.go +++ b/routes/complaints.go @@ -67,6 +67,7 @@ func PostComplaintsHandler(ctx *emmanuel.Context, sess session.Store, f *session From: `+sender+` Category: `+ctx.QueryTrim("category")+` Subject: `+ctx.QueryTrim("subject")+` +Instance: `+config.Config.SiteScope+` Message: `+ctx.QueryTrim("message")) From 98052d2190c80e51375c4b20722617414e4d2ca0 Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Wed, 14 Oct 2020 21:36:24 +0400 Subject: [PATCH 5/8] Show error when complaint couldn't be sent --- routes/complaints.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/routes/complaints.go b/routes/complaints.go index f163aa4..d67f0fe 100644 --- a/routes/complaints.go +++ b/routes/complaints.go @@ -1,6 +1,8 @@ package routes import ( + "log" + "github.com/go-emmanuel/csrf" "github.com/go-emmanuel/emmanuel" "github.com/go-emmanuel/session" @@ -63,7 +65,7 @@ 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")+` @@ -71,7 +73,14 @@ Instance: `+config.Config.SiteScope+` 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 } From 2d73e28f6d13c01a4cb74a335c41cc89567439eb Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Wed, 14 Oct 2020 21:39:19 +0400 Subject: [PATCH 6/8] Remove instance (as HW mail servers reject it as spam) --- routes/complaints.go | 1 - 1 file changed, 1 deletion(-) diff --git a/routes/complaints.go b/routes/complaints.go index d67f0fe..8cfdfe4 100644 --- a/routes/complaints.go +++ b/routes/complaints.go @@ -69,7 +69,6 @@ func PostComplaintsHandler(ctx *emmanuel.Context, sess session.Store, f *session From: `+sender+` Category: `+ctx.QueryTrim("category")+` Subject: `+ctx.QueryTrim("subject")+` -Instance: `+config.Config.SiteScope+` Message: `+ctx.QueryTrim("message")) From 929c5dc5a5e55fc2b8f518c0c8e16c2477b89fbd Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Tue, 3 Nov 2020 19:39:39 +0000 Subject: [PATCH 7/8] Fix deleting comments. --- routes/tickets.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/tickets.go b/routes/tickets.go index b38a90c..253e70b 100644 --- a/routes/tickets.go +++ b/routes/tickets.go @@ -441,7 +441,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") From 56103b5291c4d33ba0516f7d35c1652d42f80ccb Mon Sep 17 00:00:00 2001 From: Humaid AlQassimi Date: Wed, 18 Nov 2020 14:12:02 +0000 Subject: [PATCH 8/8] Make votes based on IP. Also allow commenting on resolved tickets. --- routes/tickets.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/routes/tickets.go b/routes/tickets.go index 253e70b..9fd4e73 100644 --- a/routes/tickets.go +++ b/routes/tickets.go @@ -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 { @@ -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)) }