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

Use the PublicKey type for public keys in the database #1291

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robinlinden
Copy link
Collaborator

No description provided.

atox/src/main/kotlin/ui/NotificationHelper.kt Fixed Show fixed Hide fixed
value class PublicKey(private val value: String) {
fun bytes() = hexToBytes(value)
fun string() = value
fun fingerprint() = value.take(8)

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
@@ -67,7 +67,7 @@ class OpenMultiplePersistableDocuments : ActivityResultContracts.OpenMultipleDoc
class ChatFragment : BaseFragment<FragmentChatBinding>(FragmentChatBinding::inflate) {
private val viewModel: ChatViewModel by viewModels { vmFactory }

private lateinit var contactPubKey: String
private var contactPubKey = PublicKey("")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit strange that the empty string is a valid public key, but ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, this one made me sad. No way to have a lateinit value class apparently. I'll clean these things up once I add a require in the PublicKey-ctor to require all pks to be valid pks. :/

@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2020 aTox contributors
// SPDX-FileCopyrightText: 2019-2025 Robin Lindén <dev@robinlinden.eu>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Only you now? :P no more contributors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it was always just me in this file, but I set all files to "aTox contributors" in the script that added them. :( I add back myself as I touch files.

This is in preparation of using it in the database types now that that
is a thing that's possible.
This means a lot of conversions go away.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants