- Replace "Room" with "Channel" in bridge-agnostic contexts throughout codebase - Update BridgeRoomID → BridgeChannelID in model structs and all references - Change error messages to use consistent "Channel" terminology for user-facing text - Update log keys: bridge_room_id → bridge_channel_id for consistency - Clean up kvstore constants file by removing unused functions and constants: - Removed BuildXMPPUserKey, BuildMattermostUserKey, BuildGhostUserKey - Removed BuildXMPPEventPostKey, BuildXMPPReactionKey functions - Removed unused constants: KeyPrefixXMPPUser, KeyPrefixMattermostUser, etc. - Keep only actively used BuildChannelMapKey and ExtractIdentifierFromChannelMapKey - Preserve XMPP-specific "Room" terminology in appropriate contexts (client methods, JIDs) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
88 lines
2.8 KiB
Go
88 lines
2.8 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// MessageDirection indicates the direction of message flow
|
|
type MessageDirection string
|
|
|
|
const (
|
|
DirectionIncoming MessageDirection = "incoming" // From external system to us
|
|
DirectionOutgoing MessageDirection = "outgoing" // From us to external system
|
|
)
|
|
|
|
// BridgeMessage represents a message that can be passed between any bridge types
|
|
type BridgeMessage struct {
|
|
// Source information
|
|
SourceBridge string // "xmpp", "mattermost", "slack", etc.
|
|
SourceChannelID string // Channel ID in source system
|
|
SourceUserID string // User ID in source system (JID, user ID, etc.)
|
|
SourceUserName string // Display name in source system
|
|
|
|
// Message content (standardized on Markdown)
|
|
Content string // Markdown formatted message content
|
|
MessageType string // "text", "image", "file", etc.
|
|
|
|
// Metadata
|
|
Timestamp time.Time // When message was received
|
|
MessageID string // Unique message ID from source
|
|
ThreadID string // Thread/reply ID (if applicable)
|
|
|
|
// Routing hints
|
|
TargetBridges []string // Which bridges should receive this
|
|
Metadata map[string]any // Bridge-specific metadata
|
|
}
|
|
|
|
// DirectionalMessage wraps a BridgeMessage with direction information
|
|
type DirectionalMessage struct {
|
|
*BridgeMessage
|
|
Direction MessageDirection
|
|
}
|
|
|
|
// ExternalUser represents a user from any bridge system
|
|
type ExternalUser struct {
|
|
BridgeType string // "xmpp", "slack", etc.
|
|
ExternalUserID string // JID, Slack user ID, etc.
|
|
DisplayName string // How to display this user
|
|
MattermostUserID string // Mapped Mattermost user (if exists)
|
|
}
|
|
|
|
// UserResolver handles user resolution for a specific bridge
|
|
type UserResolver interface {
|
|
// ResolveUser converts an external user ID to an ExternalUser
|
|
ResolveUser(externalUserID string) (*ExternalUser, error)
|
|
|
|
// FormatUserMention formats a user mention for Markdown content
|
|
FormatUserMention(user *ExternalUser) string
|
|
|
|
// GetDisplayName extracts display name from external user ID
|
|
GetDisplayName(externalUserID string) string
|
|
}
|
|
|
|
// MessageBus handles routing messages between bridges
|
|
type MessageBus interface {
|
|
// Subscribe returns a channel that receives messages for the specified bridge
|
|
Subscribe(bridgeName string) <-chan *DirectionalMessage
|
|
|
|
// Publish sends a message to the message bus for routing
|
|
Publish(msg *DirectionalMessage) error
|
|
|
|
// Start begins message routing
|
|
Start() error
|
|
|
|
// Stop ends message routing and cleans up resources
|
|
Stop() error
|
|
}
|
|
|
|
// MessageHandler processes incoming messages for a bridge
|
|
type MessageHandler interface {
|
|
// ProcessMessage handles an incoming message
|
|
ProcessMessage(msg *DirectionalMessage) error
|
|
|
|
// CanHandleMessage determines if this handler can process the message
|
|
CanHandleMessage(msg *BridgeMessage) bool
|
|
|
|
// GetSupportedMessageTypes returns the message types this handler supports
|
|
GetSupportedMessageTypes() []string
|
|
}
|