mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 19:33:01 +00:00
check if is using secret and if application is not connected already
This commit is contained in:
@@ -206,12 +206,21 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
|||||||
if (secret.isNotBlank()) {
|
if (secret.isNotBlank()) {
|
||||||
bunkerRequest.secret = secret
|
bunkerRequest.secret = secret
|
||||||
applicationWithSecret = database.applicationDao().getBySecret(secret)
|
applicationWithSecret = database.applicationDao().getBySecret(secret)
|
||||||
if (applicationWithSecret == null || secret.isBlank()) {
|
if (applicationWithSecret == null || secret.isBlank() || applicationWithSecret.application.isConnected || !applicationWithSecret.application.useSecret) {
|
||||||
|
val message = if (applicationWithSecret == null) {
|
||||||
|
"invalid secret"
|
||||||
|
} else if (secret.isBlank()) {
|
||||||
|
"no secret"
|
||||||
|
} else if (applicationWithSecret.application.isConnected) {
|
||||||
|
"already connected"
|
||||||
|
} else {
|
||||||
|
"secret not in use"
|
||||||
|
}
|
||||||
IntentUtils.sendBunkerResponse(
|
IntentUtils.sendBunkerResponse(
|
||||||
applicationContext,
|
applicationContext,
|
||||||
acc,
|
acc,
|
||||||
bunkerRequest,
|
bunkerRequest,
|
||||||
BunkerResponse(bunkerRequest.id, "", "invalid secret"),
|
BunkerResponse(bunkerRequest.id, "", message),
|
||||||
applicationWithSecret?.application?.relays ?: listOf(),
|
applicationWithSecret?.application?.relays ?: listOf(),
|
||||||
onLoading = { },
|
onLoading = { },
|
||||||
onDone = { },
|
onDone = { },
|
||||||
|
|||||||
Reference in New Issue
Block a user