Skip to content

Commit

Permalink
Add test for conversation conversion
Browse files Browse the repository at this point in the history
This test respects different API versions and checks if default values are set as expected.

- remove deprecated+unused methods
- remove comments
- remove unnecessary double-bang operator

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
  • Loading branch information
mahibi committed Sep 26, 2024
1 parent 454c829 commit c89f620
Show file tree
Hide file tree
Showing 11 changed files with 436 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1745,9 +1745,8 @@ class CallActivity : CallBaseActivity() {
ApplicationWideCurrentRoomHolder.getInstance().callStartTime = conversation.callStartTime
}

private fun startCallTimeCounter(callStartTime: Long?) {
if (callStartTime != null &&
callStartTime != 0L &&
private fun startCallTimeCounter(callStartTime: Long) {
if (callStartTime != 0L &&
hasSpreedFeatureCapability(
conversationUser!!.capabilities!!.spreedCapability!!, SpreedFeatures.RECORDING_V1
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ class ConversationInfoActivity :
binding.webinarInfoView.startTimeButton.setOnClickListener {
MaterialDialog(this, BottomSheet(WRAP_CONTENT)).show {
val currentTimeCalendar = Calendar.getInstance()
if (conversation!!.lobbyTimer != null && conversation!!.lobbyTimer != 0L) {
currentTimeCalendar.timeInMillis = conversation!!.lobbyTimer!! * DateConstants.SECOND_DIVIDER
if (conversation!!.lobbyTimer != 0L) {
currentTimeCalendar.timeInMillis = conversation!!.lobbyTimer * DateConstants.SECOND_DIVIDER
}

dateTimePicker(
Expand Down Expand Up @@ -746,13 +746,13 @@ class ConversationInfoActivity :

setupWebinaryView()

if (!ConversationUtils.canLeave(conversation!!)) {
if (!conversation!!.canLeaveConversation) {
binding.leaveConversationAction.visibility = GONE
} else {
binding.leaveConversationAction.visibility = VISIBLE
}

if (!ConversationUtils.canDelete(conversation!!, spreedCapabilities)) {
if (!conversation!!.canDeleteConversation) {
binding.deleteConversationAction.visibility = GONE
} else {
binding.deleteConversationAction.visibility = VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,46 +116,46 @@ fun Conversation.asEntity(accountId: Long) =
ConversationEntity(
internalId = "$accountId@$token",
accountId = accountId,
token = token!!,
name = name!!,
displayName = displayName!!,
description = description!!,
type = type!!,
token = token,
name = name,
displayName = displayName,
description = description,
type = type,
lastPing = lastPing,
participantType = participantType!!,
participantType = participantType,
hasPassword = hasPassword,
sessionId = sessionId!!,
actorId = actorId!!,
actorType = actorType!!,
sessionId = sessionId,
actorId = actorId,
actorType = actorType,
favorite = favorite,
lastActivity = lastActivity,
unreadMessages = unreadMessages,
unreadMention = unreadMention,
lastMessage = lastMessage?.let { LoganSquare.serialize(lastMessage) },
objectType = objectType!!,
notificationLevel = notificationLevel!!,
conversationReadOnlyState = conversationReadOnlyState!!,
lobbyState = lobbyState!!,
lobbyTimer = lobbyTimer!!,
objectType = objectType,
notificationLevel = notificationLevel,
conversationReadOnlyState = conversationReadOnlyState,
lobbyState = lobbyState,
lobbyTimer = lobbyTimer,
lastReadMessage = lastReadMessage,
lastCommonReadMessage = lastCommonReadMessage,
hasCall = hasCall,
callFlag = callFlag,
canStartCall = canStartCall,
canLeaveConversation = canLeaveConversation!!,
canDeleteConversation = canDeleteConversation!!,
unreadMentionDirect = unreadMentionDirect!!,
notificationCalls = notificationCalls!!,
canLeaveConversation = canLeaveConversation,
canDeleteConversation = canDeleteConversation,
unreadMentionDirect = unreadMentionDirect,
notificationCalls = notificationCalls,
permissions = permissions,
messageExpiration = messageExpiration,
status = status,
statusIcon = statusIcon,
statusMessage = statusMessage,
statusClearAt = statusClearAt,
callRecording = callRecording,
avatarVersion = avatarVersion!!,
hasCustomAvatar = hasCustomAvatar!!,
callStartTime = callStartTime!!,
avatarVersion = avatarVersion,
hasCustomAvatar = hasCustomAvatar,
callStartTime = callStartTime,
recordingConsentRequired = recordingConsentRequired,
remoteServer = remoteServer,
remoteToken = remoteToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.nextcloud.talk.models.json.participants.Participant
class ConversationModel(
var internalId: String,
var accountId: Long,
// var roomId: String? = null,
var token: String,
var name: String,
var displayName: String,
Expand Down Expand Up @@ -70,104 +69,59 @@ class ConversationModel(
return ConversationModel(
internalId = user.id!!.toString() + "@" + conversation.token,
accountId = user.id!!,
// roomId = conversation.roomId,
token = conversation.token!!,
name = conversation.name!!,
displayName = conversation.displayName!!,
description = conversation.description!!,
type = conversation.type.let { ConversationEnums.ConversationType.valueOf(it!!.name) },
token = conversation.token,
name = conversation.name,
displayName = conversation.displayName,
description = conversation.description,
type = conversation.type.let { ConversationEnums.ConversationType.valueOf(it.name) },
lastPing = conversation.lastPing,
participantType = conversation.participantType.let { Participant.ParticipantType.valueOf(it!!.name) },
participantType = conversation.participantType.let { Participant.ParticipantType.valueOf(it.name) },
hasPassword = conversation.hasPassword,
sessionId = conversation.sessionId!!,
actorId = conversation.actorId!!,
actorType = conversation.actorType!!,
sessionId = conversation.sessionId,
actorId = conversation.actorId,
actorType = conversation.actorType,
password = conversation.password,
favorite = conversation.favorite,
lastActivity = conversation.lastActivity,
unreadMessages = conversation.unreadMessages,
unreadMention = conversation.unreadMention,
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 {
ConversationEnums.NotificationLevel.valueOf(
it!!.name
it.name
)
},
conversationReadOnlyState = conversation.conversationReadOnlyState.let {
ConversationEnums.ConversationReadOnlyState.valueOf(
it!!.name
it.name
)
},
lobbyState = conversation.lobbyState.let { ConversationEnums.LobbyState.valueOf(it!!.name) },
lobbyTimer = conversation.lobbyTimer!!,
lobbyState = conversation.lobbyState.let { ConversationEnums.LobbyState.valueOf(it.name) },
lobbyTimer = conversation.lobbyTimer,
lastReadMessage = conversation.lastReadMessage,
lastCommonReadMessage = conversation.lastCommonReadMessage,
hasCall = conversation.hasCall,
callFlag = conversation.callFlag,
canStartCall = conversation.canStartCall,
canLeaveConversation = conversation.canLeaveConversation!!,
canDeleteConversation = conversation.canDeleteConversation!!,
unreadMentionDirect = conversation.unreadMentionDirect!!,
notificationCalls = conversation.notificationCalls!!,
canLeaveConversation = conversation.canLeaveConversation,
canDeleteConversation = conversation.canDeleteConversation,
unreadMentionDirect = conversation.unreadMentionDirect,
notificationCalls = conversation.notificationCalls,
permissions = conversation.permissions,
messageExpiration = conversation.messageExpiration,
status = conversation.status,
statusIcon = conversation.statusIcon,
statusMessage = conversation.statusMessage,
statusClearAt = conversation.statusClearAt,
callRecording = conversation.callRecording,
avatarVersion = conversation.avatarVersion!!,
hasCustomAvatar = conversation.hasCustomAvatar!!,
callStartTime = conversation.callStartTime!!,
avatarVersion = conversation.avatarVersion,
hasCustomAvatar = conversation.hasCustomAvatar,
callStartTime = conversation.callStartTime,
recordingConsentRequired = conversation.recordingConsentRequired,
remoteServer = conversation.remoteServer,
remoteToken = conversation.remoteToken
)
}
}
}

// enum class ConversationType {
// DUMMY,
// ROOM_TYPE_ONE_TO_ONE_CALL,
// ROOM_GROUP_CALL,
// ROOM_PUBLIC_CALL,
// ROOM_SYSTEM,
// FORMER_ONE_TO_ONE,
// NOTE_TO_SELF
// }
//
// enum class ParticipantType {
// DUMMY,
// OWNER,
// MODERATOR,
// USER,
// GUEST,
// USER_FOLLOWING_LINK,
// GUEST_MODERATOR
// }
//
// enum class ObjectType {
// DEFAULT,
// SHARE_PASSWORD,
// FILE,
// ROOM
// }
//
// enum class NotificationLevel {
// DEFAULT,
// ALWAYS,
// MENTION,
// NEVER
// }
//
// enum class ConversationReadOnlyState {
// CONVERSATION_READ_WRITE,
// CONVERSATION_READ_ONLY
// }
//
// enum class LobbyState {
// LOBBY_STATE_ALL_PARTICIPANTS,
// LOBBY_STATE_MODERATORS_ONLY
// }
Loading

0 comments on commit c89f620

Please sign in to comment.