Skip to content

Commit

Permalink
WIP running into 412 errors
Browse files Browse the repository at this point in the history
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
  • Loading branch information
rapterjet2004 committed Nov 18, 2024
1 parent 3908d0c commit 36655ff
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,6 +66,11 @@ interface ChatMessageRepository : LifecycleAwareManager {
*/
suspend fun getMessage(messageId: Long, bundle: Bundle): Flow<ChatMessage>

/**
* TODO
*/
suspend fun updateDBAfterPushNotification(message: ChatMessageEntity)

/**
* Destroys unused resources.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int, List<ChatMessageJson>>? {
val fieldMap = bundle.getSerializable(BundleKeys.KEY_FIELD_MAP) as HashMap<String, Int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 36655ff

Please sign in to comment.