2024-08-24 15:49:19 +00:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
2024-10-31 12:38:50 +00:00
|
|
|
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
|
|
|
"git.solsynth.dev/hypernet/passport/pkg/internal/database"
|
2024-08-24 15:49:19 +00:00
|
|
|
)
|
|
|
|
|
2024-10-30 16:17:53 +00:00
|
|
|
func GetBotCount(user models.Account) (int64, error) {
|
2024-08-24 15:49:19 +00:00
|
|
|
var count int64
|
2024-10-30 16:17:53 +00:00
|
|
|
if err := database.C.Where("automated_id = ?", user.ID).Count(&count).Error; err != nil {
|
2024-08-24 15:49:19 +00:00
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return count, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBot(user models.Account, bot models.Account) (models.Account, error) {
|
|
|
|
bot.AutomatedBy = &user
|
|
|
|
bot.AutomatedID = &user.ID
|
|
|
|
|
|
|
|
if err := database.C.Save(&bot).Error; err != nil {
|
|
|
|
return bot, err
|
|
|
|
}
|
|
|
|
return bot, nil
|
|
|
|
}
|