ValidateDirectRoomBinding proves that an existing direct room row matches the deterministic identity for its workspace/channel-scoped peer pair.
(workspaceID string, channel string, directID string, peerA string, peerB string)
| 244 | // ValidateDirectRoomBinding proves that an existing direct room row matches |
| 245 | // the deterministic identity for its workspace/channel-scoped peer pair. |
| 246 | func ValidateDirectRoomBinding(workspaceID string, channel string, directID string, peerA string, peerB string) error { |
| 247 | trimmedDirectID := strings.TrimSpace(directID) |
| 248 | if err := ValidateConversationID(trimmedDirectID, validateDirectIDKey); err != nil { |
| 249 | return err |
| 250 | } |
| 251 | expectedID, _, _, err := DirectRoomIdentity(workspaceID, channel, peerA, peerB) |
| 252 | if err != nil { |
| 253 | return err |
| 254 | } |
| 255 | if trimmedDirectID != expectedID { |
| 256 | return fmt.Errorf( |
| 257 | "%w: direct_id=%q expected=%q", |
| 258 | ErrDirectRoomCollision, |
| 259 | trimmedDirectID, |
| 260 | expectedID, |
| 261 | ) |
| 262 | } |
| 263 | return nil |
| 264 | } |
| 265 | |
| 266 | // ValidateConversationRef reports whether a conversation reference identifies exactly one container. |
| 267 | func ValidateConversationRef(ref ConversationRef) error { |