2025-02-28 01:25:45 -08:00
|
|
|
// internal/models/bot.go
|
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Bot represents a Nostr posting bot
|
|
|
|
type Bot struct {
|
|
|
|
ID int64 `db:"id" json:"id"`
|
|
|
|
Pubkey string `db:"pubkey" json:"pubkey"`
|
2025-03-01 22:53:36 -08:00
|
|
|
EncryptedPrivkey string `db:"encrypted_privkey" json:"encrypted_privkey,omitempty"`
|
2025-02-28 01:25:45 -08:00
|
|
|
Name string `db:"name" json:"name"`
|
|
|
|
DisplayName string `db:"display_name" json:"display_name"`
|
|
|
|
Bio string `db:"bio" json:"bio"`
|
|
|
|
Nip05 string `db:"nip05" json:"nip05"`
|
|
|
|
ZapAddress string `db:"zap_address" json:"zap_address"`
|
|
|
|
ProfilePicture string `db:"profile_picture" json:"profile_picture"`
|
|
|
|
Banner string `db:"banner" json:"banner"`
|
|
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
|
|
OwnerPubkey string `db:"owner_pubkey" json:"owner_pubkey"`
|
|
|
|
|
|
|
|
// The following are not stored in the database
|
|
|
|
PostConfig *PostConfig `json:"post_config,omitempty"`
|
|
|
|
MediaConfig *MediaConfig `json:"media_config,omitempty"`
|
|
|
|
Relays []*Relay `json:"relays,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// PostConfig represents the posting configuration for a bot
|
|
|
|
type PostConfig struct {
|
|
|
|
ID int64 `db:"id" json:"id"`
|
|
|
|
BotID int64 `db:"bot_id" json:"-"`
|
|
|
|
Hashtags string `db:"hashtags" json:"hashtags"` // JSON array stored as string
|
|
|
|
IntervalMinutes int `db:"interval_minutes" json:"interval_minutes"`
|
|
|
|
PostTemplate string `db:"post_template" json:"post_template"`
|
|
|
|
Enabled bool `db:"enabled" json:"enabled"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// MediaConfig represents the media upload configuration for a bot
|
|
|
|
type MediaConfig struct {
|
|
|
|
ID int64 `db:"id" json:"id"`
|
|
|
|
BotID int64 `db:"bot_id" json:"-"`
|
|
|
|
PrimaryService string `db:"primary_service" json:"primary_service"` // "nip94" or "blossom"
|
|
|
|
FallbackService string `db:"fallback_service" json:"fallback_service"`
|
|
|
|
Nip94ServerURL string `db:"nip94_server_url" json:"nip94_server_url"`
|
|
|
|
BlossomServerURL string `db:"blossom_server_url" json:"blossom_server_url"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Relay represents a Nostr relay configuration
|
|
|
|
type Relay struct {
|
|
|
|
ID int64 `db:"id" json:"id"`
|
|
|
|
BotID int64 `db:"bot_id" json:"-"`
|
|
|
|
URL string `db:"url" json:"url"`
|
|
|
|
Read bool `db:"read" json:"read"`
|
|
|
|
Write bool `db:"write" json:"write"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Post represents a post made by the bot
|
|
|
|
type Post struct {
|
|
|
|
ID int64 `db:"id" json:"id"`
|
|
|
|
BotID int64 `db:"bot_id" json:"bot_id"`
|
|
|
|
ContentFilename string `db:"content_filename" json:"content_filename"`
|
|
|
|
MediaURL string `db:"media_url" json:"media_url"`
|
|
|
|
EventID string `db:"event_id" json:"event_id"`
|
|
|
|
Status string `db:"status" json:"status"` // "pending", "posted", "failed"
|
|
|
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
|
|
|
Error string `db:"error" json:"error,omitempty"`
|
|
|
|
}
|