Move Json provider from Network module to AppModule to reuse it.
This commit is contained in:
parent
4400cd3643
commit
7c437761c4
10 changed files with 34 additions and 25 deletions
|
|
@ -13,9 +13,9 @@ import io.element.android.libraries.pushproviders.api.PushData
|
|||
import kotlinx.serialization.json.Json
|
||||
|
||||
@Inject
|
||||
class UnifiedPushParser {
|
||||
private val json by lazy { Json { ignoreUnknownKeys = true } }
|
||||
|
||||
class UnifiedPushParser(
|
||||
private val json: Json,
|
||||
) {
|
||||
fun parse(message: ByteArray, clientSecret: String): PushData? {
|
||||
return tryOrNull { json.decodeFromString<PushDataUnifiedPush>(String(message)) }?.toPushData(clientSecret)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue