added error log

This commit is contained in:
rayaman 2025-06-26 11:56:30 -04:00
parent 19e7e2afed
commit 1ab8f49b77
2 changed files with 7 additions and 2 deletions

View File

@ -44,7 +44,7 @@ func instagramHandleExists(username string, bypass ...bool) string {
utils.Logger.Infof("Checking Insta account: %v", username) utils.Logger.Infof("Checking Insta account: %v", username)
records, _ := db.GetRecords(db.QueryOptions{Where: fmt.Sprintf(`handle='%v'`, username)}) records, _ := db.GetRecords(db.QueryOptions{Where: fmt.Sprintf(`handle='%v'`, username)})
if len(records) > 0 && len(bypass) == 0 { 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 return records[0].URL
} }
url := fmt.Sprintf("https://www.instagram.com/%s/", username) 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 handle string
var err error var err error
if binaryInput == "" { if binaryInput == "" {
utils.Logger.Infof("Got Request for Text to Binary")
asciiInput := req.URL.Query().Get("text") asciiInput := req.URL.Query().Get("text")
if asciiInput == "" { if asciiInput == "" {
fmt.Fprintf(w, "Could not encode or decode!\n") 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>`, "")) fmt.Fprintf(w, "%v\n", GetFancyResponse(`<center><p>`+text+`</p></center>`, ""))
return return
} else { } else {
utils.Logger.Infof("Got Request for Binary to Text")
text, err = binaryToASCII(binaryInput) text, err = binaryToASCII(binaryInput)
text = strings.ReplaceAll(text, "@", "") text = strings.ReplaceAll(text, "@", "")
handle = text handle = text

View File

@ -2,19 +2,22 @@ package backend
import ( import (
"binaryserver/app/db" "binaryserver/app/db"
"binaryserver/app/utils"
"fmt" "fmt"
"net/http" "net/http"
) )
func ReportHandler(w http.ResponseWriter, req *http.Request) { func ReportHandler(w http.ResponseWriter, req *http.Request) {
utils.Logger.Infof("Got Request for reporting a link")
handle := req.URL.Query().Get("handle") handle := req.URL.Query().Get("handle")
records, _ := db.GetRecords(db.QueryOptions{Where: fmt.Sprintf(`handle='%v'`, handle)}) records, _ := db.GetRecords(db.QueryOptions{Where: fmt.Sprintf(`handle='%v'`, handle)})
if len(records) > 0 { if len(records) > 0 {
if result := instagramHandleExists(records[0].Handle, true); result == "" && records[0].URL != "" { if result := instagramHandleExists(records[0].Handle, true); result == "" && records[0].URL != "" {
fmt.Fprintf(w, "Link does seem to be bad. Fixing...\n") fmt.Fprintf(w, "Link does seem to be bad. Fixing...\n")
db.DeleteRecord(records[0]) utils.Logger.Infof("Fixing bad link")
} else { } else {
fmt.Fprintf(w, "Link seems to be active and working!\n") fmt.Fprintf(w, "Link seems to be active and working!\n")
utils.Logger.Infof("Link is fine")
} }
} }
} }