Skip to main content

copy_auth_to_dc

Function copy_auth_to_dc 

Source
pub async fn copy_auth_to_dc<F, Fut>(
    home_dc_id: i32,
    target_dc_id: i32,
    tracker: &DcAuthTracker,
    invoke_fn: F,
    invoke_on_dc_fn: impl Fn(i32, ImportAuthorization) -> Fut,
) -> Result<(), InvocationError>
Expand description

Export the home-DC authorization and import it on target_dc_id.

This is a no-op if:

  • target_dc_id == home_dc_id (already home)
  • auth was already copied in this session (tracked by DcAuthTracker)

Ported from Client::copy_auth_to_dc.

§Where to call this

Call from invoke_on_dc(target_dc_id, req) before sending the request, so that file downloads on foreign DCs work without manual setup:

pub async fn invoke_on_dc<R: RemoteCall>(
&self,
dc_id: i32,
req: &R,
) -> Result<R::Return, InvocationError> {
self.copy_auth_to_dc(dc_id).await?;
// ... then call the DC-specific connection
}