From 52185b20c960dd1c832afa5b4f557d002ed620b6 Mon Sep 17 00:00:00 2001 From: Yamil Medina Date: Fri, 30 Aug 2024 07:35:53 -0400 Subject: [PATCH] feat: missing accent id for messages detail, reactions and receipts (WPB-1750) (#2980) * feat: missing accent id for messages detail, reactions and receipts * feat: tests * feat: tests --- .../kalium/logic/data/message/UserSummary.kt | 3 +- .../data/message/reaction/ReactionsMapper.kt | 6 ++- .../data/message/receipt/ReceiptsMapper.kt | 3 +- .../wire/kalium/logic/data/user/UserMapper.kt | 3 +- .../logic/data/message/ReactionsMapperTest.kt | 12 ++++-- .../message/receipt/ReceiptsMapperTest.kt | 6 ++- .../ObserveMessageReactionsUseCaseTest.kt | 3 +- .../ObserveMessageReceiptsUseCaseTest.kt | 3 +- .../com/wire/kalium/persistence/Reactions.sq | 3 +- .../com/wire/kalium/persistence/Receipts.sq | 3 +- .../src/commonMain/db_user/migrations/85.sqm | 41 +++++++++++++++++++ .../dao/reaction/ReactionMapper.kt | 3 +- .../dao/reaction/ReactionsEntity.kt | 3 +- .../dao/receipt/DetailedReceiptEntity.kt | 3 +- .../persistence/dao/receipt/ReceiptMapper.kt | 2 + 15 files changed, 79 insertions(+), 18 deletions(-) create mode 100644 persistence/src/commonMain/db_user/migrations/85.sqm diff --git a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/message/UserSummary.kt b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/message/UserSummary.kt index 9fcb19f0f22..419b9d502e8 100644 --- a/data/src/commonMain/kotlin/com/wire/kalium/logic/data/message/UserSummary.kt +++ b/data/src/commonMain/kotlin/com/wire/kalium/logic/data/message/UserSummary.kt @@ -31,5 +31,6 @@ data class UserSummary( val userType: UserType, val isUserDeleted: Boolean, val connectionStatus: ConnectionState, - val availabilityStatus: UserAvailabilityStatus + val availabilityStatus: UserAvailabilityStatus, + val accentId: Int ) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/reaction/ReactionsMapper.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/reaction/ReactionsMapper.kt index abc2ede9218..892b4c26511 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/reaction/ReactionsMapper.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/reaction/ReactionsMapper.kt @@ -53,7 +53,8 @@ internal class ReactionsMapperImpl( userTypeEntity = userType, deleted = deleted, connectionStatus = connectionStatus, - availabilityStatus = userAvailabilityStatus + availabilityStatus = userAvailabilityStatus, + accentId = accentId ) } @@ -71,7 +72,8 @@ internal class ReactionsMapperImpl( userType = domainUserTypeMapper.fromUserTypeEntity(userTypeEntity), isUserDeleted = deleted, connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus), - availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus) + availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus), + accentId = accentId ) ) } diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapper.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapper.kt index be3fd5a56ef..6aacce40d91 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapper.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapper.kt @@ -65,7 +65,8 @@ internal class ReceiptsMapperImpl( userType = domainUserTypeMapper.fromUserTypeEntity(userType), isUserDeleted = isUserDeleted, connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus), - availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus) + availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus), + accentId = accentId ) ) } diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/user/UserMapper.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/user/UserMapper.kt index 8210942369a..cd8398f0f5c 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/user/UserMapper.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/user/UserMapper.kt @@ -210,7 +210,8 @@ internal class UserMapperImpl( userType = domainUserTypeMapper.fromUserTypeEntity(userType), isUserDeleted = deleted, availabilityStatus = availabilityStatusMapper.fromDaoAvailabilityStatusToModel(availabilityStatus), - connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus) + connectionStatus = connectionStateMapper.fromDaoConnectionStateToUser(connectionStatus), + accentId = accentId ) } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/ReactionsMapperTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/ReactionsMapperTest.kt index 204d3fbad76..d8a70287f98 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/ReactionsMapperTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/ReactionsMapperTest.kt @@ -59,7 +59,8 @@ class ReactionsMapperTest { userType = UserTypeEntity.STANDARD, deleted = false, connectionStatus = ConnectionEntity.State.ACCEPTED, - userAvailabilityStatus = UserAvailabilityStatusEntity.NONE + userAvailabilityStatus = UserAvailabilityStatusEntity.NONE, + accentId = 0 ) val expectedMessageReactionEntity = MessageReactionEntity( @@ -71,7 +72,8 @@ class ReactionsMapperTest { userTypeEntity = UserTypeEntity.STANDARD, deleted = false, connectionStatus = ConnectionEntity.State.ACCEPTED, - availabilityStatus = UserAvailabilityStatusEntity.NONE + availabilityStatus = UserAvailabilityStatusEntity.NONE, + accentId = 0 ) val (_, reactionsMapper) = Arrangement() @@ -99,7 +101,8 @@ class ReactionsMapperTest { userTypeEntity = UserTypeEntity.STANDARD, deleted = false, connectionStatus = ConnectionEntity.State.ACCEPTED, - availabilityStatus = UserAvailabilityStatusEntity.NONE + availabilityStatus = UserAvailabilityStatusEntity.NONE, + accentId = 0 ) val expectedMessageReaction = MessageReaction( @@ -113,7 +116,8 @@ class ReactionsMapperTest { userType = UserType.INTERNAL, isUserDeleted = false, connectionStatus = ConnectionState.ACCEPTED, - availabilityStatus = UserAvailabilityStatus.NONE + availabilityStatus = UserAvailabilityStatus.NONE, + accentId = 0 ) ) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapperTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapperTest.kt index 4cbaf6517ef..27e82c06925 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapperTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/receipt/ReceiptsMapperTest.kt @@ -118,7 +118,8 @@ class ReceiptsMapperTest { isUserDeleted = false, connectionStatus = ConnectionEntity.State.ACCEPTED, availabilityStatus = UserAvailabilityStatusEntity.NONE, - date = date + date = date, + accentId = 0 ) val expectedDetailedReceipt = DetailedReceipt( @@ -132,7 +133,8 @@ class ReceiptsMapperTest { userType = UserType.INTERNAL, isUserDeleted = false, connectionStatus = ConnectionState.ACCEPTED, - availabilityStatus = UserAvailabilityStatus.NONE + availabilityStatus = UserAvailabilityStatus.NONE, + accentId = 0 ) ) diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReactionsUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReactionsUseCaseTest.kt index 26349a9e121..c3faa94f32d 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReactionsUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReactionsUseCaseTest.kt @@ -92,7 +92,8 @@ class ObserveMessageReactionsUseCaseTest { userType = UserType.INTERNAL, isUserDeleted = false, connectionStatus = ConnectionState.ACCEPTED, - availabilityStatus = UserAvailabilityStatus.NONE + availabilityStatus = UserAvailabilityStatus.NONE, + accentId = 0 ) ) } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReceiptsUseCaseTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReceiptsUseCaseTest.kt index 37ef8917ea7..cb6e591edcf 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReceiptsUseCaseTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/message/ObserveMessageReceiptsUseCaseTest.kt @@ -114,7 +114,8 @@ class ObserveMessageReceiptsUseCaseTest { userType = UserType.INTERNAL, isUserDeleted = false, connectionStatus = ConnectionState.ACCEPTED, - availabilityStatus = UserAvailabilityStatus.NONE + availabilityStatus = UserAvailabilityStatus.NONE, + accentId = 0 ) ) } diff --git a/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Reactions.sq b/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Reactions.sq index 3aac7289142..50e7c3a23bb 100644 --- a/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Reactions.sq +++ b/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Reactions.sq @@ -44,7 +44,8 @@ AS SELECT User.user_type AS userType, User.deleted, User.connection_status AS connectionStatus, - User.user_availability_status AS userAvailabilityStatus + User.user_availability_status AS userAvailabilityStatus, + User.accent_id AS accentId FROM Reaction INNER JOIN User ON User.qualified_id = Reaction.sender_id diff --git a/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Receipts.sq b/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Receipts.sq index c416f0c61ea..4476c480f7c 100644 --- a/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Receipts.sq +++ b/persistence/src/commonMain/db_user/com/wire/kalium/persistence/Receipts.sq @@ -45,7 +45,8 @@ AS SELECT User.user_type AS userType, User.deleted AS isUserDeleted, User.connection_status AS connectionStatus, - User.user_availability_status AS userAvailabilityStatus + User.user_availability_status AS userAvailabilityStatus, + User.accent_id AS accentId FROM Receipt INNER JOIN User ON User.qualified_id = Receipt.user_id diff --git a/persistence/src/commonMain/db_user/migrations/85.sqm b/persistence/src/commonMain/db_user/migrations/85.sqm new file mode 100644 index 00000000000..34dbb0c0089 --- /dev/null +++ b/persistence/src/commonMain/db_user/migrations/85.sqm @@ -0,0 +1,41 @@ +DROP VIEW IF EXISTS ReceiptDetails; +DROP VIEW IF EXISTS MessageDetailsReactions; + +CREATE VIEW IF NOT EXISTS ReceiptDetails +AS SELECT + Receipt.type, + Receipt.date, + Receipt.message_id AS messageId, + Receipt.conversation_id AS conversationId, + User.qualified_id AS userId, + User.name AS userName, + User.handle AS userHandle, + User.preview_asset_id AS previewAssetId, + User.user_type AS userType, + User.deleted AS isUserDeleted, + User.connection_status AS connectionStatus, + User.user_availability_status AS userAvailabilityStatus, + User.accent_id AS accentId +FROM + Receipt +INNER JOIN User ON User.qualified_id = Receipt.user_id +ORDER BY User.name; + +CREATE VIEW IF NOT EXISTS MessageDetailsReactions +AS SELECT + Reaction.emoji, + Reaction.message_id AS messageId, + Reaction.conversation_id AS conversationId, + User.qualified_id AS userId, + User.name, + User.handle, + User.preview_asset_id AS previewAssetId, + User.user_type AS userType, + User.deleted, + User.connection_status AS connectionStatus, + User.user_availability_status AS userAvailabilityStatus, + User.accent_id AS accentId +FROM + Reaction +INNER JOIN User ON User.qualified_id = Reaction.sender_id +ORDER BY Reaction.emoji; diff --git a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionMapper.kt b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionMapper.kt index bdba6a14519..545fa92cf48 100644 --- a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionMapper.kt +++ b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionMapper.kt @@ -46,7 +46,8 @@ object ReactionMapper { userTypeEntity = userType, deleted = deleted, connectionStatus = connectionStatus, - availabilityStatus = userAvailabilityStatus + availabilityStatus = userAvailabilityStatus, + accentId = accentId ) } } diff --git a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionsEntity.kt b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionsEntity.kt index 227afb0a3df..a6bd98adbd1 100644 --- a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionsEntity.kt +++ b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/reaction/ReactionsEntity.kt @@ -41,7 +41,8 @@ data class MessageReactionEntity( val userTypeEntity: UserTypeEntity, val deleted: Boolean, val connectionStatus: ConnectionEntity.State, - val availabilityStatus: UserAvailabilityStatusEntity + val availabilityStatus: UserAvailabilityStatusEntity, + val accentId: Int ) typealias ReactionsCountEntity = Map diff --git a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/DetailedReceiptEntity.kt b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/DetailedReceiptEntity.kt index 48637ea8867..8e64740e2a0 100644 --- a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/DetailedReceiptEntity.kt +++ b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/DetailedReceiptEntity.kt @@ -34,5 +34,6 @@ data class DetailedReceiptEntity( val userType: UserTypeEntity, val isUserDeleted: Boolean, val connectionStatus: ConnectionEntity.State, - val availabilityStatus: UserAvailabilityStatusEntity + val availabilityStatus: UserAvailabilityStatusEntity, + val accentId: Int ) diff --git a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/ReceiptMapper.kt b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/ReceiptMapper.kt index 8b110bd6797..379ce1281bd 100644 --- a/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/ReceiptMapper.kt +++ b/persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/receipt/ReceiptMapper.kt @@ -40,6 +40,7 @@ internal object ReceiptMapper { isUserDeleted: Boolean, connectionStatus: ConnectionEntity.State, userAvailabilityStatus: UserAvailabilityStatusEntity, + accentId: Int ) = DetailedReceiptEntity( type = type, date = Instant.parse(date), @@ -51,5 +52,6 @@ internal object ReceiptMapper { isUserDeleted = isUserDeleted, connectionStatus = connectionStatus, availabilityStatus = userAvailabilityStatus, + accentId = accentId ) }