md formatting doesnt work yet

Started implementing owner feature

Add .gitattributes to enforce LF line endings

Temporary commit before merge

Updated owner management

Updated json and gitignore

Proceed with role management

Again, CI

Fix some lint errors

Implemented screening

Per-bot API keys implemented

Use getRoleByName func

Fix unused imports

Upgrade actions

rm unused function

Upgrade action

Fix unaddressed errors
This commit is contained in:
HugeFrog24
2024-10-20 17:17:21 +02:00
parent e5532df7f9
commit c8af457af1
18 changed files with 520 additions and 79 deletions

13
models.go Executable file → Normal file
View File

@@ -11,7 +11,7 @@ type BotModel struct {
Identifier string `gorm:"uniqueIndex"` // Renamed from ID to Identifier
Name string
Configs []ConfigModel `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"`
Users []User `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"` // Added foreign key
Users []User `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"` // Associated users
Messages []Message `gorm:"foreignKey:BotID;constraint:OnDelete:CASCADE"`
}
@@ -24,6 +24,7 @@ type ConfigModel struct {
TempBanDuration string `json:"temp_ban_duration"`
SystemPrompts string `json:"system_prompts"` // Consider JSON string or separate table
TelegramToken string `json:"telegram_token"`
Active bool `json:"active"`
}
type Message struct {
@@ -53,9 +54,15 @@ type Role struct {
type User struct {
gorm.Model
BotID uint `gorm:"index"` // Added foreign key to BotModel
TelegramID int64 `gorm:"uniqueIndex"` // Consider composite unique index if TelegramID is unique per Bot
BotID uint `gorm:"index"` // Foreign key to BotModel
TelegramID int64 `gorm:"uniqueIndex;not null"` // Unique per user
Username string
RoleID uint
Role Role `gorm:"foreignKey:RoleID"`
IsOwner bool `gorm:"default:false"` // Indicates if the user is the owner
}
// Compound unique index to ensure only one owner per bot
func (User) TableName() string {
return "users"
}