mirror of
https://github.com/nextcloud/talk-android
synced 2025-01-31 19:42:34 +00:00
read matching user context
Resolves #2180 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
1577a99567
commit
07c57bcfd1
@ -42,6 +42,7 @@ import com.nextcloud.talk.models.database.UserEntity
|
|||||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.NotificationUtils
|
import com.nextcloud.talk.utils.NotificationUtils
|
||||||
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils
|
import com.nextcloud.talk.utils.database.user.UserUtils
|
||||||
@ -55,12 +56,10 @@ import javax.inject.Inject
|
|||||||
class DirectReplyReceiver : BroadcastReceiver() {
|
class DirectReplyReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@JvmField
|
lateinit var userUtils: UserUtils
|
||||||
var userUtils: UserUtils? = null
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@JvmField
|
lateinit var ncApi: NcApi
|
||||||
var ncApi: NcApi? = null
|
|
||||||
|
|
||||||
lateinit var context: Context
|
lateinit var context: Context
|
||||||
lateinit var currentUser: UserEntity
|
lateinit var currentUser: UserEntity
|
||||||
@ -74,13 +73,15 @@ class DirectReplyReceiver : BroadcastReceiver() {
|
|||||||
|
|
||||||
override fun onReceive(receiveContext: Context, intent: Intent?) {
|
override fun onReceive(receiveContext: Context, intent: Intent?) {
|
||||||
context = receiveContext
|
context = receiveContext
|
||||||
currentUser = userUtils!!.currentUser!!
|
|
||||||
|
|
||||||
// NOTE - systemNotificationId is an internal ID used on the device only.
|
// NOTE - systemNotificationId is an internal ID used on the device only.
|
||||||
// It is NOT the same as the notification ID used in communication with the server.
|
// It is NOT the same as the notification ID used in communication with the server.
|
||||||
systemNotificationId = intent!!.getIntExtra(KEY_SYSTEM_NOTIFICATION_ID, 0)
|
systemNotificationId = intent!!.getIntExtra(KEY_SYSTEM_NOTIFICATION_ID, 0)
|
||||||
roomToken = intent.getStringExtra(KEY_ROOM_TOKEN)
|
roomToken = intent.getStringExtra(KEY_ROOM_TOKEN)
|
||||||
|
|
||||||
|
val id = intent.getLongExtra(KEY_INTERNAL_USER_ID, userUtils.currentUser!!.getId())
|
||||||
|
currentUser = userUtils.getUserWithId(id)
|
||||||
|
|
||||||
replyMessage = getMessageText(intent)
|
replyMessage = getMessageText(intent)
|
||||||
sendDirectReply()
|
sendDirectReply()
|
||||||
}
|
}
|
||||||
@ -94,7 +95,7 @@ class DirectReplyReceiver : BroadcastReceiver() {
|
|||||||
val apiVersion = ApiUtils.getChatApiVersion(currentUser, intArrayOf(1))
|
val apiVersion = ApiUtils.getChatApiVersion(currentUser, intArrayOf(1))
|
||||||
val url = ApiUtils.getUrlForChat(apiVersion, currentUser.baseUrl, roomToken)
|
val url = ApiUtils.getUrlForChat(apiVersion, currentUser.baseUrl, roomToken)
|
||||||
|
|
||||||
ncApi!!.sendChatMessage(credentials, url, replyMessage, currentUser.displayName, null, false)
|
ncApi.sendChatMessage(credentials, url, replyMessage, currentUser.displayName, null, false)
|
||||||
?.subscribeOn(Schedulers.io())
|
?.subscribeOn(Schedulers.io())
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.subscribe(object : Observer<GenericOverall> {
|
?.subscribe(object : Observer<GenericOverall> {
|
||||||
|
Loading…
Reference in New Issue
Block a user