From b0c5d7f3f4147d9fb218c6ee6dadcb519ed3101e Mon Sep 17 00:00:00 2001 From: Karasiq Date: Mon, 26 Oct 2020 20:37:36 +0300 Subject: [PATCH] Use challenges for Yandex captcha --- .../storage/yandex/YandexStoragePlugin.scala | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/storage/yandex/src/main/scala/com/karasiq/shadowcloud/storage/yandex/YandexStoragePlugin.scala b/storage/yandex/src/main/scala/com/karasiq/shadowcloud/storage/yandex/YandexStoragePlugin.scala index 2c876771..94e06f53 100644 --- a/storage/yandex/src/main/scala/com/karasiq/shadowcloud/storage/yandex/YandexStoragePlugin.scala +++ b/storage/yandex/src/main/scala/com/karasiq/shadowcloud/storage/yandex/YandexStoragePlugin.scala @@ -1,8 +1,5 @@ package com.karasiq.shadowcloud.storage.yandex -import java.awt.Desktop -import java.net.URI - import akka.Done import akka.actor.{ActorContext, ActorRef} import com.karasiq.shadowcloud.ShadowCloud @@ -20,22 +17,15 @@ import scala.util.Try class YandexStoragePlugin extends StoragePlugin { override def createStorage(storageId: StorageId, props: StorageProps)(implicit context: ActorContext): ActorRef = { import context.{dispatcher, system} - val sc = ShadowCloud() + val sc = ShadowCloud() val api = new YandexWebApi(solveCaptcha = { imageUrl ⇒ - Future { - sc.ui.showNotification(s"Yandex captcha required for $storageId: $imageUrl") - if (Desktop.isDesktopSupported) Desktop.getDesktop.browse(new URI(imageUrl)) - sc.ui.askPassword("Yandex captcha") - }(sc.ui.executionContext) + sc.challenges + .create(s"Yandex captcha ($storageId)", s"""""") + .map(_.utf8String) }, passChallenge = { url ⇒ - Future { - if (Desktop.isDesktopSupported) Desktop.getDesktop.browse(new URI(url)) - sc.ui.showNotification( - s"Yandex verification required for $storageId: $url\n" + - "Please complete the verification and then press OK" - ) - Done - }(sc.ui.executionContext) + sc.challenges + .create(s"Yandex verification ($storageId)", s"""Please complete the verification""") + .map(_ ⇒ Done) }) implicit val session: YandexSession = {