MCPcopy Create free account
hub / github.com/compozy/agh / ValidateDirectRoomBinding

Function ValidateDirectRoomBinding

internal/network/validate.go:246–264  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

244// ValidateDirectRoomBinding proves that an existing direct room row matches
245// the deterministic identity for its workspace/channel-scoped peer pair.
246func 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.
267func ValidateConversationRef(ref ConversationRef) error {

Calls 2

ValidateConversationIDFunction · 0.85
DirectRoomIdentityFunction · 0.85