Merge pull request #3 from ProjectSegfault/announcements
I commited to announcements branch lmao
This commit is contained in:
		| @@ -36,7 +36,7 @@ func handleAnnouncements(w http.ResponseWriter, r *http.Request) { | |||||||
| 			return | 			return | ||||||
| 		} else { | 		} else { | ||||||
| 			w.WriteHeader(http.StatusOK) | 			w.WriteHeader(http.StatusOK) | ||||||
| 			now := time.Now() | 			now := time.Now().Unix() | ||||||
| 			data := map[string]interface{}{ | 			data := map[string]interface{}{ | ||||||
| 				"title":    r.FormValue("title"), | 				"title":    r.FormValue("title"), | ||||||
| 				"link":     r.FormValue("link"), | 				"link":     r.FormValue("link"), | ||||||
| @@ -50,7 +50,7 @@ func handleAnnouncements(w http.ResponseWriter, r *http.Request) { | |||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			ioutil.WriteFile("./static/announcements.json", jsonData, os.ModePerm) | 			ioutil.WriteFile("./data/announcements.json", jsonData, os.ModePerm) | ||||||
|  |  | ||||||
| 			w.Write([]byte("Announcement posted!")) | 			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) | 		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 | 		return | ||||||
| 	} else { | 	} 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) | 			http.Error(w, "If you're gonna delete the annoucement, there has to be an announcement in the first place.", http.StatusNotFound) | ||||||
| 			return | 			return | ||||||
| 		} else { | 		} else { | ||||||
| 			err := os.Remove("./static/announcements.json") | 			err := os.Remove("./data/announcements.json") | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				log.Fatal(err) | 				log.Fatal(err) | ||||||
| 			} | 			} | ||||||
| @@ -87,11 +87,11 @@ func getAnnouncements(w http.ResponseWriter, r *http.Request) { | |||||||
| 		http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) | 		http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) | ||||||
| 		return | 		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) | 		http.Error(w, "There are no announcements.", http.StatusNotFound) | ||||||
| 		return | 		return | ||||||
| 	} else { | 	} else { | ||||||
| 		f, err := os.Open("./static/announcements.json") | 		f, err := os.Open("./data/announcements.json") | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			log.Fatal(err) | 			log.Fatal(err) | ||||||
| 		} | 		} | ||||||
|   | |||||||
							
								
								
									
										0
									
								
								data/.gitkeep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								data/.gitkeep
									
									
									
									
									
										Normal file
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| HCAPTCHA_SITE_KEY=YOURSITEKEY | HCAPTCHA_SITE_KEY=YOURSITEKEY | ||||||
| HCAPTCHA_SECRET_KEY=YOURSECRETKEY | HCAPTCHA_SECRET_KEY=YOURSECRETKEY | ||||||
| SEGFAUTILS_WEBHOOK_URL=YOURWEBHOOKURL | SEGFAUTILS_WEBHOOK_URL=YOURWEBHOOKURL | ||||||
| SEGFAUTILS_AUTHTOKEN=YOURAUTHTOKEN | SEGFAUTILS_AUTHTOKEN=YOURAUTHTOKEN | ||||||
| @@ -8,7 +8,7 @@ For now it powers our contact form. In the future we will expand our APIs so you | |||||||
|  |  | ||||||
| ### Docker: | ### 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. | 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. | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user