[fractal/fractal-next] verification: Check if a camera is available



commit 9c433d3caa8e10519e86be829c39828281eabdae
Author: Julian Sparber <julian sparber net>
Date:   Wed Feb 2 17:16:50 2022 +0100

    verification: Check if a camera is available

 src/session/verification/identity_verification.rs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/session/verification/identity_verification.rs 
b/src/session/verification/identity_verification.rs
index 30f8a77b9..0d6598536 100644
--- a/src/session/verification/identity_verification.rs
+++ b/src/session/verification/identity_verification.rs
@@ -22,6 +22,7 @@ use tokio::sync::mpsc;
 
 use super::{VERIFICATION_CREATION_TIMEOUT, VERIFICATION_RECEIVE_TIMEOUT};
 use crate::{
+    contrib::Camera,
     session::{user::UserExt, Session, User},
     spawn, spawn_tokio, Error,
 };
@@ -388,7 +389,8 @@ impl IdentityVerification {
             (Mode::CurrentSession, session.user().unwrap())
         };
 
-        let supported_methods = SupportedMethods::with_camera(true);
+        let supported_methods =
+            SupportedMethods::with_camera(Camera::default().has_camera().await.unwrap_or_default());
 
         if let Some(identity) = user.crypto_identity().await {
             let handle = spawn_tokio!(async move {
@@ -439,6 +441,7 @@ impl IdentityVerification {
 
         let (sync_sender, sync_receiver) = mpsc::channel(100);
         priv_.sync_sender.replace(Some(sync_sender));
+
         let supported_methods = self.supported_methods();
 
         let handle = spawn_tokio!(async move {
@@ -946,6 +949,11 @@ impl Context {
             // Wait for the user to accept or cancel the request
             wait![self];
 
+            // Check whether we have a camera
+            if !Camera::default().has_camera().await.unwrap_or_default() {
+                self.supported_methods.remove(SupportedMethods::QR_SCAN);
+            }
+
             self.request
                 .accept_with_methods(self.supported_methods.into())
                 .await?;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]