Skip to main content

localized_update

Function localized_update 

Source
pub fn localized_update<O: JmapObject>(
    old: &Map<String, Value>,
    new: &mut Map<String, Value>,
    patch: &PatchObject,
    max_localizations: Option<usize>,
) -> Result<bool, Box<SetError>>
Expand description

The draft-atwood-jmap-updates-00 §4.1 rules that need the patched object, for a backend’s update_object of a type with JmapObject::LOCALIZABLE properties.

old is the stored object and new the result of applying patch to it (for example with apply_patch_object), both serialized. It checks locale and localizations in new (check_localizations, so no key may equal the new locale), applies max_localizations (I18nInfo::max_localizations), folds tags to canonical case, and then drops translations made stale by a changed base value (prune_stale_localizations). Run it inside the same atomic update, before validating and writing new.

Pruning applies to every client, including those that do not use the capability: that is the case §4.1 is for.

Returns true when pruning removed anything. The backend MUST then return the updated object (Ok(Some(_))) from update_object, so that the handler returns localizations in updated to clients that use the capability (§4.1, RFC 8620 §5.3).

§Errors

An invalidProperties SetError naming locale or localizations; the backend returns it as the update’s SetError.