Get Voip.ms working again in the text system
Because we need it for the conference.
This commit is contained in:
parent
a900c23090
commit
d2d5f003d8
8 changed files with 221 additions and 57 deletions
|
|
@ -39,7 +39,7 @@ func apiAudioPost(w http.ResponseWriter, r *http.Request, u *models.User) {
|
|||
return
|
||||
}
|
||||
if err := json.Unmarshal(body, &payload); err != nil {
|
||||
debugSaveRequest(body, err, "Audio note POST JSON decode error")
|
||||
//debugSaveRequest(body, err, "Audio note POST JSON decode error")
|
||||
http.Error(w, "Failed to decode the payload", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ func apiImagePost(w http.ResponseWriter, r *http.Request, u *models.User) {
|
|||
return
|
||||
}
|
||||
if err := json.Unmarshal(body, &payload); err != nil {
|
||||
debugSaveRequest(body, err, "Image note POST JSON decode error")
|
||||
//debugSaveRequest(body, err, "Image note POST JSON decode error")
|
||||
http.Error(w, "Failed to decode the payload", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
21
api/debug.go
21
api/debug.go
|
|
@ -1,22 +1,25 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func debugSaveRequest(body []byte, err error, message string) {
|
||||
// TODO(eliribble): avoid using a single static filename and instead securely generate
|
||||
// this value
|
||||
func debugSaveRequest(r *http.Request) {
|
||||
tmpFile, err := os.CreateTemp("/tmp", "request-*.data")
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg(message)
|
||||
log.Error().Err(err).Msg("failed to create temp file for debugSaveRequest")
|
||||
return
|
||||
}
|
||||
output, err := os.OpenFile("/tmp/request.body", os.O_RDWR|os.O_CREATE, 0666)
|
||||
defer tmpFile.Close()
|
||||
|
||||
_, err = io.Copy(tmpFile, r.Body)
|
||||
if err != nil {
|
||||
log.Info().Msg("Failed to open temp request.bady")
|
||||
log.Error().Err(err).Msg("failed to copy request body in debugSaveRequest")
|
||||
return
|
||||
}
|
||||
defer output.Close()
|
||||
output.Write(body)
|
||||
log.Info().Msg("Wrote request to /tmp/request.body")
|
||||
log.Info().Str("filename", tmpFile.Name()).Msg("Saved request body")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ func AddRoutes(r chi.Router) {
|
|||
r.Post("/twilio/message", twilioMessagePost)
|
||||
r.Post("/twilio/text", twilioTextPost)
|
||||
r.Post("/twilio/text/status", twilioTextStatusPost)
|
||||
r.Get("/voipms/text", voipmsTextGet)
|
||||
r.Post("/voipms/text", voipmsTextPost)
|
||||
r.Get("/webhook/fieldseeker", webhookFieldseeker)
|
||||
r.Post("/webhook/fieldseeker", webhookFieldseeker)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue