fix: refresh codex credentials for auto-disabled channels (#4324)
This commit is contained in:
@@ -28,6 +28,10 @@ var (
|
||||
codexCredentialRefreshRunning atomic.Bool
|
||||
)
|
||||
|
||||
func shouldAutoRefreshCodexChannelStatus(status int) bool {
|
||||
return status == common.ChannelStatusEnabled || status == common.ChannelStatusAutoDisabled
|
||||
}
|
||||
|
||||
func StartCodexCredentialAutoRefreshTask() {
|
||||
codexCredentialRefreshOnce.Do(func() {
|
||||
if !common.IsMasterNode {
|
||||
@@ -65,7 +69,11 @@ func runCodexCredentialAutoRefreshOnce() {
|
||||
var channels []*model.Channel
|
||||
err := model.DB.
|
||||
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").
|
||||
Limit(codexCredentialRefreshBatchSize).
|
||||
Offset(offset).
|
||||
|
||||
Reference in New Issue
Block a user