Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"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`,
|
`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 {
|
for _, q := range cleanupQueries {
|
||||||
if _, err := tx.Exec(q, userID); err != nil {
|
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)
|
log.Printf("❌ [UserDetail] cleanup failed user_id=%d err=%v query=%s", userID, err, q)
|
||||||
http.Error(w, "Kullanici baglantilari silinemedi", http.StatusInternalServerError)
|
http.Error(w, "Kullanici baglantilari silinemedi", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user