mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 09:09:08 -04:00
fix js exception on undefined "id".
This commit is contained in:
parent
e17ec3d1f9
commit
b135de6fc0
|
@ -3,6 +3,7 @@ package app.handlers
|
||||||
import scala.annotation.{nowarn, tailrec}
|
import scala.annotation.{nowarn, tailrec}
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
|
import scala.util.{Failure, Success}
|
||||||
import scala.scalajs.js
|
import scala.scalajs.js
|
||||||
import slinky.core.FunctionalComponent
|
import slinky.core.FunctionalComponent
|
||||||
import slinky.web.html._
|
import slinky.web.html._
|
||||||
|
@ -127,10 +128,11 @@ object EventSignatures extends Handler {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
Nostr
|
val hash = Nostr.getEventHash(event)
|
||||||
.getEventHash(event) == (c.get[String]("id")).toOption.get match {
|
|
||||||
case true => Right(render(true))
|
c.get[String]("id") match {
|
||||||
case false => Left(render(false))
|
case Right(id) if id == hash => Right(render(true))
|
||||||
|
case _ => Left(render(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,11 +150,9 @@ object EventSignatures extends Handler {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
Nostr.verifySignature(event).toFuture map { result =>
|
Nostr.verifySignature(event).toFuture map {
|
||||||
result match {
|
case true => Right(render(true))
|
||||||
case true => Right(render(true))
|
case false => Left(render(false))
|
||||||
case false => Left(render(false))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ object EventSignatures extends Handler {
|
||||||
acc: List[slinky.core.TagMod[Nothing]]
|
acc: List[slinky.core.TagMod[Nothing]]
|
||||||
): Future[List[slinky.core.TagMod[Nothing]]] = remaining match {
|
): Future[List[slinky.core.TagMod[Nothing]]] = remaining match {
|
||||||
case fn :: tail => {
|
case fn :: tail => {
|
||||||
fn(props) flatMap { res =>
|
fn(props) flatMap {
|
||||||
res match {
|
{
|
||||||
case Left(el) => runAndUnwrapUntilFirstLeft(Nil, el :: acc)
|
case Left(el) => runAndUnwrapUntilFirstLeft(Nil, el :: acc)
|
||||||
case Right(el) => runAndUnwrapUntilFirstLeft(tail, el :: acc)
|
case Right(el) => runAndUnwrapUntilFirstLeft(tail, el :: acc)
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,11 @@ object EventSignatures extends Handler {
|
||||||
case Nil => Future { acc.reverse }
|
case Nil => Future { acc.reverse }
|
||||||
}
|
}
|
||||||
|
|
||||||
runAndUnwrapUntilFirstLeft(protoElements, List()) foreach setElements
|
runAndUnwrapUntilFirstLeft(protoElements, List()) onComplete {
|
||||||
|
case Success(x) => setElements(x)
|
||||||
|
case Failure(err) =>
|
||||||
|
println(f"failed to run through elements: ${err}")
|
||||||
|
}
|
||||||
|
|
||||||
() => {}
|
() => {}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user