Skip to content

Commit 21cb42e

Browse files
committed
fix: refresh token
1 parent 4a8cd27 commit 21cb42e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backend/internal/service/rag_service.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,16 @@ func (m *MainServiceManager) SendNotifications(body dto.WebhookBody, comments st
422422

423423
// 发送GitLab评论
424424
apiURL := data.GitlabInfo.Config.API
425+
gitlabToken := data.GitlabToken
426+
425427
if apiURL == "" {
426428
fmt.Printf("警告: GitLab API URL 为空,尝试从缓存重新获取\n")
427429
// 尝试从缓存重新获取
428430
gitlabCache := cache.GetGitlabCache()
429-
_, gitlabInfo, ok := cache.FindTokenByProjectID(fmt.Sprintf("%d", body.Project.ID), gitlabCache)
431+
token, gitlabInfo, ok := cache.FindTokenByProjectID(fmt.Sprintf("%d", body.Project.ID), gitlabCache)
430432
if ok && gitlabInfo.Config.API != "" {
431433
apiURL = gitlabInfo.Config.API
434+
gitlabToken = token // 同时更新 token
432435
fmt.Printf("从缓存重新获取到 API URL: %s\n", apiURL)
433436
} else {
434437
fmt.Printf("错误: 无法获取有效的 GitLab API URL\n")
@@ -438,7 +441,7 @@ func (m *MainServiceManager) SendNotifications(body dto.WebhookBody, comments st
438441

439442
err := notificationService.SendEnhancedNotification(
440443
apiURL,
441-
data.GitlabToken,
444+
gitlabToken, // 使用更新后的 token
442445
body.Project.ID,
443446
body.ObjectAttributes.IID,
444447
comments,

0 commit comments

Comments
 (0)