mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-25 17:12:38 +01:00
Small cleanup
This commit is contained in:
parent
bbbeb4b283
commit
45768c5251
@ -26,8 +26,6 @@ import androidx.lifecycle.ProcessLifecycleOwner
|
|||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import com.squareup.moshi.Moshi
|
|
||||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.BuildConfig
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
@ -48,6 +46,7 @@ import org.matrix.android.sdk.api.logger.LoggerTag
|
|||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.getRoom
|
import org.matrix.android.sdk.api.session.getRoom
|
||||||
import org.matrix.android.sdk.api.session.room.getTimelineEvent
|
import org.matrix.android.sdk.api.session.room.getTimelineEvent
|
||||||
|
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
||||||
import org.unifiedpush.android.connector.MessagingReceiver
|
import org.unifiedpush.android.connector.MessagingReceiver
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -113,20 +112,15 @@ class VectorMessagingReceiver : MessagingReceiver() {
|
|||||||
vectorDataStore.incrementPushCounter()
|
vectorDataStore.incrementPushCounter()
|
||||||
}
|
}
|
||||||
|
|
||||||
val moshi: Moshi = Moshi.Builder()
|
val moshi = MatrixJsonParser.getMoshi()
|
||||||
.add(KotlinJsonAdapterFactory())
|
val notification: Notification = if (unifiedPushHelper.isEmbeddedDistributor()) {
|
||||||
.build()
|
moshi.adapter(Notification::class.java).fromJson(sMessage)
|
||||||
lateinit var notification: Notification
|
|
||||||
|
|
||||||
if (unifiedPushHelper.isEmbeddedDistributor()) {
|
|
||||||
notification = moshi.adapter(Notification::class.java)
|
|
||||||
.fromJson(sMessage) ?: return
|
|
||||||
} else {
|
} else {
|
||||||
val data = moshi.adapter(UnifiedPushMessage::class.java)
|
val data = moshi.adapter(UnifiedPushMessage::class.java).fromJson(sMessage)
|
||||||
.fromJson(sMessage) ?: return
|
data?.notification?.also {
|
||||||
notification = data.notification
|
it.unread = it.counts.unread
|
||||||
notification.unread = notification.counts.unread
|
|
||||||
}
|
}
|
||||||
|
} ?: return Unit.also { Timber.w("Invalid received data") }
|
||||||
|
|
||||||
// Diagnostic Push
|
// Diagnostic Push
|
||||||
if (notification.eventId == PushersManager.TEST_EVENT_ID) {
|
if (notification.eventId == PushersManager.TEST_EVENT_ID) {
|
||||||
|
Loading…
Reference in New Issue
Block a user