added error log
This commit is contained in:
parent
19e7e2afed
commit
1ab8f49b77
@ -44,7 +44,7 @@ func instagramHandleExists(username string, bypass ...bool) string {
|
||||
utils.Logger.Infof("Checking Insta account: %v", username)
|
||||
records, _ := db.GetRecords(db.QueryOptions{Where: fmt.Sprintf(`handle='%v'`, username)})
|
||||
if len(records) > 0 && len(bypass) == 0 {
|
||||
utils.Logger.Infof("Using stored value")
|
||||
utils.Logger.Infof("Using stored value from DB")
|
||||
return records[0].URL
|
||||
}
|
||||
url := fmt.Sprintf("https://www.instagram.com/%s/", username)
|
||||
@ -92,6 +92,7 @@ func BinaryHandler(w http.ResponseWriter, req *http.Request) {
|
||||
var handle string
|
||||
var err error
|
||||
if binaryInput == "" {
|
||||
utils.Logger.Infof("Got Request for Text to Binary")
|
||||
asciiInput := req.URL.Query().Get("text")
|
||||
if asciiInput == "" {
|
||||
fmt.Fprintf(w, "Could not encode or decode!\n")
|
||||
@ -101,6 +102,7 @@ func BinaryHandler(w http.ResponseWriter, req *http.Request) {
|
||||
fmt.Fprintf(w, "%v\n", GetFancyResponse(`<center><p>`+text+`</p></center>`, ""))
|
||||
return
|
||||
} else {
|
||||
utils.Logger.Infof("Got Request for Binary to Text")
|
||||
text, err = binaryToASCII(binaryInput)
|
||||
text = strings.ReplaceAll(text, "@", "")
|
||||
handle = text
|
||||
|
||||
@ -2,19 +2,22 @@ package backend
|
||||
|
||||
import (
|
||||
"binaryserver/app/db"
|
||||
"binaryserver/app/utils"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ReportHandler(w http.ResponseWriter, req *http.Request) {
|
||||
utils.Logger.Infof("Got Request for reporting a link")
|
||||
handle := req.URL.Query().Get("handle")
|
||||
records, _ := db.GetRecords(db.QueryOptions{Where: fmt.Sprintf(`handle='%v'`, handle)})
|
||||
if len(records) > 0 {
|
||||
if result := instagramHandleExists(records[0].Handle, true); result == "" && records[0].URL != "" {
|
||||
fmt.Fprintf(w, "Link does seem to be bad. Fixing...\n")
|
||||
db.DeleteRecord(records[0])
|
||||
utils.Logger.Infof("Fixing bad link")
|
||||
} else {
|
||||
fmt.Fprintf(w, "Link seems to be active and working!\n")
|
||||
utils.Logger.Infof("Link is fine")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user