mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-07-06 22:51:21 +08:00
feat: add custom file name support for saved files and improve error messages
This commit is contained in:
12
dao/file.go
12
dao/file.go
@@ -2,8 +2,12 @@ package dao
|
||||
|
||||
import "github.com/krau/SaveAny-Bot/types"
|
||||
|
||||
func AddReceivedFile(receivedFile *types.ReceivedFile) error {
|
||||
return db.Create(receivedFile).Error
|
||||
func SaveReceivedFile(receivedFile *types.ReceivedFile) error {
|
||||
record, err := GetReceivedFileByChatAndMessageID(receivedFile.ChatID, receivedFile.MessageID)
|
||||
if err == nil {
|
||||
receivedFile.ID = record.ID
|
||||
}
|
||||
return db.Save(receivedFile).Error
|
||||
}
|
||||
|
||||
func GetReceivedFileByChatAndMessageID(chatID int64, messageID int) (*types.ReceivedFile, error) {
|
||||
@@ -15,10 +19,6 @@ func GetReceivedFileByChatAndMessageID(chatID int64, messageID int) (*types.Rece
|
||||
return &receivedFile, nil
|
||||
}
|
||||
|
||||
func UpdateReceivedFile(receivedFile *types.ReceivedFile) error {
|
||||
return db.Save(receivedFile).Error
|
||||
}
|
||||
|
||||
func DeleteReceivedFile(receivedFile *types.ReceivedFile) error {
|
||||
return db.Delete(receivedFile).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user