Исправление дублирования чужих целей в wishlist и защита от редактирования
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m16s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m16s
This commit is contained in:
@@ -9498,6 +9498,14 @@ func (a *App) getWishlistItemsWithConditions(userID int, includeCompleted bool)
|
||||
DisplayOrder: int(displayOrder.Int64),
|
||||
}
|
||||
|
||||
// Заполняем UserID для условия
|
||||
if conditionUserID.Valid {
|
||||
conditionOwnerID := int(conditionUserID.Int64)
|
||||
condition.UserID = &conditionOwnerID
|
||||
} else {
|
||||
condition.UserID = &userID
|
||||
}
|
||||
|
||||
if taskConditionID.Valid {
|
||||
condition.Type = "task_completion"
|
||||
if taskName.Valid {
|
||||
@@ -9824,12 +9832,21 @@ func (a *App) saveWishlistConditions(
|
||||
}
|
||||
|
||||
// Определяем user_id для условия:
|
||||
// - Если условие имеет id и это условие существовало - используем его оригинальный user_id
|
||||
// - Если условие имеет id и это условие существовало - проверяем, принадлежит ли оно текущему пользователю
|
||||
// - Если условие принадлежит другому пользователю - пропускаем (не сохраняем)
|
||||
// - Если условие имеет id, но не существовало (например, было только что добавлено) - игнорируем
|
||||
// - Иначе - используем userID текущего пользователя
|
||||
conditionUserID := userID
|
||||
if condition.ID != nil {
|
||||
if originalUserID, exists := existingConditions[*condition.ID]; exists {
|
||||
// Если условие принадлежит другому пользователю - пропускаем (не сохраняем)
|
||||
if originalUserID != userID {
|
||||
continue
|
||||
}
|
||||
conditionUserID = originalUserID
|
||||
} else {
|
||||
// Условие имеет id, но не существует в базе - пропускаем (не сохраняем)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10258,6 +10275,9 @@ func (a *App) getWishlistItemHandler(w http.ResponseWriter, r *http.Request) {
|
||||
conditionOwnerID := itemOwnerID
|
||||
if conditionUserID.Valid {
|
||||
conditionOwnerID = int(conditionUserID.Int64)
|
||||
condition.UserID = &conditionOwnerID
|
||||
} else {
|
||||
condition.UserID = &itemOwnerID
|
||||
}
|
||||
|
||||
if taskConditionID.Valid {
|
||||
@@ -10575,6 +10595,9 @@ func (a *App) updateWishlistHandler(w http.ResponseWriter, r *http.Request) {
|
||||
conditionOwnerID := itemOwnerID
|
||||
if conditionUserID.Valid {
|
||||
conditionOwnerID = int(conditionUserID.Int64)
|
||||
condition.UserID = &conditionOwnerID
|
||||
} else {
|
||||
condition.UserID = &itemOwnerID
|
||||
}
|
||||
|
||||
if taskConditionID.Valid {
|
||||
@@ -12387,6 +12410,10 @@ func (a *App) getWishlistItemsByBoard(boardID int, userID int) ([]WishlistItem,
|
||||
conditionOwnerID := int(itemOwnerID.Int64)
|
||||
if conditionUserID.Valid {
|
||||
conditionOwnerID = int(conditionUserID.Int64)
|
||||
condition.UserID = &conditionOwnerID
|
||||
} else {
|
||||
itemOwnerIDVal := int(itemOwnerID.Int64)
|
||||
condition.UserID = &itemOwnerIDVal
|
||||
}
|
||||
|
||||
if taskConditionID.Valid {
|
||||
|
||||
Reference in New Issue
Block a user