Skip to main content

resolve_user_id

Function resolve_user_id 

Source
pub fn resolve_user_id(
    messages: &[Message],
    provided: Option<&str>,
) -> Option<String>
Expand description

Resolve the acting user id for a batch of messages, mirroring ScopedContentProcessor._map_messages’s resolution order (minus the bearer-token-JWT fallback this port doesn’t perform — see the crate docs):

  1. The first message whose additional_properties["user_id"] is a valid GUID wins outright.
  2. Otherwise, the first message whose author_name is a valid GUID is remembered as a fallback candidate (scanning continues, in case a later message has an explicit user_id).
  3. If neither produced a value, provided is used if it is itself a valid GUID.
  4. Otherwise None — callers must treat this as “cannot evaluate; do not block” (see ContentProcessor::evaluate), matching Python’s fail-open behavior when no resolvable user id exists.