mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-06-10 04:10:26 +00:00
6895e369f6
- Remove standalone mode code: file-based stores, standalone gateway, heartbeat service, SQLite memory, standalone docker-compose - Rename docker-compose.managed.yml → docker-compose.postgres.yml - Clean up ~130 Go comments referencing "managed mode" qualifier - Simplify docker-compose.yml env vars (providers/channels via web UI) - Update .env.example to essential vars only (token + encryption key) - Add setup wizard UI (provider → agent → channel bootstrap flow) - Add logs.tail WebSocket handler for live log streaming - Add cursor-pointer to interactive UI components - Clean up config page (remove standalone-only sections) - Update README and docs for managed-only architecture
57 lines
2.0 KiB
Go
57 lines
2.0 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"strings"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ChannelInstanceData represents a channel instance in the database.
|
|
type ChannelInstanceData struct {
|
|
BaseModel
|
|
Name string `json:"name"`
|
|
DisplayName string `json:"display_name"`
|
|
ChannelType string `json:"channel_type"`
|
|
AgentID uuid.UUID `json:"agent_id"`
|
|
Credentials []byte `json:"-"` // encrypted, never serialized to API
|
|
Config json.RawMessage `json:"config"`
|
|
Enabled bool `json:"enabled"`
|
|
CreatedBy string `json:"created_by"`
|
|
}
|
|
|
|
// IsDefaultChannelInstance returns true if the instance name matches a default/seeded channel.
|
|
// Default instances use either the bare channel type ("telegram") or "{channelType}/default".
|
|
func IsDefaultChannelInstance(name string) bool {
|
|
if strings.HasSuffix(name, "/default") {
|
|
return true
|
|
}
|
|
// Legacy Telegram default uses bare name "telegram"
|
|
switch name {
|
|
case "telegram", "discord", "feishu", "zalo_oa", "whatsapp":
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// ChannelInstanceListOpts configures channel instance listing with optional pagination and filtering.
|
|
type ChannelInstanceListOpts struct {
|
|
Search string
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
// ChannelInstanceStore manages channel instance definitions.
|
|
type ChannelInstanceStore interface {
|
|
Create(ctx context.Context, inst *ChannelInstanceData) error
|
|
Get(ctx context.Context, id uuid.UUID) (*ChannelInstanceData, error)
|
|
GetByName(ctx context.Context, name string) (*ChannelInstanceData, error)
|
|
Update(ctx context.Context, id uuid.UUID, updates map[string]any) error
|
|
Delete(ctx context.Context, id uuid.UUID) error
|
|
ListEnabled(ctx context.Context) ([]ChannelInstanceData, error)
|
|
ListAll(ctx context.Context) ([]ChannelInstanceData, error)
|
|
ListPaged(ctx context.Context, opts ChannelInstanceListOpts) ([]ChannelInstanceData, error)
|
|
CountInstances(ctx context.Context, opts ChannelInstanceListOpts) (int, error)
|
|
}
|