feat: refactor channel mapping with structured parameters and shared channel integration
- Add ChannelMappingRequest and ChannelMappingDeleteRequest structs with validation - Update BridgeManager interface to accept structured parameters instead of individual strings - Implement proper user ID and team ID propagation to shared channels - Add shared channel creation/deletion integration with Mattermost API - Update command handlers to provide user and team context - Enhance logging with comprehensive parameter tracking 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a5eb80817c
commit
1f45197aa8
5 changed files with 223 additions and 51 deletions
40
server/model/strings.go
Normal file
40
server/model/strings.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package model
|
||||
|
||||
import "strings"
|
||||
|
||||
// sanitizeShareName creates a valid ShareName matching the regex: ^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]*$
|
||||
func SanitizeShareName(name string) string {
|
||||
// Convert to lowercase and replace spaces with hyphens
|
||||
shareName := strings.ToLower(name)
|
||||
shareName = strings.ReplaceAll(shareName, " ", "-")
|
||||
|
||||
// Remove any characters that aren't lowercase letters, numbers, hyphens, or underscores
|
||||
var validShareName strings.Builder
|
||||
for _, r := range shareName {
|
||||
if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '-' || r == '_' {
|
||||
validShareName.WriteRune(r)
|
||||
}
|
||||
}
|
||||
|
||||
result := validShareName.String()
|
||||
if result == "" {
|
||||
return "matrixbridge" // fallback if no valid characters
|
||||
}
|
||||
|
||||
// Ensure it starts with alphanumeric
|
||||
for len(result) > 0 && (result[0] == '-' || result[0] == '_') {
|
||||
result = result[1:]
|
||||
}
|
||||
|
||||
// Ensure it ends with alphanumeric
|
||||
for len(result) > 0 && (result[len(result)-1] == '-' || result[len(result)-1] == '_') {
|
||||
result = result[:len(result)-1]
|
||||
}
|
||||
|
||||
// Final fallback check
|
||||
if result == "" {
|
||||
return "matrixbridge"
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue