Browse Source

Add Config API Endpoint

hkremer/rebranding
Gregory Rudolph 4 years ago
parent
commit
86c95bb012
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 1
      .gitignore
  2. 2
      main.go
  3. 16
      site-api.go

1
.gitignore vendored

@ -4,5 +4,6 @@ disgord-thanos
disgord-Thanos disgord-Thanos
config.json config.json
start.sh start.sh
dev.html
verifications/* verifications/*
node_modules/ node_modules/

2
main.go

@ -155,7 +155,7 @@ func runPurge(s *discordgo.Session) {
func ready(s *discordgo.Session, event *discordgo.Ready) { func ready(s *discordgo.Session, event *discordgo.Ready) {
// Set the playing status. // Set the playing status.
s.UpdateStatus(0, "DreamDaddy v2.0") s.UpdateStatus(0, "DreamDaddy v2.1")
} }
func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) { func guildMemberUpdate(s *discordgo.Session, m *discordgo.GuildMemberUpdate) {

16
site-api.go

@ -131,7 +131,20 @@ func getPending(w http.ResponseWriter, r *http.Request) {
notFoundPage(w, r) notFoundPage(w, r)
} }
} }
func getConfig(w http.ResponseWriter, r *http.Request) {
defer log.PanicSafe()
loggedIn, _ := detectUser(r, "getConfig")
if loggedIn {
pending, err := json.Marshal(config)
if err != nil {
log.LogErrorType(err)
notFoundPage(w, r)
}
fmt.Fprintf(w, string(pending))
} else {
notFoundPage(w, r)
}
}
func getProbations(w http.ResponseWriter, r *http.Request) { func getProbations(w http.ResponseWriter, r *http.Request) {
defer log.PanicSafe() defer log.PanicSafe()
loggedIn, _ := detectUser(r, "getProbations") loggedIn, _ := detectUser(r, "getProbations")
@ -222,6 +235,7 @@ func runWeb() {
router.HandleFunc("/pass", passPage) router.HandleFunc("/pass", passPage)
router.HandleFunc("/login", loginPage) router.HandleFunc("/login", loginPage)
router.HandleFunc("/api/login", tryLogin) router.HandleFunc("/api/login", tryLogin)
router.HandleFunc("/api/config", getConfig)
router.HandleFunc("/api/pending", getPending) router.HandleFunc("/api/pending", getPending)
router.HandleFunc("/api/verifications", getVerifications) router.HandleFunc("/api/verifications", getVerifications)
router.HandleFunc("/api/probations", getProbations) router.HandleFunc("/api/probations", getProbations)

Loading…
Cancel
Save