Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: receive and store composite messages [part-1] #1888

Conversation

MohamadJaara
Copy link
Member

@MohamadJaara MohamadJaara commented Jul 16, 2023


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

kalium does not handle composite messages

Solutions

map composite messages from/to proto and store the content

composite messages have a list of items where each item can be either a Text message content (with mentions, quote, ...ect ) or a Button

I did take the assumption that there is at most one text content, since we do not support having multiple content from the same type for one messages.

i did also move the messages views to separate file since Messages.sq is getting too big for its own good

Needs releases with:

  • GitHub link to other pull request

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Briefly describe how this change was tested and if applicable the exact steps taken to verify that it works as expected.

Notes (Optional)

Specify here any other facts that you think are important for this issue.

Attachments (Optional)

Attachments like images, videos, etc. (drag and drop in the text box)


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

Comment on lines +204 to +205
is MessageContent.ButtonAction -> TODO()
is MessageContent.ButtonActionConfirmation -> TODO()
Copy link
Member Author

@MohamadJaara MohamadJaara Jul 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ButtonAction and ButtonActionConfirmation will be handled in a separate PR

@github-actions
Copy link
Contributor

github-actions bot commented Jul 16, 2023

Unit Test Results

   331 files   -   72     331 suites   - 72   18s ⏱️ - 1m 19s
1 858 tests  - 323  1 789 ✔️  - 294  69 💤  - 29  0 ±0 

Results for commit afc616f. ± Comparison against base commit abc276b.

♻️ This comment has been updated with latest results.

Comment on lines 314 to 316
sealed interface WithUser : MessagePreviewContent {
val username: String?
data class Text(override val username: String?, val messageBody: String?) : WithUser
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea here is composite messages preview are handled as text messages

@MohamadJaara MohamadJaara removed the WIP work in progress label Jul 17, 2023
@MohamadJaara MohamadJaara requested review from vitorhugods, a team, gongracr, yamilmedina, Garzas and saleniuk and removed request for a team July 17, 2023 08:02
Comment on lines -304 to 348
val senderName: String?,
override val username: String?,
val isSelfUserAdded: Boolean,
val otherUserIdList: List<UserId> // TODO add usernames
) : WithUser(senderName)
) : WithUser

data class MembersRemoved(
val senderName: String?,
override val username: String?,
val isSelfUserRemoved: Boolean,
val otherUserIdList: List<UserId> // TODO add usernames
) : WithUser(senderName)
) : WithUser

data class MembersFailedToAdd(
val senderName: String?,
override val username: String?,
val isSelfUserRemoved: Boolean,
val otherUserIdList: List<UserId> // TODO add usernames
) : WithUser(senderName)
) : WithUser

data class MembersCreationAdded(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those had duplicated fields, senderName and userName

@MohamadJaara MohamadJaara changed the title feat: recive and store composite messages feat: receive and store composite messages Jul 17, 2023
Copy link
Member

@vitorhugods vitorhugods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I believe just some small changes needed.

@MohamadJaara MohamadJaara changed the title feat: receive and store composite messages feat: receive and store composite messages [part-1] Jul 19, 2023
@@ -487,6 +490,37 @@ object MessageMapper {
restrictedAssetName.requireField("assetName")
)

MessageEntity.ContentType.COMPOSITE -> {
// if the text body is null then the composite message had no text body
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a local variable stating the above instead of a comment would be better here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already a local val
val compositeText: MessageEntityContent.Text? = text?.let {

the comment just so no body add a .requireField to the text content since it is fine if it is missing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that kind of obvious from not adding .requireField ? is this comment really necessary ? anyways a minor thing, do as you wish to not block it :P

Copy link
Contributor

@trOnk12 trOnk12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job ! Nothing major from my side, but I would like to have my comments resolved before u make the final call, but I already give the approval 🍖

@MohamadJaara MohamadJaara merged commit bbf47e8 into feat/composit_messages/epic Jul 19, 2023
9 checks passed
@MohamadJaara MohamadJaara deleted the feat/composit_messages/map_from_to_proto branch July 19, 2023 16:02
@MohamadJaara MohamadJaara mentioned this pull request Jul 24, 2023
8 tasks
tmspzz added a commit that referenced this pull request Jul 27, 2023
* feat: receive and store composite messages [part-1] (#1888)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* merge issues

* address PR comments

* address PR comments

* detekt

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* feat: use case to send Message Button Action [part-2] (#1896)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* feat: use case to execute composite message action

* expose use case to message scope

* missing param

* rename use case

* docs

* map to proto

* merge issues

* address PR comments

* address PR comments

* detekt

* sent the message only to the message original sender

* detekt

* Update logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/MessageMetaDataRepositoryTest.kt

Co-authored-by: Alexandre Ferris <[email protected]>

* PR comments

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Alexandre Ferris <[email protected]>

* feat: handle composite action confermation message [part-3] (#1901)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* feat: use case to execute composite message action

* expose use case to message scope

* missing param

* rename use case

* docs

* map to proto

* merge issues

* address PR comments

* address PR comments

* detekt

* handle ButtonActionConfirmation event

* add unit test

* detekt

* detekt

* sent the message only to the message original sender

* detekt

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* feat: composite message preview [part-4] (#1908)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* feat: use case to execute composite message action

* expose use case to message scope

* missing param

* rename use case

* docs

* map to proto

* merge issues

* address PR comments

* address PR comments

* detekt

* handle ButtonActionConfirmation event

* add unit test

* detekt

* detekt

* sent the message only to the message original sender

* detekt

* feat: map composite messages preview

* Update persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageMapper.kt

Co-authored-by: Alexandre Ferris <[email protected]>

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Alexandre Ferris <[email protected]>

* fix: composite messages are not included in the getLastMessages query [part-5] (#1909)

* include composite messages to message preview

* detekt

* feat: display composite message preview

* add test

* feat: composit messages backup [part-6] (#1914)

* fea: include message buttons into the backup

* import buttons

* merge issues

* unit test

* merge issues

* ignore Confirmation messages that are not fom the original message sender

* test

* cleanup

* detekt

* typo

* typo

* PR comments

* trigger CI

* empty

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Alexandre Ferris <[email protected]>
Co-authored-by: Tommaso Piazza <[email protected]>
borichellow added a commit that referenced this pull request Aug 3, 2023
* feat: receive and store composite messages [part-1] (#1888)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* merge issues

* address PR comments

* address PR comments

* detekt

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* feat: use case to send Message Button Action [part-2] (#1896)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* feat: use case to execute composite message action

* expose use case to message scope

* missing param

* rename use case

* docs

* map to proto

* merge issues

* address PR comments

* address PR comments

* detekt

* sent the message only to the message original sender

* detekt

* Update logic/src/commonTest/kotlin/com/wire/kalium/logic/data/message/MessageMetaDataRepositoryTest.kt

Co-authored-by: Alexandre Ferris <[email protected]>

* PR comments

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Alexandre Ferris <[email protected]>

* feat: handle composite action confermation message [part-3] (#1901)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* feat: use case to execute composite message action

* expose use case to message scope

* missing param

* rename use case

* docs

* map to proto

* merge issues

* address PR comments

* address PR comments

* detekt

* handle ButtonActionConfirmation event

* add unit test

* detekt

* detekt

* sent the message only to the message original sender

* detekt

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* feat: composite message preview [part-4] (#1908)

* receive composite messages

* map composite to proto

* detekt

* detekt

* db migration

* db migration

* sqm

* map to composite entity

* detekt

* remove is pending state from the DB

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* Update logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageContent.kt

Co-authored-by: Vitor Hugo Schwaab <[email protected]>

* address PR comments

* detekt

* remove composite message preview mapping

* fix migration

* feat: use case to execute composite message action

* expose use case to message scope

* missing param

* rename use case

* docs

* map to proto

* merge issues

* address PR comments

* address PR comments

* detekt

* handle ButtonActionConfirmation event

* add unit test

* detekt

* detekt

* sent the message only to the message original sender

* detekt

* feat: map composite messages preview

* Update persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageMapper.kt

Co-authored-by: Alexandre Ferris <[email protected]>

---------

Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Alexandre Ferris <[email protected]>

* fix: composite messages are not included in the getLastMessages query [part-5] (#1909)

* include composite messages to message preview

* detekt

* feat: display composite message preview

* add test

* feat: composit messages backup [part-6] (#1914)

* fea: include message buttons into the backup

* import buttons

* merge issues

* unit test

* merge issues

* ignore Confirmation messages that are not fom the original message sender

* test

* cleanup

* detekt

* typo

* typo

* PR comments

* feat: Get and save clients mlsPublicKeys

* feat: Get and save clients mlsPublicKeys: code stly

* feat: Get and save clients mlsPublicKeys: tests fix

* feat: Get and save clients mlsPublicKeys: removed logs

---------

Co-authored-by: Mohamad Jaara <[email protected]>
Co-authored-by: Vitor Hugo Schwaab <[email protected]>
Co-authored-by: Alexandre Ferris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants