forked from molecule-ai/molecule-core
Renames: - platform/ → workspace-server/ (Go module path stays as "platform" for external dep compat — will update after plugin module republish) - workspace-template/ → workspace/ Removed (moved to separate repos or deleted): - PLAN.md — internal roadmap (move to private project board) - HANDOFF.md, AGENTS.md — one-time internal session docs - .claude/ — gitignored entirely (local agent config) - infra/cloudflare-worker/ → Molecule-AI/molecule-tenant-proxy - org-templates/molecule-dev/ → standalone template repo - .mcp-eval/ → molecule-mcp-server repo - test-results/ — ephemeral, gitignored Security scrubbing: - Cloudflare account/zone/KV IDs → placeholders - Real EC2 IPs → <EC2_IP> in all docs - CF token prefix, Neon project ID, Fly app names → redacted - Langfuse dev credentials → parameterized - Personal runner username/machine name → generic Community files: - CONTRIBUTING.md — build, test, branch conventions - CODE_OF_CONDUCT.md — Contributor Covenant 2.1 All Dockerfiles, CI workflows, docker-compose, railway.toml, render.yaml, README, CLAUDE.md updated for new directory names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
56 lines
2.1 KiB
Go
56 lines
2.1 KiB
Go
// Package channels provides a pluggable adapter system for social channel
|
|
// integrations (Telegram, Slack, Discord, etc.). Each platform implements
|
|
// the ChannelAdapter interface and registers itself in the adapter registry.
|
|
package channels
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// ChannelAdapter is the interface every social channel must implement.
|
|
type ChannelAdapter interface {
|
|
// Type returns the channel type identifier (e.g. "telegram", "slack").
|
|
Type() string
|
|
|
|
// DisplayName returns the human-readable name (e.g. "Telegram").
|
|
DisplayName() string
|
|
|
|
// ValidateConfig checks that channel_config JSONB has required fields.
|
|
ValidateConfig(config map[string]interface{}) error
|
|
|
|
// SendMessage sends a text message to the social platform.
|
|
SendMessage(ctx context.Context, config map[string]interface{}, chatID string, text string) error
|
|
|
|
// ParseWebhook extracts message info from an incoming webhook request.
|
|
ParseWebhook(c *gin.Context, config map[string]interface{}) (*InboundMessage, error)
|
|
|
|
// StartPolling begins long-polling for platforms that support it.
|
|
// Returns nil immediately if the platform only supports webhooks.
|
|
StartPolling(ctx context.Context, config map[string]interface{}, onMessage MessageHandler) error
|
|
}
|
|
|
|
// InboundMessage is the standardized message from any social platform.
|
|
type InboundMessage struct {
|
|
ChatID string // Platform-specific chat/channel ID
|
|
UserID string // Platform-specific user ID
|
|
Username string // Human-readable username
|
|
Text string // Message text
|
|
MessageID string // Platform-specific message ID (for threading)
|
|
Metadata map[string]string // Extra platform-specific data
|
|
}
|
|
|
|
// MessageHandler is called by polling adapters when a message arrives.
|
|
type MessageHandler func(ctx context.Context, channelID string, msg *InboundMessage) error
|
|
|
|
// ChannelRow represents a row from the workspace_channels table.
|
|
type ChannelRow struct {
|
|
ID string
|
|
WorkspaceID string
|
|
ChannelType string
|
|
Config map[string]interface{}
|
|
Enabled bool
|
|
AllowedUsers []string
|
|
}
|