Commit e729b221 by Seefs Committed by GitHub

fix: refresh codex credentials for auto-disabled channels (#4324)

parent 5f67d2a2
...@@ -28,6 +28,10 @@ var ( ...@@ -28,6 +28,10 @@ var (
codexCredentialRefreshRunning atomic.Bool codexCredentialRefreshRunning atomic.Bool
) )
func shouldAutoRefreshCodexChannelStatus(status int) bool {
return status == common.ChannelStatusEnabled || status == common.ChannelStatusAutoDisabled
}
func StartCodexCredentialAutoRefreshTask() { func StartCodexCredentialAutoRefreshTask() {
codexCredentialRefreshOnce.Do(func() { codexCredentialRefreshOnce.Do(func() {
if !common.IsMasterNode { if !common.IsMasterNode {
...@@ -65,7 +69,11 @@ func runCodexCredentialAutoRefreshOnce() { ...@@ -65,7 +69,11 @@ func runCodexCredentialAutoRefreshOnce() {
var channels []*model.Channel var channels []*model.Channel
err := model.DB. err := model.DB.
Select("id", "name", "key", "status", "channel_info"). Select("id", "name", "key", "status", "channel_info").
Where("type = ? AND status = 1", constant.ChannelTypeCodex). Where("type = ? AND (status = ? OR status = ?)",
constant.ChannelTypeCodex,
common.ChannelStatusEnabled,
common.ChannelStatusAutoDisabled,
).
Order("id asc"). Order("id asc").
Limit(codexCredentialRefreshBatchSize). Limit(codexCredentialRefreshBatchSize).
Offset(offset). Offset(offset).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment