-
Notifications
You must be signed in to change notification settings - Fork 11
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
support multiple pub keys per recipient #1523
support multiple pub keys per recipient #1523
Conversation
5c30eb9
to
589c384
Compare
b1ebbc3
to
b53ba16
Compare
@tomholub @IvanPizhenko It's ready for a review. Sorry, that is a huge and terrible PR. But I could not split it into a few smaller PRs. One thing relates to another one and so on. I had to change too many things. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you go.
General comment - the codebase is quite massive when I feel maybe less code could achieve the same thing. Often there are bits of functionality duplicated, like once suspend and once not, once xxxFlow and once not and so on. I hope, with some refactoring (not now) it could be streamlined. Else it will be a lot of work for you to make changes if many things are implemented twice to use in similar but a bit different ways.
...m/flowcrypt/email/ui/activity/ImportPgpContactActivityDisallowAttesterSearchForDomainTest.kt
Show resolved
Hide resolved
.../src/androidTest/java/com/flowcrypt/email/ui/activity/PreviewImportPgpContactActivityTest.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/PubKeyDao.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/ImportPublicKeyActivity.kt
Show resolved
Hide resolved
} else { | ||
//todo-denbond7 temporary disable updating | ||
button.gone() | ||
}/*else if (existingRecipientWithPubKeys.publicKeys.firstOrNull()?.fingerprint.isNullOrEmpty() | ||
|| keyDetails?.fingerprint?.equals( | ||
existingPgpContact.fingerprint!!, ignoreCase = true | ||
existingRecipientWithPubKeys.publicKeys.firstOrNull()?.fingerprint, ignoreCase = true | ||
) == true | ||
) { | ||
initUpdateContactButton(block, button) | ||
} else { | ||
initReplaceContactButton(block, button) | ||
} | ||
}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it should be similar to other places:
- if we already have this particular public key (by fingerprint) saved for this recipient, then we compare by last modified. If the one we already have is newer or same, we tell the user. If the received one is newer, we offer import (with "update")
- if we don't have that pubkey for this recipient by fingerprint, offer import (with "save")
So it's not firstOrNull
but we instead check if it's in the list, and then whether it's newer or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. It seems I've disabled some functionality in MessageDetailsFragment.kt
during migration and forgotten to fix it.(too many changes in this PR :( ) I have to fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please file a separate issue for the future to add a test for this. Since it could be disabled without noticing, it's not covered by any test.
/*button.setOnClickListener { v -> | ||
val RecipientWithPubKeys = block.keyDetails?.primaryRecipientWithPubKeys | ||
if (RecipientWithPubKeys != null) { | ||
recipientsViewModel.updateContact(RecipientWithPubKeys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus here
FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/base/CreateMessageFragment.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/ui/adapter/PgpContactAdapter.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per above
FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments. To say true, yes, it is really huge, and I don't have a lot to say here, since I'm not specialist in Android and not always get the rest of application logic. I've seen Tom made more meaningful comments.
FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/RecipientDao.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/RecipientDao.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/database/FlowCryptRoomDatabase.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/database/dao/RecipientDao.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/database/entity/PublicKeyEntity.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/sync/LoadRecipientsWorker.kt
Outdated
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/ImportPublicKeyActivity.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ParseAndSavePubKeysFragment.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ParseAndSavePubKeysFragment.kt
Show resolved
Hide resolved
FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/PublicKeyDetailsFragment.kt
Show resolved
Hide resolved
Let me explain why we have the following situation. It relates to the current situation in code:
a) we have the old code that uses standard Java Threads. That's why we have to have for example this method @Query("SELECT * FROM sqlite")
fun getRows(): List<Row> b) we have code that uses coroutines. It requires the following version. Usually, such methods are used to fetch some info once. Like finding some entity and so on. @Query("SELECT * FROM sqlite")
suspend fun getRows(): List<Row> c) we have code that uses coroutines and Flow. Usually, such methods are used to fetch some info and observe changes. Like fetching a list and receiving updates: insert, delete, update items. @Query("SELECT * FROM sqlite")
suspend fun getRowsFlow(): Flow<List<Row>> I agree that we should drop a) and migrate to use b) and c) depending on our needs. Just need to find some free time for that (between adding new functionality) :)) |
@IvanPizhenko @tomholub By the way, please mark a conversation as resolved if you don't have any other comments and it looks ok after my changes. It will help me to see what is already done and what I should fix. Thanks! |
…multiply_pub_keys_for_recipient # Conflicts: # FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ContactsViewModel.kt # FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/SelectRecipientsActivity.kt
I've resolved some that don't need any code change. But let's do it the other way - if you made a code change that you believe resolves our concern, then please mark it as resolved. All of the comments are quite minor and you are the primary person who interacts with this codebase, so it's the most important that it works for you rather than that it works for us (except for things that affect functionality directly, but I guess there weren't any this time). |
All good. I just wanted to make sure that we both don't like the situation. Yes, I know I haven't given you any time for refactoring lately. And it looks like there won't be any until at least February :-( |
because of #1550 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkpoint review - so far good
companion object { | ||
private const val SELECT_ALL_PUB_KEYS = "SELECT * FROM public_keys" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means in the future we may be doing this for all. But that's also for another issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
This PR added support multiple pub keys for recipient
close #1188
close #1539
close #1540
close #1541
close #1542
close #1566
close #1570
Tests (delete all except exactly one):
To be filled by reviewers
I have reviewed that this PR... (tick whichever items you personally focused on during this review):