Make things work. Next: Tests, make sure that primary transport is published

This commit is contained in:
Hocuri
2026-03-16 14:41:35 +01:00
parent acffad37ef
commit 57529407e3
6 changed files with 85 additions and 27 deletions

View File

@@ -528,6 +528,7 @@ impl CommandApi {
/// from a server encoded in a QR code.
/// - [Self::list_transports()] to get a list of all configured transports.
/// - [Self::delete_transport()] to remove a transport.
/// - [Self::set_transport_unpublished()] to set whether contacts see this transport.
async fn add_or_update_transport(
&self,
account_id: u32,
@@ -571,8 +572,16 @@ impl CommandApi {
ctx.delete_transport(&addr).await
}
// TODO not sure if that's a good API design,
// but I'm also not sure about an alternative - Adding to EnteredLoginParam?
/// Change whether the transport is unpublished.
///
/// Unpublished transports are not advertised to contacts,
/// and self-sent messages are not sent there,
/// so that we don't cause extra messages to the corresponding inbox,
/// but can still receive messages from contacts who don't know the new relay addresses yet.
///
/// The default is true, but when updating,
/// existing secondary transports are set to unpublished,
/// so that an existing transport address doesn't suddenly get spammed with a lot of messages.
async fn set_transport_unpublished(
&self,
account_id: u32,
@@ -580,19 +589,14 @@ impl CommandApi {
unpublished: bool,
) -> Result<()> {
let ctx = self.get_context(account_id).await?;
ctx.set_transport_unpublished(addr, unpublished).await
ctx.set_transport_unpublished(&addr, unpublished).await
}
// TODO not sure if that's a good API design,
// but I'm also not sure about an alternative - Adding to EnteredLoginParam?
async fn get_transport_unpublished(
&self,
account_id: u32,
addr: String,
unpublished: bool,
) -> Result<()> {
/// Check whether the transport is unpublished.
/// See [`Self::set_transport_unpublished`] / `setTransportUnpublished` for details.
async fn is_transport_unpublished(&self, account_id: u32, addr: String) -> Result<bool> {
let ctx = self.get_context(account_id).await?;
ctx.get_transport_unpublished(addr, unpublished).await
ctx.is_transport_unpublished(&addr).await
}
/// Signal an ongoing process to stop.