mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-11 18:59:40 +08:00
feat: parse media group, wip
This commit is contained in:
13
dao/file.go
13
dao/file.go
@@ -9,6 +9,19 @@ func SaveReceivedFile(receivedFile *ReceivedFile) (*ReceivedFile, error) {
|
||||
return receivedFile, db.Error
|
||||
}
|
||||
|
||||
func BatchSaveReceivedFiles(receivedFiles []*ReceivedFile) error {
|
||||
if len(receivedFiles) == 0 {
|
||||
return nil
|
||||
}
|
||||
for _, file := range receivedFiles {
|
||||
record, err := GetReceivedFileByChatAndMessageID(file.ChatID, file.MessageID)
|
||||
if err == nil {
|
||||
file.ID = record.ID
|
||||
}
|
||||
}
|
||||
return db.Save(receivedFiles).Error
|
||||
}
|
||||
|
||||
func GetReceivedFileByChatAndMessageID(chatID int64, messageID int) (*ReceivedFile, error) {
|
||||
var receivedFile ReceivedFile
|
||||
err := db.Where("chat_id = ? AND message_id = ?", chatID, messageID).First(&receivedFile).Error
|
||||
|
||||
Reference in New Issue
Block a user