diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt index 860da6c21..81873b411 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt @@ -10,6 +10,7 @@ package com.nextcloud.talk.chat.data import android.os.Bundle import com.nextcloud.talk.chat.data.io.LifecycleAwareManager import com.nextcloud.talk.chat.data.model.ChatMessage +import com.nextcloud.talk.data.database.model.ChatMessageEntity import com.nextcloud.talk.models.domain.ConversationModel import kotlinx.coroutines.Job import kotlinx.coroutines.flow.Flow @@ -65,6 +66,11 @@ interface ChatMessageRepository : LifecycleAwareManager { */ suspend fun getMessage(messageId: Long, bundle: Bundle): Flow + /** + * TODO + */ + suspend fun updateDBAfterPushNotification(message: ChatMessageEntity) + /** * Destroys unused resources. */ diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt index 7be5caaed..ec76b576e 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt @@ -391,6 +391,10 @@ class OfflineFirstChatRepository @Inject constructor( .map(ChatMessageEntity::asModel) } + override suspend fun updateDBAfterPushNotification(message: ChatMessageEntity) { + // TODO Figure this out + } + @Suppress("UNCHECKED_CAST", "MagicNumber") private fun getMessagesFromServer(bundle: Bundle): Pair>? { val fieldMap = bundle.getSerializable(BundleKeys.KEY_FIELD_MAP) as HashMap diff --git a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt index 053ad4766..b0b2bcae6 100644 --- a/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt +++ b/app/src/main/java/com/nextcloud/talk/data/source/local/TalkDatabase.kt @@ -108,7 +108,7 @@ abstract class TalkDatabase : RoomDatabase() { return Room .databaseBuilder(context.applicationContext, TalkDatabase::class.java, dbName) // comment out openHelperFactory to view the database entries in Android Studio for debugging - .openHelperFactory(factory) + // .openHelperFactory(factory) .addMigrations( Migrations.MIGRATION_6_8, Migrations.MIGRATION_7_8, diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt index ac0fe43db..a3112700e 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt @@ -49,7 +49,9 @@ import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication import com.nextcloud.talk.arbitrarystorage.ArbitraryStorageManager import com.nextcloud.talk.callnotification.CallNotificationActivity +import com.nextcloud.talk.chat.data.ChatMessageRepository import com.nextcloud.talk.chat.data.network.ChatNetworkDataSource +import com.nextcloud.talk.conversationlist.data.network.OfflineFirstConversationsRepository import com.nextcloud.talk.models.SignatureVerification import com.nextcloud.talk.models.domain.ConversationModel import com.nextcloud.talk.models.json.chat.ChatUtils.Companion.getParsedMessage @@ -96,6 +98,9 @@ import io.reactivex.Observer import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable import io.reactivex.schedulers.Schedulers +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch import okhttp3.JavaNetCookieJar import okhttp3.OkHttpClient import retrofit2.Retrofit @@ -131,6 +136,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor @Inject lateinit var userManager: UserManager + @Inject + lateinit var chatMessageRepository: ChatMessageRepository + + @Inject + lateinit var conversationsRepository: OfflineFirstConversationsRepository + @JvmField @Inject var okHttpClient: OkHttpClient? = null @@ -203,6 +214,16 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor } else { showNotification(mainActivityIntent, null) } + + loadMessageToDB() + } + + private fun loadMessageToDB() { + val token = pushMessage.id + + CoroutineScope(Dispatchers.Default).launch { + // TODO + } } private fun handleRemoteTalkSharePushMessage() {