Skip to main content

validate_one_app_data_update

Function validate_one_app_data_update 

Source
pub fn validate_one_app_data_update(
    component_id: ComponentId,
    operation: &AppDataUpdateOperation,
    actor: ActorAuthority,
    proposer_inbox_id: &str,
    registry: &ComponentRegistry,
    openmls_group: &MlsGroup,
    dm_members: Option<&DmMembers<String>>,
) -> Result<(), CommitRuleError>
Expand description

Validate a single AppDataUpdate (component_id + operation) against registry on behalf of actor.

Shared core for both validator entry points: validate_proposal in xmtp_mls (standalone proposal-by-reference messages) and validate_app_data_update_proposals_in_commit (proposals inside commits, inline or referenced). Both paths must enforce identical permission checks; lifting the loop here keeps them in lockstep so a future change can’t drift the two implementations apart.

Reads the pre-commit stored bytes for component_id from the group’s AppData dictionary and threads them into the expansion step so RemoveByHash mutations can be resolved back to the concrete inbox id being removed. If the component has no prior entry (first write), read_from_app_data_dict returns None, which [expand_app_data_update_to_changes] treats as an empty prior set — Insert / Remove deltas expand normally, and any RemoveByHash surfaces value: None (the CRDT apply step later rejects with KeyNotFound). This matches the Bytes component case where a first-time Update has no prior value to diff against.

Returns Err(InsufficientPermissions) on the first failure (expand, per-element check, or field bound) so the caller can reject the wider message wholesale.