fix: correct indentation and octal literals for linter
Fix gci errors caused by lost indentation when removing localFiles lines, and use 0o700/0o600 octal syntax for gofumpt compliance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a56d97f233
commit
81df10b0b1
4 changed files with 11 additions and 11 deletions
|
|
@ -317,19 +317,19 @@ func (c *LINEChannel) processEvent(event lineEvent) {
|
||||||
case "image":
|
case "image":
|
||||||
localPath := c.downloadContent(msg.ID, "image.jpg")
|
localPath := c.downloadContent(msg.ID, "image.jpg")
|
||||||
if localPath != "" {
|
if localPath != "" {
|
||||||
mediaPaths = append(mediaPaths, localPath)
|
mediaPaths = append(mediaPaths, localPath)
|
||||||
content = "[image]"
|
content = "[image]"
|
||||||
}
|
}
|
||||||
case "audio":
|
case "audio":
|
||||||
localPath := c.downloadContent(msg.ID, "audio.m4a")
|
localPath := c.downloadContent(msg.ID, "audio.m4a")
|
||||||
if localPath != "" {
|
if localPath != "" {
|
||||||
mediaPaths = append(mediaPaths, localPath)
|
mediaPaths = append(mediaPaths, localPath)
|
||||||
content = "[audio]"
|
content = "[audio]"
|
||||||
}
|
}
|
||||||
case "video":
|
case "video":
|
||||||
localPath := c.downloadContent(msg.ID, "video.mp4")
|
localPath := c.downloadContent(msg.ID, "video.mp4")
|
||||||
if localPath != "" {
|
if localPath != "" {
|
||||||
mediaPaths = append(mediaPaths, localPath)
|
mediaPaths = append(mediaPaths, localPath)
|
||||||
content = "[video]"
|
content = "[video]"
|
||||||
}
|
}
|
||||||
case "file":
|
case "file":
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ func (c *SlackChannel) handleMessageEvent(ev *slackevents.MessageEvent) {
|
||||||
if localPath == "" {
|
if localPath == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
mediaPaths = append(mediaPaths, localPath)
|
mediaPaths = append(mediaPaths, localPath)
|
||||||
|
|
||||||
if utils.IsAudioFile(file.Name, file.Mimetype) && c.transcriber != nil && c.transcriber.IsAvailable() {
|
if utils.IsAudioFile(file.Name, file.Mimetype) && c.transcriber != nil && c.transcriber.IsAvailable() {
|
||||||
ctx, cancel := context.WithTimeout(c.ctx, 30*time.Second)
|
ctx, cancel := context.WithTimeout(c.ctx, 30*time.Second)
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ func (c *TelegramChannel) handleMessage(ctx context.Context, message *telego.Mes
|
||||||
photo := message.Photo[len(message.Photo)-1]
|
photo := message.Photo[len(message.Photo)-1]
|
||||||
photoPath := c.downloadPhoto(ctx, photo.FileID)
|
photoPath := c.downloadPhoto(ctx, photo.FileID)
|
||||||
if photoPath != "" {
|
if photoPath != "" {
|
||||||
mediaPaths = append(mediaPaths, photoPath)
|
mediaPaths = append(mediaPaths, photoPath)
|
||||||
if content != "" {
|
if content != "" {
|
||||||
content += "\n"
|
content += "\n"
|
||||||
}
|
}
|
||||||
|
|
@ -248,7 +248,7 @@ func (c *TelegramChannel) handleMessage(ctx context.Context, message *telego.Mes
|
||||||
if message.Voice != nil {
|
if message.Voice != nil {
|
||||||
voicePath := c.downloadFile(ctx, message.Voice.FileID, ".ogg")
|
voicePath := c.downloadFile(ctx, message.Voice.FileID, ".ogg")
|
||||||
if voicePath != "" {
|
if voicePath != "" {
|
||||||
mediaPaths = append(mediaPaths, voicePath)
|
mediaPaths = append(mediaPaths, voicePath)
|
||||||
|
|
||||||
transcribedText := ""
|
transcribedText := ""
|
||||||
if c.transcriber != nil && c.transcriber.IsAvailable() {
|
if c.transcriber != nil && c.transcriber.IsAvailable() {
|
||||||
|
|
@ -282,7 +282,7 @@ func (c *TelegramChannel) handleMessage(ctx context.Context, message *telego.Mes
|
||||||
if message.Audio != nil {
|
if message.Audio != nil {
|
||||||
audioPath := c.downloadFile(ctx, message.Audio.FileID, ".mp3")
|
audioPath := c.downloadFile(ctx, message.Audio.FileID, ".mp3")
|
||||||
if audioPath != "" {
|
if audioPath != "" {
|
||||||
mediaPaths = append(mediaPaths, audioPath)
|
mediaPaths = append(mediaPaths, audioPath)
|
||||||
if content != "" {
|
if content != "" {
|
||||||
content += "\n"
|
content += "\n"
|
||||||
}
|
}
|
||||||
|
|
@ -293,7 +293,7 @@ func (c *TelegramChannel) handleMessage(ctx context.Context, message *telego.Mes
|
||||||
if message.Document != nil {
|
if message.Document != nil {
|
||||||
docPath := c.downloadFile(ctx, message.Document.FileID, "")
|
docPath := c.downloadFile(ctx, message.Document.FileID, "")
|
||||||
if docPath != "" {
|
if docPath != "" {
|
||||||
mediaPaths = append(mediaPaths, docPath)
|
mediaPaths = append(mediaPaths, docPath)
|
||||||
if content != "" {
|
if content != "" {
|
||||||
content += "\n"
|
content += "\n"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ import (
|
||||||
func TestMediaCleanerRemovesOldFiles(t *testing.T) {
|
func TestMediaCleanerRemovesOldFiles(t *testing.T) {
|
||||||
// Setup: create a temp media directory with old and new files
|
// Setup: create a temp media directory with old and new files
|
||||||
mediaDir := filepath.Join(os.TempDir(), MediaDir)
|
mediaDir := filepath.Join(os.TempDir(), MediaDir)
|
||||||
if err := os.MkdirAll(mediaDir, 0700); err != nil {
|
if err := os.MkdirAll(mediaDir, 0o700); err != nil {
|
||||||
t.Fatalf("failed to create media dir: %v", err)
|
t.Fatalf("failed to create media dir: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an "old" file and backdate its modification time
|
// Create an "old" file and backdate its modification time
|
||||||
oldFile := filepath.Join(mediaDir, "test_old_file.jpg")
|
oldFile := filepath.Join(mediaDir, "test_old_file.jpg")
|
||||||
if err := os.WriteFile(oldFile, []byte("old"), 0600); err != nil {
|
if err := os.WriteFile(oldFile, []byte("old"), 0o600); err != nil {
|
||||||
t.Fatalf("failed to create old file: %v", err)
|
t.Fatalf("failed to create old file: %v", err)
|
||||||
}
|
}
|
||||||
oldTime := time.Now().Add(-1 * time.Hour)
|
oldTime := time.Now().Add(-1 * time.Hour)
|
||||||
|
|
@ -26,7 +26,7 @@ func TestMediaCleanerRemovesOldFiles(t *testing.T) {
|
||||||
|
|
||||||
// Create a "new" file (just created, so modtime is now)
|
// Create a "new" file (just created, so modtime is now)
|
||||||
newFile := filepath.Join(mediaDir, "test_new_file.jpg")
|
newFile := filepath.Join(mediaDir, "test_new_file.jpg")
|
||||||
if err := os.WriteFile(newFile, []byte("new"), 0600); err != nil {
|
if err := os.WriteFile(newFile, []byte("new"), 0o600); err != nil {
|
||||||
t.Fatalf("failed to create new file: %v", err)
|
t.Fatalf("failed to create new file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue