Procházet zdrojové kódy

Merge pull request #2588 from PowerfulBart/fix/auto-group-task-logging

fix(task): 修复使用 auto 分组时 Task Relay 不记录日志和不扣费的问题
Xyfacai před 2 měsíci
rodič
revize
022fbcee04
1 změnil soubory, kde provedl 8 přidání a 0 odebrání
  1. 8 0
      relay/relay_task.go

+ 8 - 0
relay/relay_task.go

@@ -150,6 +150,14 @@ func RelayTaskSubmit(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto.
 		}
 	}
 
+	// 处理 auto 分组:从 context 获取实际选中的分组
+	// 当使用 auto 分组时,Distribute 中间件会将实际选中的分组存储在 ContextKeyAutoGroup 中
+	if autoGroup, exists := common.GetContextKey(c, constant.ContextKeyAutoGroup); exists {
+		if groupStr, ok := autoGroup.(string); ok && groupStr != "" {
+			info.UsingGroup = groupStr
+		}
+	}
+
 	// 预扣
 	groupRatio := ratio_setting.GetGroupRatio(info.UsingGroup)
 	var ratio float64