Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-02-20 16:06:40 +03:00
parent 47ca23f970
commit a93630df7a

View File

@@ -19,6 +19,7 @@ import (
"time"
"github.com/gorilla/mux"
"github.com/lib/pq"
)
// ======================================================
@@ -373,8 +374,22 @@ func handleUserDelete(db *sql.DB, w http.ResponseWriter, r *http.Request, userID
`DELETE FROM dfusr_nebim_user WHERE dfusr_id = $1`,
}
isUndefinedTable := func(err error) bool {
if err == nil {
return false
}
if pe, ok := err.(*pq.Error); ok {
return pe.Code == "42P01" // undefined_table
}
return false
}
for _, q := range cleanupQueries {
if _, err := tx.Exec(q, userID); err != nil {
if isUndefinedTable(err) {
log.Printf("⚠️ [UserDetail] cleanup skipped (table missing) user_id=%d query=%s", userID, q)
continue
}
log.Printf("❌ [UserDetail] cleanup failed user_id=%d err=%v query=%s", userID, err, q)
http.Error(w, "Kullanici baglantilari silinemedi", http.StatusInternalServerError)
return