set values to not nullable in ConversationEntity.kt wherever this makes sense

remove roomId from Conversation (deprecated. only token should be used)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-08-12 12:40:05 +02:00
parent 9892613984
commit a632765cce
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
18 changed files with 134 additions and 131 deletions

View File

@ -1734,7 +1734,7 @@ class CallActivity : CallBaseActivity() {
private fun setInitialApplicationWideCurrentRoomHolderValues(conversation: Conversation) { private fun setInitialApplicationWideCurrentRoomHolderValues(conversation: Conversation) {
ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser
ApplicationWideCurrentRoomHolder.getInstance().session = conversation.sessionId ApplicationWideCurrentRoomHolder.getInstance().session = conversation.sessionId
ApplicationWideCurrentRoomHolder.getInstance().currentRoomId = conversation.roomId // ApplicationWideCurrentRoomHolder.getInstance().currentRoomId = conversation.roomId
ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken = conversation.token ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken = conversation.token
ApplicationWideCurrentRoomHolder.getInstance().callStartTime = conversation.callStartTime ApplicationWideCurrentRoomHolder.getInstance().callStartTime = conversation.callStartTime
} }

View File

@ -54,7 +54,7 @@ class ConversationItem(
ISectionable<ConversationItemViewHolder, GenericTextHeaderItem?>, ISectionable<ConversationItemViewHolder, GenericTextHeaderItem?>,
IFilterable<String?> { IFilterable<String?> {
private var header: GenericTextHeaderItem? = null private var header: GenericTextHeaderItem? = null
private val chatMessage = model.lastMessageViaConversationList?.asModel() private val chatMessage = model.lastMessage?.asModel()
constructor( constructor(
conversation: ConversationModel, conversation: ConversationModel,

View File

@ -291,7 +291,7 @@ class ChatActivity :
var newMessagesCount = 0 var newMessagesCount = 0
var startCallFromNotification: Boolean = false var startCallFromNotification: Boolean = false
var startCallFromRoomSwitch: Boolean = false var startCallFromRoomSwitch: Boolean = false
lateinit var roomId: String // lateinit var roomId: String
var voiceOnly: Boolean = true var voiceOnly: Boolean = true
private lateinit var path: String private lateinit var path: String
@ -460,7 +460,7 @@ class ChatActivity :
private fun handleIntent(intent: Intent) { private fun handleIntent(intent: Intent) {
val extras: Bundle? = intent.extras val extras: Bundle? = intent.extras
roomId = extras?.getString(KEY_ROOM_ID).orEmpty() // roomId = extras?.getString(KEY_ROOM_ID).orEmpty()
roomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty() roomToken = extras?.getString(KEY_ROOM_TOKEN).orEmpty()
sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty() sharedText = extras?.getString(BundleKeys.KEY_SHARED_TEXT).orEmpty()
@ -619,7 +619,7 @@ class ChatActivity :
sessionIdAfterRoomJoined = currentConversation!!.sessionId sessionIdAfterRoomJoined = currentConversation!!.sessionId
ApplicationWideCurrentRoomHolder.getInstance().session = currentConversation!!.sessionId ApplicationWideCurrentRoomHolder.getInstance().session = currentConversation!!.sessionId
ApplicationWideCurrentRoomHolder.getInstance().currentRoomId = currentConversation!!.roomId // ApplicationWideCurrentRoomHolder.getInstance().currentRoomId = currentConversation!!.roomId
ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken = currentConversation!!.token ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken = currentConversation!!.token
ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser
@ -738,7 +738,7 @@ class ChatActivity :
is ChatViewModel.CreateRoomSuccessState -> { is ChatViewModel.CreateRoomSuccessState -> {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(KEY_ROOM_TOKEN, state.roomOverall.ocs!!.data!!.token) bundle.putString(KEY_ROOM_TOKEN, state.roomOverall.ocs!!.data!!.token)
bundle.putString(KEY_ROOM_ID, state.roomOverall.ocs!!.data!!.roomId) // bundle.putString(KEY_ROOM_ID, state.roomOverall.ocs!!.data!!.roomId)
leaveRoom { leaveRoom {
val chatIntent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
@ -2345,12 +2345,12 @@ class ChatActivity :
private fun joinRoomWithPassword() { private fun joinRoomWithPassword() {
// if ApplicationWideCurrentRoomHolder contains a session (because a call is active), then keep the sessionId // if ApplicationWideCurrentRoomHolder contains a session (because a call is active), then keep the sessionId
if (ApplicationWideCurrentRoomHolder.getInstance().currentRoomId == if (ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken ==
currentConversation!!.roomId currentConversation!!.token
) { ) {
sessionIdAfterRoomJoined = ApplicationWideCurrentRoomHolder.getInstance().session sessionIdAfterRoomJoined = ApplicationWideCurrentRoomHolder.getInstance().session
ApplicationWideCurrentRoomHolder.getInstance().currentRoomId = roomId // ApplicationWideCurrentRoomHolder.getInstance().currentRoomId = roomId
ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken = roomToken ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken = roomToken
ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser
} }
@ -2908,7 +2908,7 @@ class ChatActivity :
currentConversation?.let { currentConversation?.let {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(KEY_ROOM_TOKEN, roomToken) bundle.putString(KEY_ROOM_TOKEN, roomToken)
bundle.putString(KEY_ROOM_ID, roomId) // bundle.putString(KEY_ROOM_ID, roomId)
bundle.putString(BundleKeys.KEY_CONVERSATION_PASSWORD, roomPassword) bundle.putString(BundleKeys.KEY_CONVERSATION_PASSWORD, roomPassword)
bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, conversationUser?.baseUrl!!) bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, conversationUser?.baseUrl!!)
bundle.putString(KEY_CONVERSATION_NAME, it.displayName) bundle.putString(KEY_CONVERSATION_NAME, it.displayName)
@ -3043,7 +3043,7 @@ class ChatActivity :
val bundle = Bundle() val bundle = Bundle()
bundle.putBoolean(BundleKeys.KEY_FORWARD_MSG_FLAG, true) bundle.putBoolean(BundleKeys.KEY_FORWARD_MSG_FLAG, true)
bundle.putString(BundleKeys.KEY_FORWARD_MSG_TEXT, message?.text) bundle.putString(BundleKeys.KEY_FORWARD_MSG_TEXT, message?.text)
bundle.putString(BundleKeys.KEY_FORWARD_HIDE_SOURCE_ROOM, roomId) bundle.putString(BundleKeys.KEY_FORWARD_HIDE_SOURCE_ROOM, roomToken)
val intent = Intent(this, ConversationsListActivity::class.java) val intent = Intent(this, ConversationsListActivity::class.java)
intent.putExtras(bundle) intent.putExtras(bundle)

View File

@ -338,7 +338,7 @@ class ContactsActivity :
override fun onNext(roomOverall: RoomOverall) { override fun onNext(roomOverall: RoomOverall) {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token) bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token)
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId) // bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId)
val chatIntent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle) chatIntent.putExtras(bundle)
@ -804,7 +804,7 @@ class ContactsActivity :
override fun onNext(roomOverall: RoomOverall) { override fun onNext(roomOverall: RoomOverall) {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token) bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token)
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId) // bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId)
val chatIntent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle) chatIntent.putExtras(bundle)

View File

@ -220,7 +220,7 @@ fun ContactItemRow(contact: AutocompleteUser, contactsViewModel: ContactsViewMod
val conversation = (roomUiState as RoomUiState.Success).conversation val conversation = (roomUiState as RoomUiState.Success).conversation
val bundle = Bundle() val bundle = Bundle()
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, conversation?.token) bundle.putString(BundleKeys.KEY_ROOM_TOKEN, conversation?.token)
bundle.putString(BundleKeys.KEY_ROOM_ID, conversation?.roomId) // bundle.putString(BundleKeys.KEY_ROOM_ID, conversation?.roomId)
val chatIntent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle) chatIntent.putExtras(bundle)
chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)

View File

@ -775,7 +775,7 @@ class ConversationsListActivity :
private fun addToConversationItems(conversation: ConversationModel) { private fun addToConversationItems(conversation: ConversationModel) {
if (intent.getStringExtra(KEY_FORWARD_HIDE_SOURCE_ROOM) != null && if (intent.getStringExtra(KEY_FORWARD_HIDE_SOURCE_ROOM) != null &&
intent.getStringExtra(KEY_FORWARD_HIDE_SOURCE_ROOM) == conversation.roomId intent.getStringExtra(KEY_FORWARD_HIDE_SOURCE_ROOM) == conversation.token
) { ) {
return return
} }
@ -1456,7 +1456,7 @@ class ConversationsListActivity :
val bundle = Bundle() val bundle = Bundle()
bundle.putString(KEY_ROOM_TOKEN, selectedConversation!!.token) bundle.putString(KEY_ROOM_TOKEN, selectedConversation!!.token)
bundle.putString(KEY_ROOM_ID, selectedConversation!!.roomId) // bundle.putString(KEY_ROOM_ID, selectedConversation!!.roomId)
bundle.putString(KEY_SHARED_TEXT, textToPaste) bundle.putString(KEY_SHARED_TEXT, textToPaste)
if (selectedMessageId != null) { if (selectedMessageId != null) {
bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId) bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId)

View File

@ -32,7 +32,7 @@ fun ConversationModel.asEntity() =
lastActivity = lastActivity, lastActivity = lastActivity,
unreadMessages = unreadMessages, unreadMessages = unreadMessages,
unreadMention = unreadMention, unreadMention = unreadMention,
// lastMessageId = lastMessage?.id?.toLong(), lastMessage = lastMessage?.let { LoganSquare.serialize(lastMessage) },
objectType = objectType, objectType = objectType,
notificationLevel = notificationLevel, notificationLevel = notificationLevel,
conversationReadOnlyState = conversationReadOnlyState, conversationReadOnlyState = conversationReadOnlyState,
@ -81,8 +81,8 @@ fun ConversationEntity.asModel() =
lastActivity = lastActivity, lastActivity = lastActivity,
unreadMessages = unreadMessages, unreadMessages = unreadMessages,
unreadMention = unreadMention, unreadMention = unreadMention,
lastMessageViaConversationList = lastMessageJson?.let lastMessage = lastMessage?.let
{ LoganSquare.parse(lastMessageJson, ChatMessageJson::class.java) }, { LoganSquare.parse(lastMessage, ChatMessageJson::class.java) },
objectType = objectType, objectType = objectType,
notificationLevel = notificationLevel, notificationLevel = notificationLevel,
conversationReadOnlyState = conversationReadOnlyState, conversationReadOnlyState = conversationReadOnlyState,
@ -116,36 +116,36 @@ fun Conversation.asEntity(accountId: Long) =
ConversationEntity( ConversationEntity(
internalId = "$accountId@$token", internalId = "$accountId@$token",
accountId = accountId, accountId = accountId,
token = token, token = token!!,
name = name, name = name!!,
displayName = displayName, displayName = displayName!!,
description = description, description = description!!,
type = type, type = type!!,
lastPing = lastPing, lastPing = lastPing,
participantType = participantType, participantType = participantType!!,
hasPassword = hasPassword, hasPassword = hasPassword,
sessionId = sessionId, sessionId = sessionId!!,
actorId = actorId, actorId = actorId!!,
actorType = actorType, actorType = actorType!!,
favorite = favorite, favorite = favorite,
lastActivity = lastActivity, lastActivity = lastActivity,
unreadMessages = unreadMessages, unreadMessages = unreadMessages,
unreadMention = unreadMention, unreadMention = unreadMention,
lastMessageJson = lastMessage?.let { LoganSquare.serialize(lastMessage) }, lastMessage = lastMessage?.let { LoganSquare.serialize(lastMessage) },
objectType = objectType, objectType = objectType!!,
notificationLevel = notificationLevel, notificationLevel = notificationLevel!!,
conversationReadOnlyState = conversationReadOnlyState, conversationReadOnlyState = conversationReadOnlyState!!,
lobbyState = lobbyState, lobbyState = lobbyState!!,
lobbyTimer = lobbyTimer, lobbyTimer = lobbyTimer!!,
lastReadMessage = lastReadMessage, lastReadMessage = lastReadMessage,
lastCommonReadMessage = lastCommonReadMessage, lastCommonReadMessage = lastCommonReadMessage,
hasCall = hasCall, hasCall = hasCall,
callFlag = callFlag, callFlag = callFlag,
canStartCall = canStartCall, canStartCall = canStartCall,
canLeaveConversation = canLeaveConversation, canLeaveConversation = canLeaveConversation!!,
canDeleteConversation = canDeleteConversation, canDeleteConversation = canDeleteConversation!!,
unreadMentionDirect = unreadMentionDirect, unreadMentionDirect = unreadMentionDirect!!,
notificationCalls = notificationCalls, notificationCalls = notificationCalls!!,
permissions = permissions, permissions = permissions,
messageExpiration = messageExpiration, messageExpiration = messageExpiration,
status = status, status = status,
@ -153,9 +153,9 @@ fun Conversation.asEntity(accountId: Long) =
statusMessage = statusMessage, statusMessage = statusMessage,
statusClearAt = statusClearAt, statusClearAt = statusClearAt,
callRecording = callRecording, callRecording = callRecording,
avatarVersion = avatarVersion, avatarVersion = avatarVersion!!,
hasCustomAvatar = hasCustomAvatar, hasCustomAvatar = hasCustomAvatar!!,
callStartTime = callStartTime, callStartTime = callStartTime!!,
recordingConsentRequired = recordingConsentRequired, recordingConsentRequired = recordingConsentRequired,
remoteServer = remoteServer, remoteServer = remoteServer,
remoteToken = remoteToken remoteToken = remoteToken

View File

@ -11,6 +11,8 @@ import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
// ChatBlockEntity.kt:26: internalConversationId column references a foreign key but it is not part of an index. This may trigger full table scans whenever parent table is modified so you are highly advised to create an index that covers this column.
@Entity( @Entity(
tableName = "ChatBlocks", tableName = "ChatBlocks",
foreignKeys = [ foreignKeys = [

View File

@ -47,7 +47,7 @@ data class ChatMessageEntity(
@ColumnInfo(name = "systemMessage") var systemMessageType: ChatMessage.SystemMessageType? = null, @ColumnInfo(name = "systemMessage") var systemMessageType: ChatMessage.SystemMessageType? = null,
@ColumnInfo(name = "messageType") var messageType: String? = null, @ColumnInfo(name = "messageType") var messageType: String? = null,
@ColumnInfo(name = "isReplyable") var replyable: Boolean = false, @ColumnInfo(name = "isReplyable") var replyable: Boolean = false,
// TODO: add "referenceId" // missing/not needed: referenceId
@ColumnInfo(name = "message") var message: String? = null, @ColumnInfo(name = "message") var message: String? = null,
@ColumnInfo(name = "messageParameters") var messageParameters: HashMap<String?, HashMap<String?, String?>>? = null, @ColumnInfo(name = "messageParameters") var messageParameters: HashMap<String?, HashMap<String?, String?>>? = null,
@ColumnInfo(name = "expirationTimestamp") var expirationTimestamp: Int = 0, @ColumnInfo(name = "expirationTimestamp") var expirationTimestamp: Int = 0,
@ -60,5 +60,5 @@ data class ChatMessageEntity(
@ColumnInfo(name = "lastEditActorDisplayName") var lastEditActorDisplayName: String? = null, @ColumnInfo(name = "lastEditActorDisplayName") var lastEditActorDisplayName: String? = null,
@ColumnInfo(name = "lastEditTimestamp") var lastEditTimestamp: Long? = 0, @ColumnInfo(name = "lastEditTimestamp") var lastEditTimestamp: Long? = 0,
@ColumnInfo(name = "deleted") var deleted: Boolean = false, @ColumnInfo(name = "deleted") var deleted: Boolean = false,
// TODO: add "silent" // missing/not needed: silent
) )

View File

@ -44,49 +44,49 @@ data class ConversationEntity(
// "unread message" etc only match a specific account. // "unread message" etc only match a specific account.
// If multiple talk app accounts have the same conversation, it is stored as another dataset, which is // If multiple talk app accounts have the same conversation, it is stored as another dataset, which is
// exactly what we want for this case. // exactly what we want for this case.
@ColumnInfo(name = "token") var token: String?, @ColumnInfo(name = "token") var token: String,
@ColumnInfo(name = "type") var type: ConversationEnums.ConversationType? = null, @ColumnInfo(name = "type") var type: ConversationEnums.ConversationType,
@ColumnInfo(name = "name") var name: String? = null, @ColumnInfo(name = "name") var name: String,
@ColumnInfo(name = "displayName") var displayName: String? = null, @ColumnInfo(name = "displayName") var displayName: String,
@ColumnInfo(name = "description") var description: String? = null, @ColumnInfo(name = "description") var description: String,
@ColumnInfo(name = "participantType") var participantType: Participant.ParticipantType? = null, @ColumnInfo(name = "participantType") var participantType: Participant.ParticipantType,
// missing/not needed: attendeeId // missing/not needed: attendeeId
// missing/not needed: attendeePin // missing/not needed: attendeePin
@ColumnInfo(name = "actorType") var actorType: String? = null, @ColumnInfo(name = "actorType") var actorType: String,
@ColumnInfo(name = "actorId") var actorId: String? = null, @ColumnInfo(name = "actorId") var actorId: String,
@ColumnInfo(name = "permissions") var permissions: Int = 0, @ColumnInfo(name = "permissions") var permissions: Int = 0,
// missing/not needed: attendeePermissions // missing/not needed: attendeePermissions
// missing/not needed: callPermissions // missing/not needed: callPermissions
// missing/not needed: defaultPermissions // missing/not needed: defaultPermissions
// missing/not needed: participantInCall // missing/not needed: participantInCall
// missing/not needed: participantFlags // missing/not needed: participantFlags
@ColumnInfo(name = "readOnly") var conversationReadOnlyState: ConversationEnums.ConversationReadOnlyState? = null, @ColumnInfo(name = "readOnly") var conversationReadOnlyState: ConversationEnums.ConversationReadOnlyState,
// missing/not needed: listable // missing/not needed: listable
@ColumnInfo(name = "messageExpiration") var messageExpiration: Int = 0, @ColumnInfo(name = "messageExpiration") var messageExpiration: Int = 0,
// missing/not needed: count // missing/not needed: count
// missing/not needed: numGuests // missing/not needed: numGuests
@ColumnInfo(name = "lastPing") var lastPing: Long = 0, @ColumnInfo(name = "lastPing") var lastPing: Long = 0,
@ColumnInfo(name = "sessionId") var sessionId: String? = null, @ColumnInfo(name = "sessionId") var sessionId: String,
@ColumnInfo(name = "hasPassword") var hasPassword: Boolean = false, @ColumnInfo(name = "hasPassword") var hasPassword: Boolean = false,
@ColumnInfo(name = "hasCall") var hasCall: Boolean = false, @ColumnInfo(name = "hasCall") var hasCall: Boolean = false,
@ColumnInfo(name = "callFlag") var callFlag: Int = 0, @ColumnInfo(name = "callFlag") var callFlag: Int = 0,
@ColumnInfo(name = "canStartCall") var canStartCall: Boolean = false, @ColumnInfo(name = "canStartCall") var canStartCall: Boolean = false,
@ColumnInfo(name = "canDeleteConversation") var canDeleteConversation: Boolean? = null, @ColumnInfo(name = "canDeleteConversation") var canDeleteConversation: Boolean,
@ColumnInfo(name = "canLeaveConversation") var canLeaveConversation: Boolean? = null, @ColumnInfo(name = "canLeaveConversation") var canLeaveConversation: Boolean,
@ColumnInfo(name = "lastActivity") var lastActivity: Long = 0, @ColumnInfo(name = "lastActivity") var lastActivity: Long = 0,
@ColumnInfo(name = "isFavorite") var favorite: Boolean = false, @ColumnInfo(name = "isFavorite") var favorite: Boolean = false,
@ColumnInfo(name = "notificationLevel") var notificationLevel: ConversationEnums.NotificationLevel? = null, @ColumnInfo(name = "notificationLevel") var notificationLevel: ConversationEnums.NotificationLevel,
@ColumnInfo(name = "lobbyState") var lobbyState: ConversationEnums.LobbyState? = null, @ColumnInfo(name = "lobbyState") var lobbyState: ConversationEnums.LobbyState,
@ColumnInfo(name = "lobbyTimer") var lobbyTimer: Long? = null, @ColumnInfo(name = "lobbyTimer") var lobbyTimer: Long = 0,
// missing/not needed: sipEnabled // missing/not needed: sipEnabled
// missing/not needed: canEnableSIP // missing/not needed: canEnableSIP
@ColumnInfo(name = "unreadMessages") var unreadMessages: Int = 0, @ColumnInfo(name = "unreadMessages") var unreadMessages: Int = 0,
@ColumnInfo(name = "unreadMention") var unreadMention: Boolean = false, @ColumnInfo(name = "unreadMention") var unreadMention: Boolean = false,
@ColumnInfo(name = "unreadMentionDirect") var unreadMentionDirect: Boolean? = null, @ColumnInfo(name = "unreadMentionDirect") var unreadMentionDirect: Boolean,
@ColumnInfo(name = "lastReadMessage") var lastReadMessage: Int = 0, @ColumnInfo(name = "lastReadMessage") var lastReadMessage: Int = 0,
@ColumnInfo(name = "lastCommonReadMessage") var lastCommonReadMessage: Int = 0, @ColumnInfo(name = "lastCommonReadMessage") var lastCommonReadMessage: Int = 0,
@ColumnInfo(name = "lastMessageJson") var lastMessageJson: String? = null, @ColumnInfo(name = "lastMessage") var lastMessage: String? = null,
@ColumnInfo(name = "objectType") var objectType: ConversationEnums.ObjectType? = null, @ColumnInfo(name = "objectType") var objectType: ConversationEnums.ObjectType,
// missing/not needed: objectId // missing/not needed: objectId
// missing/not needed: breakoutRoomMode // missing/not needed: breakoutRoomMode
// missing/not needed: breakoutRoomStatus // missing/not needed: breakoutRoomStatus
@ -94,13 +94,13 @@ data class ConversationEntity(
@ColumnInfo(name = "statusIcon") var statusIcon: String? = null, @ColumnInfo(name = "statusIcon") var statusIcon: String? = null,
@ColumnInfo(name = "statusMessage") var statusMessage: String? = null, @ColumnInfo(name = "statusMessage") var statusMessage: String? = null,
@ColumnInfo(name = "statusClearAt") var statusClearAt: Long? = 0, @ColumnInfo(name = "statusClearAt") var statusClearAt: Long? = 0,
@ColumnInfo(name = "avatarVersion") var avatarVersion: String? = null, @ColumnInfo(name = "avatarVersion") var avatarVersion: String,
@ColumnInfo(name = "isCustomAvatar") var hasCustomAvatar: Boolean? = null, @ColumnInfo(name = "isCustomAvatar") var hasCustomAvatar: Boolean,
@ColumnInfo(name = "callStartTime") var callStartTime: Long? = null, @ColumnInfo(name = "callStartTime") var callStartTime: Long = 0,
@ColumnInfo(name = "callRecording") var callRecording: Int = 0, @ColumnInfo(name = "callRecording") var callRecording: Int = 0,
@ColumnInfo(name = "recordingConsent") var recordingConsentRequired: Int = 0, @ColumnInfo(name = "recordingConsent") var recordingConsentRequired: Int = 0,
@ColumnInfo(name = "notificationCalls") var notificationCalls: Int? = null, @ColumnInfo(name = "notificationCalls") var notificationCalls: Int = 0,
@ColumnInfo(name = "remoteServer") var remoteServer: String? = null, @ColumnInfo(name = "remoteServer") var remoteServer: String? = null,
@ColumnInfo(name = "remoteToken") var remoteToken: String? = null @ColumnInfo(name = "remoteToken") var remoteToken: String? = null
) )

View File

@ -16,38 +16,37 @@ import com.nextcloud.talk.models.json.participants.Participant
class ConversationModel( class ConversationModel(
var internalId: String, var internalId: String,
var accountId: Long, var accountId: Long,
var roomId: String? = null, // var roomId: String? = null,
var token: String? = null, var token: String,
var name: String? = null, var name: String,
var displayName: String? = null, var displayName: String,
var description: String? = null, var description: String,
var type: ConversationEnums.ConversationType? = null, var type: ConversationEnums.ConversationType,
var lastPing: Long = 0, var lastPing: Long = 0,
var participantType: Participant.ParticipantType? = null, var participantType: Participant.ParticipantType,
var hasPassword: Boolean = false, var hasPassword: Boolean = false,
var sessionId: String? = null, var sessionId: String,
var actorId: String? = null, var actorId: String,
var actorType: String? = null, var actorType: String,
var password: String? = null,
var favorite: Boolean = false, var favorite: Boolean = false,
var lastActivity: Long = 0, var lastActivity: Long = 0,
var unreadMessages: Int = 0, var unreadMessages: Int = 0,
var unreadMention: Boolean = false, var unreadMention: Boolean = false,
var lastMessageViaConversationList: ChatMessageJson? = null, var lastMessage: ChatMessageJson? = null,
var objectType: ConversationEnums.ObjectType? = null, var objectType: ConversationEnums.ObjectType,
var notificationLevel: ConversationEnums.NotificationLevel? = null, var notificationLevel: ConversationEnums.NotificationLevel,
var conversationReadOnlyState: ConversationEnums.ConversationReadOnlyState? = null, var conversationReadOnlyState: ConversationEnums.ConversationReadOnlyState,
var lobbyState: ConversationEnums.LobbyState? = null, var lobbyState: ConversationEnums.LobbyState,
var lobbyTimer: Long? = null, var lobbyTimer: Long,
var lastReadMessage: Int = 0, var lastReadMessage: Int = 0,
var lastCommonReadMessage: Int = 0, var lastCommonReadMessage: Int = 0,
var hasCall: Boolean = false, var hasCall: Boolean = false,
var callFlag: Int = 0, var callFlag: Int = 0,
var canStartCall: Boolean = false, var canStartCall: Boolean = false,
var canLeaveConversation: Boolean? = null, var canLeaveConversation: Boolean,
var canDeleteConversation: Boolean? = null, var canDeleteConversation: Boolean,
var unreadMentionDirect: Boolean? = null, var unreadMentionDirect: Boolean,
var notificationCalls: Int? = null, var notificationCalls: Int,
var permissions: Int = 0, var permissions: Int = 0,
var messageExpiration: Int = 0, var messageExpiration: Int = 0,
var status: String? = null, var status: String? = null,
@ -55,12 +54,15 @@ class ConversationModel(
var statusMessage: String? = null, var statusMessage: String? = null,
var statusClearAt: Long? = 0, var statusClearAt: Long? = 0,
var callRecording: Int = 0, var callRecording: Int = 0,
var avatarVersion: String? = null, var avatarVersion: String,
var hasCustomAvatar: Boolean? = null, var hasCustomAvatar: Boolean,
var callStartTime: Long? = null, var callStartTime: Long,
var recordingConsentRequired: Int = 0, var recordingConsentRequired: Int = 0,
var remoteServer: String? = null, var remoteServer: String? = null,
var remoteToken: String? = null, var remoteToken: String? = null,
// attributes that don't come from API. This should be changed?!
var password: String? = null,
) { ) {
companion object { companion object {
@ -68,46 +70,46 @@ class ConversationModel(
return ConversationModel( return ConversationModel(
internalId = user.id!!.toString() + "@" + conversation.token, internalId = user.id!!.toString() + "@" + conversation.token,
accountId = user.id!!, accountId = user.id!!,
roomId = conversation.roomId, // roomId = conversation.roomId,
token = conversation.token, token = conversation.token!!,
name = conversation.name, name = conversation.name!!,
displayName = conversation.displayName, displayName = conversation.displayName!!,
description = conversation.description, description = conversation.description!!,
type = conversation.type?.let { ConversationEnums.ConversationType.valueOf(it.name) }, type = conversation.type.let { ConversationEnums.ConversationType.valueOf(it!!.name) },
lastPing = conversation.lastPing, lastPing = conversation.lastPing,
participantType = conversation.participantType?.let { Participant.ParticipantType.valueOf(it.name) }, participantType = conversation.participantType.let { Participant.ParticipantType.valueOf(it!!.name) },
hasPassword = conversation.hasPassword, hasPassword = conversation.hasPassword,
sessionId = conversation.sessionId, sessionId = conversation.sessionId!!,
actorId = conversation.actorId, actorId = conversation.actorId!!,
actorType = conversation.actorType, actorType = conversation.actorType!!,
password = conversation.password, password = conversation.password,
favorite = conversation.favorite, favorite = conversation.favorite,
lastActivity = conversation.lastActivity, lastActivity = conversation.lastActivity,
unreadMessages = conversation.unreadMessages, unreadMessages = conversation.unreadMessages,
unreadMention = conversation.unreadMention, unreadMention = conversation.unreadMention,
// lastMessage = conversation.lastMessage, to do... lastMessage = conversation.lastMessage,
objectType = conversation.objectType?.let { ConversationEnums.ObjectType.valueOf(it.name) }, objectType = conversation.objectType.let { ConversationEnums.ObjectType.valueOf(it!!.name) },
notificationLevel = conversation.notificationLevel?.let { notificationLevel = conversation.notificationLevel.let {
ConversationEnums.NotificationLevel.valueOf( ConversationEnums.NotificationLevel.valueOf(
it.name it!!.name
) )
}, },
conversationReadOnlyState = conversation.conversationReadOnlyState?.let { conversationReadOnlyState = conversation.conversationReadOnlyState.let {
ConversationEnums.ConversationReadOnlyState.valueOf( ConversationEnums.ConversationReadOnlyState.valueOf(
it.name it!!.name
) )
}, },
lobbyState = conversation.lobbyState?.let { ConversationEnums.LobbyState.valueOf(it.name) }, lobbyState = conversation.lobbyState.let { ConversationEnums.LobbyState.valueOf(it!!.name) },
lobbyTimer = conversation.lobbyTimer, lobbyTimer = conversation.lobbyTimer!!,
lastReadMessage = conversation.lastReadMessage, lastReadMessage = conversation.lastReadMessage,
lastCommonReadMessage = conversation.lastCommonReadMessage, lastCommonReadMessage = conversation.lastCommonReadMessage,
hasCall = conversation.hasCall, hasCall = conversation.hasCall,
callFlag = conversation.callFlag, callFlag = conversation.callFlag,
canStartCall = conversation.canStartCall, canStartCall = conversation.canStartCall,
canLeaveConversation = conversation.canLeaveConversation, canLeaveConversation = conversation.canLeaveConversation!!,
canDeleteConversation = conversation.canDeleteConversation, canDeleteConversation = conversation.canDeleteConversation!!,
unreadMentionDirect = conversation.unreadMentionDirect, unreadMentionDirect = conversation.unreadMentionDirect!!,
notificationCalls = conversation.notificationCalls, notificationCalls = conversation.notificationCalls!!,
permissions = conversation.permissions, permissions = conversation.permissions,
messageExpiration = conversation.messageExpiration, messageExpiration = conversation.messageExpiration,
status = conversation.status, status = conversation.status,
@ -115,9 +117,9 @@ class ConversationModel(
statusMessage = conversation.statusMessage, statusMessage = conversation.statusMessage,
statusClearAt = conversation.statusClearAt, statusClearAt = conversation.statusClearAt,
callRecording = conversation.callRecording, callRecording = conversation.callRecording,
avatarVersion = conversation.avatarVersion, avatarVersion = conversation.avatarVersion!!,
hasCustomAvatar = conversation.hasCustomAvatar, hasCustomAvatar = conversation.hasCustomAvatar!!,
callStartTime = conversation.callStartTime, callStartTime = conversation.callStartTime!!,
recordingConsentRequired = conversation.recordingConsentRequired, recordingConsentRequired = conversation.recordingConsentRequired,
remoteServer = conversation.remoteServer, remoteServer = conversation.remoteServer,
remoteToken = conversation.remoteToken remoteToken = conversation.remoteToken

View File

@ -28,8 +28,8 @@ import kotlinx.parcelize.Parcelize
@Parcelize @Parcelize
@JsonObject @JsonObject
data class Conversation( data class Conversation(
@JsonField(name = ["id"]) // @JsonField(name = ["id"])
var roomId: String? = null, // var roomId: String? = null,
@JsonField(name = ["token"]) @JsonField(name = ["token"])
var token: String? = null, var token: String? = null,
@JsonField(name = ["name"]) @JsonField(name = ["name"])
@ -67,7 +67,6 @@ data class Conversation(
@JsonField(name = ["unreadMention"]) @JsonField(name = ["unreadMention"])
var unreadMention: Boolean = false, var unreadMention: Boolean = false,
// TODO get this from Json -> map to ChatMessage and fix error
@JsonField(name = ["lastMessage"]) @JsonField(name = ["lastMessage"])
var lastMessage: ChatMessageJson? = null, var lastMessage: ChatMessageJson? = null,

View File

@ -76,6 +76,6 @@ object ConversationsCallback : DiffUtil.ItemCallback<OpenConversation>() {
} }
override fun areContentsTheSame(oldItem: OpenConversation, newItem: OpenConversation): Boolean { override fun areContentsTheSame(oldItem: OpenConversation, newItem: OpenConversation): Boolean {
return oldItem.roomId == newItem.roomId return oldItem.roomToken == newItem.roomToken
} }
} }

View File

@ -7,7 +7,7 @@
package com.nextcloud.talk.openconversations.data package com.nextcloud.talk.openconversations.data
data class OpenConversation( data class OpenConversation(
var roomId: String, // var roomId: String,
var roomToken: String, var roomToken: String,
var displayName: String, var displayName: String,
var description: String? var description: String?

View File

@ -32,7 +32,7 @@ class OpenConversationsRepositoryImpl(private val ncApi: NcApi, currentUserProvi
return OpenConversationsModel( return OpenConversationsModel(
conversations.map { conversation -> conversations.map { conversation ->
OpenConversation( OpenConversation(
conversation.roomId!!, // conversation.roomId!!,
conversation.token!!, conversation.token!!,
conversation.name!!, conversation.name!!,
conversation.description ?: "" conversation.description ?: ""

View File

@ -140,7 +140,7 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val viewThemeUti
override fun onNext(roomOverall: RoomOverall) { override fun onNext(roomOverall: RoomOverall) {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token) bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.ocs!!.data!!.token)
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId) // bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs!!.data!!.roomId)
val chatIntent = Intent(context, ChatActivity::class.java) val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(bundle) chatIntent.putExtras(bundle)

View File

@ -312,7 +312,7 @@ class ConversationsListBottomDialog(
private fun markConversationAsRead() { private fun markConversationAsRead() {
val messageId = if (conversation.remoteServer.isNullOrEmpty()) { val messageId = if (conversation.remoteServer.isNullOrEmpty()) {
conversation.lastMessageViaConversationList?.id conversation.lastMessage?.id
} else { } else {
null null
} }

View File

@ -14,7 +14,7 @@ public class ApplicationWideCurrentRoomHolder {
public static final String TAG = "ApplicationWideCurrentRoomHolder"; public static final String TAG = "ApplicationWideCurrentRoomHolder";
private static final ApplicationWideCurrentRoomHolder holder = new ApplicationWideCurrentRoomHolder(); private static final ApplicationWideCurrentRoomHolder holder = new ApplicationWideCurrentRoomHolder();
private String currentRoomId = ""; // private String currentRoomId = "";
private String currentRoomToken = ""; private String currentRoomToken = "";
private User userInRoom = new User(); private User userInRoom = new User();
private boolean inCall = false; private boolean inCall = false;
@ -29,7 +29,7 @@ public class ApplicationWideCurrentRoomHolder {
public void clear() { public void clear() {
Log.d(TAG, "ApplicationWideCurrentRoomHolder was cleared"); Log.d(TAG, "ApplicationWideCurrentRoomHolder was cleared");
currentRoomId = ""; // currentRoomId = "";
userInRoom = new User(); userInRoom = new User();
inCall = false; inCall = false;
isDialing = false; isDialing = false;
@ -45,13 +45,13 @@ public class ApplicationWideCurrentRoomHolder {
this.currentRoomToken = currentRoomToken; this.currentRoomToken = currentRoomToken;
} }
public String getCurrentRoomId() { // public String getCurrentRoomId() {
return currentRoomId; // return currentRoomId;
} // }
//
public void setCurrentRoomId(String currentRoomId) { // public void setCurrentRoomId(String currentRoomId) {
this.currentRoomId = currentRoomId; // this.currentRoomId = currentRoomId;
} // }
public User getUserInRoom() { public User getUserInRoom() {
return userInRoom; return userInRoom;