From 19e8dae383a9d7e7cbb118de856352e281660d8d Mon Sep 17 00:00:00 2001 From: Odyssey346 Date: Thu, 4 Aug 2022 21:20:21 +0200 Subject: [PATCH 1/2] add to docker.env Signed-off-by: Odyssey346 --- docker.env | 1 + 1 file changed, 1 insertion(+) diff --git a/docker.env b/docker.env index 1340b31..75f61d9 100644 --- a/docker.env +++ b/docker.env @@ -1,3 +1,4 @@ HCAPTCHA_SITE_KEY=YOURSITEKEY HCAPTCHA_SECRET_KEY=YOURSECRETKEY SEGFAUTILS_WEBHOOK_URL=YOURWEBHOOKURL +SEGFAUTILS_AUTHTOKEN=YOURAUTHTOKEN \ No newline at end of file From ee6b5252233d13b1d79e2c366ffae28b6f916402 Mon Sep 17 00:00:00 2001 From: Odyssey346 Date: Fri, 5 Aug 2022 15:17:56 +0200 Subject: [PATCH 2/2] use epoch time for announcements, docker improve Signed-off-by: Odyssey346 --- api/announcements.go | 12 ++++++------ data/.gitkeep | 0 readme.md | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 data/.gitkeep diff --git a/api/announcements.go b/api/announcements.go index 6338928..ffe41e9 100644 --- a/api/announcements.go +++ b/api/announcements.go @@ -36,7 +36,7 @@ func handleAnnouncements(w http.ResponseWriter, r *http.Request) { return } else { w.WriteHeader(http.StatusOK) - now := time.Now() + now := time.Now().Unix() data := map[string]interface{}{ "title": r.FormValue("title"), "link": r.FormValue("link"), @@ -50,7 +50,7 @@ func handleAnnouncements(w http.ResponseWriter, r *http.Request) { return } - ioutil.WriteFile("./static/announcements.json", jsonData, os.ModePerm) + ioutil.WriteFile("./data/announcements.json", jsonData, os.ModePerm) w.Write([]byte("Announcement posted!")) } @@ -67,11 +67,11 @@ func handleAnnouncementDeleteRequest(w http.ResponseWriter, r *http.Request) { http.Error(w, "You need to provide the authorization token given to you by your system administrator in order to delete an announcement.", http.StatusUnauthorized) return } else { - if _, err := os.Stat("./static/announcements.json"); errors.Is(err, os.ErrNotExist) { + if _, err := os.Stat("./data/announcements.json"); errors.Is(err, os.ErrNotExist) { http.Error(w, "If you're gonna delete the annoucement, there has to be an announcement in the first place.", http.StatusNotFound) return } else { - err := os.Remove("./static/announcements.json") + err := os.Remove("./data/announcements.json") if err != nil { log.Fatal(err) } @@ -87,11 +87,11 @@ func getAnnouncements(w http.ResponseWriter, r *http.Request) { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) return } - if _, err := os.Stat("./static/announcements.json"); errors.Is(err, os.ErrNotExist) { + if _, err := os.Stat("./data/announcements.json"); errors.Is(err, os.ErrNotExist) { http.Error(w, "There are no announcements.", http.StatusNotFound) return } else { - f, err := os.Open("./static/announcements.json") + f, err := os.Open("./data/announcements.json") if err != nil { log.Fatal(err) } diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/readme.md b/readme.md index ce48ad0..9a4c360 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ For now it powers our contact form. In the future we will expand our APIs so you ### Docker: ``` -docker run -d --restart=always -p 6893:6893 --name segfautils projectsegfault/segfautils:latest --env-file ./docker.env +docker run -d --restart=always -p 6893:6893 --name segfautils --env-file ./docker.env -v "$(pwd)"/data:/segfautils/data projectsegfault/segfautils:latest ``` docker.env should be the environment file located in this repository, customized to your settings. The env file is self-documenting so I don't need to go in any detail here.