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

Support enum with whitespaces #105

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,31 @@ data class Composer(
val startsThread: Boolean? = null,
) : VectorAnalyticsEvent {

enum class MessageType {
enum class MessageType(val rawValue: String) {
/**
* A pin drop location message.
*/
LocationPin,
LocationPin("LocationPin"),

/**
* A user current location message.
*/
LocationUser,
LocationUser("LocationUser"),

/**
* A poll message.
*/
Poll,
Poll("Poll"),

/**
* A text message.
*/
Text,
Text("Text"),

/**
* A voice message.
*/
VoiceMessage,
VoiceMessage("VoiceMessage"),
}

override fun getName() = "Composer"
Expand All @@ -83,7 +83,7 @@ data class Composer(
put("inThread", inThread)
put("isEditing", isEditing)
put("isReply", isReply)
put("messageType", messageType.name)
put("messageType", messageType.rawValue)
startsThread?.let { put("startsThread", it) }
}.takeIf { it.isNotEmpty() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,44 @@ data class CryptoSessionStateChange(
val verificationState: VerificationState,
) : VectorAnalyticsEvent {

enum class VerificationState {
enum class VerificationState(val rawValue: String) {
/**
* The device is unverified.
*/
NotVerified,
NotVerified("NotVerified"),

/**
* The device is considered to be verified, it has been signed by its
* user identity.
*/
Verified,
Verified("Verified"),
}

enum class RecoveryState {
enum class RecoveryState(val rawValue: String) {

/**
* No default secret storage key exists or it is disabled explicitly
* using the account data event.
*/
Disabled,
Disabled("Disabled"),

/**
* Secret storage is set up and we have all the secrets locally.
*/
Enabled,
Enabled("Enabled"),

/**
* Secret storage is set up but we're missing some secrets.
*/
Incomplete,
Incomplete("Incomplete"),
}

override fun getName() = "CryptoSessionState"

override fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
put("recoveryState", recoveryState.name)
put("verificationState", verificationState.name)
put("recoveryState", recoveryState.rawValue)
put("verificationState", verificationState.rawValue)
}.takeIf { it.isNotEmpty() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,118 +70,118 @@ data class Error(
val wasVisibleToUser: Boolean? = null,
) : VectorAnalyticsEvent {

enum class Domain {
E2EE,
TO_DEVICE,
VOIP,
enum class Domain(val rawValue: String) {
E2EE("E2EE"),
TO_DEVICE("TO_DEVICE"),
VOIP("VOIP"),
}

enum class Name {
enum class Name(val rawValue: String) {

/**
* E2EE domain error. Decryption failed for a message sent before you
* were in the room (shared history visibility and support for sharing
* past keys is not available/supported).
*/
ExpectedDueToMembership,
ExpectedDueToMembership("ExpectedDueToMembership"),

/**
* E2EE domain error. Decryption failed for a message sent before the
* device logged in, and key backup is not enabled.
*/
HistoricalMessage,
HistoricalMessage("HistoricalMessage"),

/**
* E2EE domain error. The room key is known but is ratcheted (index >
* 0).
*/
OlmIndexError,
OlmIndexError("OlmIndexError"),

/**
* E2EE domain error. Generic unknown inbound group session error.
*/
OlmKeysNotSentError,
OlmKeysNotSentError("OlmKeysNotSentError"),

/**
* E2EE domain error. Any other decryption error (missing field, format
* errors...).
*/
OlmUnspecifiedError,
OlmUnspecifiedError("OlmUnspecifiedError"),

/**
* TO_DEVICE domain error. The to-device message failed to decrypt.
*/
ToDeviceFailedToDecrypt,
ToDeviceFailedToDecrypt("ToDeviceFailedToDecrypt"),

/**
* E2EE domain error. Decryption failed due to unknown error.
*/
UnknownError,
UnknownError("UnknownError"),

/**
* VOIP domain error. ICE negotiation failed.
*/
VoipIceFailed,
VoipIceFailed("VoipIceFailed"),

/**
* VOIP domain error. ICE negotiation timed out.
*/
VoipIceTimeout,
VoipIceTimeout("VoipIceTimeout"),

/**
* VOIP domain error. The call invite timed out.
*/
VoipInviteTimeout,
VoipInviteTimeout("VoipInviteTimeout"),

/**
* VOIP domain error. The user hung up the call.
*/
VoipUserHangup,
VoipUserHangup("VoipUserHangup"),

/**
* VOIP domain error. The user's media failed to start.
*/
VoipUserMediaFailed,
VoipUserMediaFailed("VoipUserMediaFailed"),
}

enum class CryptoSDK {
enum class CryptoSDK(val rawValue: String) {

/**
* Legacy crypto backend specific to each platform.
*/
Legacy,
Legacy("Legacy"),

/**
* Cross-platform crypto backend written in Rust.
*/
Rust,
Rust("Rust"),
}

enum class CryptoModule {
enum class CryptoModule(val rawValue: String) {

/**
* Native / legacy crypto module specific to each platform.
*/
Native,
Native("Native"),

/**
* Shared / cross-platform crypto module written in Rust.
*/
Rust,
Rust("Rust"),
}

override fun getName() = "Error"

override fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
context?.let { put("context", it) }
cryptoModule?.let { put("cryptoModule", it.name) }
cryptoSDK?.let { put("cryptoSDK", it.name) }
put("domain", domain.name)
cryptoModule?.let { put("cryptoModule", it.rawValue) }
cryptoSDK?.let { put("cryptoSDK", it.rawValue) }
put("domain", domain.rawValue)
eventLocalAgeMillis?.let { put("eventLocalAgeMillis", it) }
isFederated?.let { put("isFederated", it) }
isMatrixDotOrg?.let { put("isMatrixDotOrg", it) }
put("name", name.name)
put("name", name.rawValue)
timeToDecryptMillis?.let { put("timeToDecryptMillis", it) }
userTrustsOwnIdentity?.let { put("userTrustsOwnIdentity", it) }
wasVisibleToUser?.let { put("wasVisibleToUser", it) }
Expand Down
Loading
Loading