Fixed no shortcode

This commit is contained in:
cdricms
2025-02-11 10:12:37 +01:00
parent 60dd966f3e
commit 2c2be9fdba
6 changed files with 644 additions and 104 deletions

View File

@@ -12,12 +12,21 @@ import (
func HandleShortcode(w http.ResponseWriter, r *http.Request) {
code := r.PathValue("shortcode")
var shortcode models.Shortcode
err := core.DB.NewSelect().
count, err := core.DB.NewSelect().
Model(&shortcode).
Where("code = ?", code).
Relation("Media").
Limit(1).
Scan(context.Background())
ScanAndCount(context.Background())
if count == 0 {
core.JSONSuccess{
Status: core.Success,
Message: "Shortcode has not been found",
}.Respond(w, http.StatusNotFound)
return
}
if err != nil {
core.JSONError{
Status: core.Error,