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: Update conversation Proteus verification status (WPB-1789) #2157

Merged

Conversation

borichellow
Copy link
Contributor

What's new in this PR?

Issues

When all the clients that belong to conversation are Proteus-verified, such a conversation should become a "Proteus verified" + need to add SystemMessage to that conversation informing user that conversation is Verified.

  • the same flow when conversation becomes "Proteus degraded".

Solutions

  1. update Conversation DB: add column proteus_verification_status
  2. update Conversation DB: add select method for getting conversationID with current proteus_verification_status and if that conversation should be verified
  3. update UpdateClientVerificationStatusUseCase to use select from #2, update conversations if needed and add SystemMessages to it.

Needs releases with:

  • GitHub link to other pull request

@CLAassistant
Copy link

CLAassistant commented Oct 19, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2023

Unit Test Results

       2 files   - 461         2 suites   - 461   3m 55s ⏱️ +21s
2 216 tests  - 362  2 209 ✔️  - 265  7 💤  - 97  0 ±0 

Results for commit 4f9df40. ± Comparison against base commit 2fb391f.

♻️ This comment has been updated with latest results.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Oct 20, 2023

Datadog Report

Branch report: feat/update_conversation_proteus_verification_status
Commit report: 5b114d6

kalium-jvm: 0 Failed, 0 New Flaky, 1 Passed, 0 Skipped, 2.02s Wall Time

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2023

Codecov Report

Merging #2157 (4f9df40) into develop (2fb391f) will decrease coverage by 0.01%.
The diff coverage is 50.81%.

@@              Coverage Diff              @@
##             develop    #2157      +/-   ##
=============================================
- Coverage      57.98%   57.97%   -0.01%     
  Complexity        21       21              
=============================================
  Files           1064     1064              
  Lines          40319    40414      +95     
  Branches        3733     3738       +5     
=============================================
+ Hits           23377    23430      +53     
- Misses         15330    15372      +42     
  Partials        1612     1612              
Files Coverage Δ
...ire/kalium/logic/data/conversation/Conversation.kt 90.96% <100.00%> (+0.11%) ⬆️
...lium/logic/data/conversation/ConversationMapper.kt 59.13% <100.00%> (+0.55%) ⬆️
...otlin/com/wire/kalium/logic/data/web/WebMappers.kt 37.30% <100.00%> (+0.50%) ⬆️
...ion/MLSConversationsVerificationStatusesHandler.kt 97.36% <100.00%> (ø)
...um/persistence/dao/conversation/ConversationDAO.kt 100.00% <ø> (ø)
...persistence/dao/conversation/ConversationEntity.kt 98.24% <100.00%> (+0.03%) ⬆️
...persistence/dao/conversation/ConversationMapper.kt 98.91% <100.00%> (+0.02%) ⬆️
...istence/dao/conversation/ConversationViewEntity.kt 97.77% <100.00%> (+0.05%) ⬆️
...tlin/com/wire/kalium/persistence/db/TableMapper.kt 100.00% <100.00%> (ø)
.../logic/data/conversation/ConversationRepository.kt 60.74% <0.00%> (ø)
... and 8 more

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fb391f...4f9df40. Read the comment docs.

@@ -269,6 +275,11 @@ data class Conversation(
)
}

data class ProteusVerificationData(
val conversationId: ConversationId,
val currentVerificationStatus: VerificationStatus,
Copy link
Member

Choose a reason for hiding this comment

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

suggestion:

Suggested change
val currentVerificationStatus: VerificationStatus,
val verificationStatus: VerificationStatus,

data class ProteusVerificationData(
val conversationId: ConversationId,
val currentVerificationStatus: VerificationStatus,
val isActuallyVerified: Boolean
Copy link
Member

Choose a reason for hiding this comment

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

question: what does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

conversationId is conversationId, currentVerificationStatus is the verification status of the conversation that is currently stored in DB, isActuallyVerified Boolean if the conversation actually should be verified or not (calculated by checking all the clients of the conversation).
It's a good idea to add some docs :)

Copy link
Member

Choose a reason for hiding this comment

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

so isn't better to store the new updated value then return the aggregated value? still I think it's confusing that we're returning two values that one is kinda out dated.

@@ -281,6 +281,14 @@ interface ConversationRepository {
* @return **true** if the protocol was changed or **false** if the protocol was unchanged.
*/
suspend fun updateProtocolLocally(conversationId: ConversationId, protocol: Conversation.Protocol): Either<CoreFailure, Boolean>

suspend fun getConversationsProteusVerificationDataByClientId(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
suspend fun getConversationsProteusVerificationDataByClientId(
suspend fun getConversationsProteusVerificationData(

clientId: ClientId
): Either<StorageFailure, List<Conversation.ProteusVerificationData>>

suspend fun updateProteusVerificationStatuses(
Copy link
Member

@mchenani mchenani Oct 20, 2023

Choose a reason for hiding this comment

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

nitpicking: https://www.grammar-monster.com/plurals/plural_of_status.htm#:~:text=The%20plural%20of%20%22status%22%20is,statuses%22%20since%20the%201960s.)

Suggested change
suspend fun updateProteusVerificationStatuses(
suspend fun updateProteusVerificationStatus(

@@ -51,7 +51,8 @@ SELECT
user_message_timer,
archived,
archived_date_time,
verification_status
verification_status,
Copy link
Member

Choose a reason for hiding this comment

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

tbh storing the mls verification status for members doesn't make sense. why we need it? it's already in the CoreCrypto we only need to fetch it. keeping it up to dated is risky.

Copy link
Member

@mchenani mchenani left a comment

Choose a reason for hiding this comment

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

I how two concerns, please review and if necessary we can sync online.

@@ -79,3 +79,32 @@ SELECT *
WHERE user_id IN
(SELECT user FROM Member WHERE conversation = :conversation_id AND user_id IN :userIdList)
AND is_valid = 1;

CREATE TRIGGER updateConversationProteusVerificationStatus
Copy link
Member

Choose a reason for hiding this comment

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

🤘🙌🔥

@@ -400,3 +403,25 @@ DELETE FROM Message WHERE conversation_id = :conversationId;

selectChanges:
SELECT changes();

CREATE TRIGGER addMessageAfterProteusVerificationStatusChange
Copy link
Member

Choose a reason for hiding this comment

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

🔥

Copy link
Member

@mchenani mchenani left a comment

Choose a reason for hiding this comment

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

Great work man, awesome 🤩 🔥

@borichellow borichellow added this pull request to the merge queue Oct 27, 2023
Merged via the queue into develop with commit 07301bd Oct 27, 2023
16 of 17 checks passed
@borichellow borichellow deleted the feat/update_conversation_proteus_verification_status branch October 27, 2023 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants