This commit is contained in:
Karmanyaah Malhotra 2023-12-16 22:53:17 -06:00
parent eb1c8300ab
commit 235f354089
4 changed files with 2 additions and 6 deletions

View file

@ -96,7 +96,7 @@ class ApiService {
val body = response.body?.string()?.trim()
if (body.isNullOrEmpty()) return emptyList()
val notifications = body.lines().mapNotNull { line ->
parser.parseNotification(line, subscriptionId = subscriptionId, notificationId = 0) // No notification when we poll
parser.parse(line, subscriptionId = subscriptionId, notificationId = 0) // No notification when we poll
}
Log.d(TAG, "Notifications: $notifications")

View file

@ -17,7 +17,7 @@ class NotificationParser {
return gson.fromJson(s, Message::class.java)
}
fun parseNotification(s: String, subscriptionId: Long = 0, notificationId: Int = 0): Notification? {
fun parse(s: String, subscriptionId: Long = 0, notificationId: Int = 0): Notification? {
val message = parseMessage(s) ?: return null
val notificationWithTopic = parseNotificationWithTopic(message, subscriptionId = subscriptionId, notificationId = notificationId)
return notificationWithTopic?.notification

View file

@ -4,12 +4,10 @@ import io.heckel.ntfy.db.*
import io.heckel.ntfy.util.Log
import io.heckel.ntfy.msg.ApiService
import io.heckel.ntfy.msg.Message
import io.heckel.ntfy.msg.NotificationParser
import io.heckel.ntfy.util.topicUrl
import kotlinx.coroutines.*
import okhttp3.Call
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.random.Random
class JsonConnection(
private val connectionId: ConnectionId,

View file

@ -5,7 +5,6 @@ import android.os.Build
import android.os.Handler
import android.os.Looper
import io.heckel.ntfy.db.*
import io.heckel.ntfy.msg.ApiService
import io.heckel.ntfy.msg.ApiService.Companion.requestBuilder
import io.heckel.ntfy.msg.Message
import io.heckel.ntfy.msg.NotificationParser
@ -20,7 +19,6 @@ import java.util.*
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicLong
import java.util.concurrent.atomic.AtomicReference
import kotlin.random.Random
/**
* Connect to ntfy server via WebSockets. This connection represents a single connection to a server, with