Allow JSON-RPC to get text of QR code as well

Desktop does use this as it allows reading QR codes as text from the
clipboard as well as copying the QR text to the clipboard instead of
showing the QR code.
This commit is contained in:
Floris Bruynooghe
2023-03-01 11:27:21 +01:00
parent 0e06da22df
commit 5762fbb9a7

View File

@@ -1376,7 +1376,19 @@ impl CommandApi {
res
}
/// Returns the QR code for the running [`CommandApi::provide_backup`].
/// Returns the text of the QR code for the running [`CommandApi::provide_backup`].
///
/// This QR code text can be used in [`CommandApi::get_backup`] on a second device to
/// retrieve the backup and setup this second device.
async fn get_backup_qr(&self, account_id: u32) -> Result<String> {
let ctx = self.get_context(account_id).await?;
let qr = ctx
.backup_export_qr()
.ok_or(anyhow!("no backup being exported"))?;
qr::format_backup(&qr)
}
/// Returns the rendered QR code for the running [`CommandApi::provide_backup`].
///
/// This QR code can be used in [`CommandApi::get_backup`] on a second device to
/// retrieve the backup and setup this second device.