mattermost-plugin-bridge-xmpp/server/store/kvstore/constants.go
Felipe Martin 4c6aeb2392
refactor: standardize bridge-agnostic terminology and remove unused kvstore functions
- 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>
2025-08-05 12:33:19 +02:00

31 lines
No EOL
956 B
Go

package kvstore
import "strings"
// KV Store key prefixes and constants
// This file centralizes all KV store key patterns used throughout the plugin
// to ensure consistency and avoid key conflicts.
const (
// KeyPrefixChannelMap is the prefix for bridge-agnostic channel mappings
KeyPrefixChannelMap = "channel_map_"
)
// Helper functions for building KV store keys
// BuildChannelMapKey creates a bridge-agnostic key for channel mappings
func BuildChannelMapKey(bridgeName, identifier string) string {
return KeyPrefixChannelMap + bridgeName + "_" + identifier
}
// ExtractIdentifierFromChannelMapKey extracts the identifier from a bridge-agnostic channel map key
func ExtractIdentifierFromChannelMapKey(key, bridgeName string) string {
expectedPrefix := KeyPrefixChannelMap + bridgeName + "_"
if len(key) <= len(expectedPrefix) {
return ""
}
if !strings.HasPrefix(key, expectedPrefix) {
return ""
}
return key[len(expectedPrefix):]
}