Skip to content

Commit

Permalink
Add user property
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed May 6, 2024
1 parent de5623e commit 0c24da0
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ data class CryptoSessionState(
*/
NotVerified,

/**
* The state is unknown for now.
*/
Unknown,

/**
* The device is considered to be verified, it has been signed by its
* user identity.
Expand All @@ -65,11 +60,6 @@ data class CryptoSessionState(
* Secret storage is set up but we're missing some secrets.
*/
Incomplete,

/**
* The state is unknown for now.
*/
Unknown,
}

override fun getName() = "CryptoSessionState"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ data class UserProperties(
* Number of spaces (and sub-spaces) the user is joined to.
*/
val numSpaces: Int? = null,
val recoveryState: RecoveryState? = null,
val verificationState: VerificationState? = null,
) {

enum class FtueUseCaseSelection {
Expand Down Expand Up @@ -87,12 +89,47 @@ data class UserProperties(
Unreads,
}

enum class VerificationState {

/**
* The device is unverified.
*/
NotVerified,

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

enum class RecoveryState {

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

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

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

fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
allChatsActiveFilter?.let { put("allChatsActiveFilter", it.name) }
ftueUseCaseSelection?.let { put("ftueUseCaseSelection", it.name) }
numFavouriteRooms?.let { put("numFavouriteRooms", it) }
numSpaces?.let { put("numSpaces", it) }
recoveryState?.let { put("recoveryState", it.name) }
verificationState?.let { put("verificationState", it.name) }
}.takeIf { it.isNotEmpty() }
}
}
2 changes: 0 additions & 2 deletions schemas/CryptoSessionState.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
"verificationState": {
"type": "string",
"oneOf": [
{"const": "Unknown", "description": "The state is unknown for now."},
{"const": "Verified", "description": "The device is considered to be verified, it has been signed by its user identity."},
{"const": "NotVerified", "description": "The device is unverified."}
]
},
"recoveryState": {
"type": "string",
"oneOf": [
{"const": "Unknown", "description": "The state is unknown for now."},
{"const": "Enabled", "description": "Secret storage is set up and we have all the secrets locally."},
{"const": "Disabled", "description": "No default secret storage key exists or it is disabled explicitly using the account data event."},
{"const": "Incomplete", "description": "Secret storage is set up but we're missing some secrets."}
Expand Down
15 changes: 15 additions & 0 deletions schemas/UserProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@
{"const": "Group", "description": "Modern layout."},
{"const": "Compact", "description": "Modern layout with compact option enabled."}
]
},
"verificationState": {
"type": "string",
"oneOf": [
{"const": "Verified", "description": "The device is considered to be verified, it has been signed by its user identity."},
{"const": "NotVerified", "description": "The device is unverified."}
]
},
"recoveryState": {
"type": "string",
"oneOf": [
{"const": "Enabled", "description": "Secret storage is set up and we have all the secrets locally."},
{"const": "Disabled", "description": "No default secret storage key exists or it is disabled explicitly using the account data event."},
{"const": "Incomplete", "description": "Secret storage is set up but we're missing some secrets."}
]
}
},
"required": [],
Expand Down
4 changes: 0 additions & 4 deletions types/swift/CryptoSessionState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ extension AnalyticsEvent {
public enum VerificationState: String {
/// The device is unverified.
case NotVerified
/// The state is unknown for now.
case Unknown
/// The device is considered to be verified, it has been signed by its user identity.
case Verified
}
Expand All @@ -48,8 +46,6 @@ extension AnalyticsEvent {
case Enabled
/// Secret storage is set up but we're missing some secrets.
case Incomplete
/// The state is unknown for now.
case Unknown
}

public var properties: [String: Any] {
Expand Down
26 changes: 24 additions & 2 deletions types/swift/UserProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ extension AnalyticsEvent {
public let numFavouriteRooms: Int?
/// Number of spaces (and sub-spaces) the user is joined to.
public let numSpaces: Int?
public let recoveryState: RecoveryState?
public let verificationState: VerificationState?

public init(allChatsActiveFilter: AllChatsActiveFilter?, ftueUseCaseSelection: FtueUseCaseSelection?, numFavouriteRooms: Int?, numSpaces: Int?) {
public init(allChatsActiveFilter: AllChatsActiveFilter?, ftueUseCaseSelection: FtueUseCaseSelection?, numFavouriteRooms: Int?, numSpaces: Int?, recoveryState: RecoveryState?, verificationState: VerificationState?) {
self.allChatsActiveFilter = allChatsActiveFilter
self.ftueUseCaseSelection = ftueUseCaseSelection
self.numFavouriteRooms = numFavouriteRooms
self.numSpaces = numSpaces
self.recoveryState = recoveryState
self.verificationState = verificationState
}

public enum FtueUseCaseSelection: String {
Expand All @@ -61,12 +65,30 @@ extension AnalyticsEvent {
case Unreads
}

public enum VerificationState: String {
/// The device is unverified.
case NotVerified
/// The device is considered to be verified, it has been signed by its user identity.
case Verified
}

public enum RecoveryState: String {
/// No default secret storage key exists or it is disabled explicitly using the account data event.
case Disabled
/// Secret storage is set up and we have all the secrets locally.
case Enabled
/// Secret storage is set up but we're missing some secrets.
case Incomplete
}

public var properties: [String: Any?] {
return [
"allChatsActiveFilter": allChatsActiveFilter?.rawValue,
"ftueUseCaseSelection": ftueUseCaseSelection?.rawValue,
"numFavouriteRooms": numFavouriteRooms,
"numSpaces": numSpaces
"numSpaces": numSpaces,
"recoveryState": recoveryState?.rawValue,
"verificationState": verificationState?.rawValue
]
}
}
Expand Down

0 comments on commit 0c24da0

Please sign in to comment.