change(location_sharing): make the asset type non-optional as per original MSC instructions

- https://github.com/matrix-org/matrix-spec-proposals/blob/matthew/location/proposals/3488-location.md
- `If m.asset is missing from the location's content the client should render it as m.self as that will be the most common use case. Otherwise, if it's not missing but the type is invalid or unknown the client should attempt to render it as a generic location. Clients should be able to distinguish between m.self and explicit assets for this feature to be correctly implemented as interpreting everything as m.self is unwanted.`
- this aligns the behavior with the newly introduced live location asset type handling
This commit is contained in:
Stefan Ceriu
2026-03-10 12:04:36 +02:00
committed by Stefan Ceriu
parent 4ec9124ce1
commit 6b414b7791

View File

@@ -472,11 +472,7 @@ impl TryFrom<RumaMessageType> for MessageType {
geo_uri: c.geo_uri,
description,
zoom_level: zoom_level.and_then(|z| z.get().try_into().ok()),
asset: c.asset.and_then(|a| match a.type_ {
RumaAssetType::Self_ => Some(AssetType::Sender),
RumaAssetType::Pin => Some(AssetType::Pin),
_ => None,
}),
asset: c.asset.map(|a| a.type_).into(),
},
}
}
@@ -927,7 +923,7 @@ pub struct LocationContent {
pub geo_uri: String,
pub description: Option<String>,
pub zoom_level: Option<u8>,
pub asset: Option<AssetType>,
pub asset: AssetType,
}
#[derive(Clone, uniffi::Enum)]
@@ -957,6 +953,15 @@ impl From<RumaAssetType> for AssetType {
}
}
impl From<Option<RumaAssetType>> for AssetType {
fn from(value: Option<RumaAssetType>) -> Self {
match value {
None => Self::Sender,
Some(asset_type) => asset_type.into(),
}
}
}
#[derive(Clone, uniffi::Record)]
pub struct FormattedBody {
pub format: MessageFormat,