mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-29 07:38:54 +00:00
rename types
This commit is contained in:
@@ -972,8 +972,8 @@ enum ChatResponse2: Decodable, ChatAPIResult {
|
||||
case membersRoleUser(user: UserRef, groupInfo: GroupInfo, members: [GroupMember], toRole: GroupMemberRole)
|
||||
case membersBlockedForAllUser(user: UserRef, groupInfo: GroupInfo, members: [GroupMember], blocked: Bool)
|
||||
case groupUpdated(user: UserRef, toGroup: GroupInfo)
|
||||
case contactNameVerified(user: UserRef, contact: Contact, verificationFailure: String?)
|
||||
case groupNameVerified(user: UserRef, groupInfo: GroupInfo, verificationFailure: String?)
|
||||
case contactDomainVerified(user: UserRef, contact: Contact, verificationFailure: String?)
|
||||
case groupDomainVerified(user: UserRef, groupInfo: GroupInfo, verificationFailure: String?)
|
||||
case groupLinkCreated(user: UserRef, groupInfo: GroupInfo, groupLink: GroupLink)
|
||||
case groupLink(user: UserRef, groupInfo: GroupInfo, groupLink: GroupLink)
|
||||
case groupLinkDeleted(user: UserRef, groupInfo: GroupInfo)
|
||||
@@ -1029,8 +1029,8 @@ enum ChatResponse2: Decodable, ChatAPIResult {
|
||||
case .membersRoleUser: "membersRoleUser"
|
||||
case .membersBlockedForAllUser: "membersBlockedForAllUser"
|
||||
case .groupUpdated: "groupUpdated"
|
||||
case .contactNameVerified: "contactNameVerified"
|
||||
case .groupNameVerified: "groupNameVerified"
|
||||
case .contactDomainVerified: "contactDomainVerified"
|
||||
case .groupDomainVerified: "groupDomainVerified"
|
||||
case .groupLinkCreated: "groupLinkCreated"
|
||||
case .groupLink: "groupLink"
|
||||
case .groupLinkDeleted: "groupLinkDeleted"
|
||||
@@ -1082,8 +1082,8 @@ enum ChatResponse2: Decodable, ChatAPIResult {
|
||||
case let .membersRoleUser(u, groupInfo, members, toRole): return withUser(u, "groupInfo: \(groupInfo)\nmembers: \(members)\ntoRole: \(toRole)")
|
||||
case let .membersBlockedForAllUser(u, groupInfo, members, blocked): return withUser(u, "groupInfo: \(groupInfo)\nmember: \(members)\nblocked: \(blocked)")
|
||||
case let .groupUpdated(u, toGroup): return withUser(u, String(describing: toGroup))
|
||||
case let .contactNameVerified(u, contact, verificationFailure): return withUser(u, "contact: \(contact)\nverificationFailure: \(verificationFailure ?? "ok")")
|
||||
case let .groupNameVerified(u, groupInfo, verificationFailure): return withUser(u, "groupInfo: \(groupInfo)\nverificationFailure: \(verificationFailure ?? "ok")")
|
||||
case let .contactDomainVerified(u, contact, verificationFailure): return withUser(u, "contact: \(contact)\nverificationFailure: \(verificationFailure ?? "ok")")
|
||||
case let .groupDomainVerified(u, groupInfo, verificationFailure): return withUser(u, "groupInfo: \(groupInfo)\nverificationFailure: \(verificationFailure ?? "ok")")
|
||||
case let .groupLinkCreated(u, groupInfo, groupLink): return withUser(u, "groupInfo: \(groupInfo)\ngroupLink: \(groupLink)")
|
||||
case let .groupLink(u, groupInfo, groupLink): return withUser(u, "groupInfo: \(groupInfo)\ngroupLink: \(groupLink)")
|
||||
case let .groupLinkDeleted(u, groupInfo): return withUser(u, String(describing: groupInfo))
|
||||
|
||||
@@ -1083,7 +1083,7 @@ private func apiConnectResponseAlert<R>(_ r: APIResult<R>) -> Alert {
|
||||
title: "Unsupported connection link",
|
||||
message: "This link requires a newer app version. Please upgrade the app or ask your contact to send a compatible link."
|
||||
)
|
||||
case let .error(.simplexDomain(domain, err)):
|
||||
case let .error(.simplexDomainNotReady(domain, err)):
|
||||
switch err {
|
||||
case .noValidLink:
|
||||
mkAlert(
|
||||
@@ -1368,7 +1368,7 @@ func apiSetProfileAddress(on: Bool) async throws -> User? {
|
||||
// name is the encoded SimplexName (e.g. "@alice.simplex"); nil clears it
|
||||
// owner-specific SNENoValidLink wording; everything else reuses the general apiConnectResponseAlert
|
||||
func showSetSimplexNameError<R>(_ r: APIResult<R>, isChannel: Bool) {
|
||||
if case let .error(.simplexDomain(domain, .noValidLink)) = r.unexpected {
|
||||
if case let .error(.simplexDomainNotReady(domain, .noValidLink)) = r.unexpected {
|
||||
let format = isChannel
|
||||
? NSLocalizedString("The SimpleX name #%@ is registered without channel link. Add channel link to the name via the registration page.", comment: "alert message")
|
||||
: NSLocalizedString("The SimpleX name @%@ is registered without SimpleX address. Add your SimpleX address to the name via the registration page.", comment: "alert message")
|
||||
@@ -1392,13 +1392,13 @@ func apiSetUserDomain(_ simplexDomain: String?) async throws -> User {
|
||||
|
||||
func apiVerifyContactDomain(_ contactId: Int64) async throws -> (Contact, String?) {
|
||||
let r: ChatResponse2 = try await chatSendCmd(.apiVerifyContactDomain(contactId: contactId))
|
||||
if case let .contactNameVerified(_, contact, verificationFailure) = r { return (contact, verificationFailure) }
|
||||
if case let .contactDomainVerified(_, contact, verificationFailure) = r { return (contact, verificationFailure) }
|
||||
throw r.unexpected
|
||||
}
|
||||
|
||||
func apiVerifyGroupDomain(_ groupId: Int64) async throws -> (GroupInfo, String?) {
|
||||
let r: ChatResponse2 = try await chatSendCmd(.apiVerifyGroupDomain(groupId: groupId))
|
||||
if case let .groupNameVerified(_, groupInfo, verificationFailure) = r { return (groupInfo, verificationFailure) }
|
||||
if case let .groupDomainVerified(_, groupInfo, verificationFailure) = r { return (groupInfo, verificationFailure) }
|
||||
throw r.unexpected
|
||||
}
|
||||
|
||||
|
||||
@@ -758,7 +758,7 @@ public enum ChatErrorType: Decodable, Hashable {
|
||||
case chatNotStopped
|
||||
case chatStoreChanged
|
||||
case invalidConnReq
|
||||
case simplexDomain(simplexDomain: SimplexDomain, simplexDomainError: SimplexDomainError)
|
||||
case simplexDomainNotReady(simplexDomain: SimplexDomain, simplexDomainError: SimplexDomainError)
|
||||
case unsupportedConnReq
|
||||
case invalidChatMessage(connection: Connection, message: String)
|
||||
case connReqMessageProhibited
|
||||
|
||||
+2
-2
@@ -4923,9 +4923,9 @@ enum class SimplexNameType {
|
||||
// peer's signed name claim; UI only checks presence
|
||||
@Serializable
|
||||
data class SimplexDomainProof(
|
||||
val linkOwnerId: String? = null,
|
||||
val presHeader: String,
|
||||
val signature: String,
|
||||
val linkOwnerId: String? = null
|
||||
val signature: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
+13
-13
@@ -1558,7 +1558,7 @@ object ChatController {
|
||||
)
|
||||
}
|
||||
r is API.Error && r.err is ChatError.ChatErrorChat
|
||||
&& r.err.errorType is ChatErrorType.CESimplexDomain -> {
|
||||
&& r.err.errorType is ChatErrorType.SimplexDomainNotReady -> {
|
||||
val domain = r.err.errorType.simplexDomain.fullDomainName
|
||||
if (r.err.errorType.simplexDomainError is SimplexDomainError.NoValidLink) {
|
||||
AlertManager.shared.showAlertMsg(
|
||||
@@ -1631,7 +1631,7 @@ object ChatController {
|
||||
|
||||
// owner-specific wording for setting one's own/channel name; null for other errors (handled by apiConnectResponseAlert)
|
||||
fun simplexNameOwnerError(err: ChatError, isChannel: Boolean): String? =
|
||||
if (err is ChatError.ChatErrorChat && err.errorType is ChatErrorType.CESimplexDomain && err.errorType.simplexDomainError is SimplexDomainError.NoValidLink) {
|
||||
if (err is ChatError.ChatErrorChat && err.errorType is ChatErrorType.SimplexDomainNotReady && err.errorType.simplexDomainError is SimplexDomainError.NoValidLink) {
|
||||
val domain = err.errorType.simplexDomain.fullDomainName
|
||||
if (isChannel) generalGetString(MR.strings.simplex_name_owner_no_channel_link).format(domain)
|
||||
else generalGetString(MR.strings.simplex_name_owner_no_address).format(domain)
|
||||
@@ -1642,7 +1642,7 @@ object ChatController {
|
||||
generalGetString(MR.strings.invalid_connection_link)
|
||||
e is ChatError.ChatErrorChat && e.errorType is ChatErrorType.UnsupportedConnReq ->
|
||||
generalGetString(MR.strings.unsupported_connection_link)
|
||||
e is ChatError.ChatErrorChat && e.errorType is ChatErrorType.CESimplexDomain ->
|
||||
e is ChatError.ChatErrorChat && e.errorType is ChatErrorType.SimplexDomainNotReady ->
|
||||
if (e.errorType.simplexDomainError is SimplexDomainError.NoValidLink)
|
||||
generalGetString(MR.strings.simplex_name_no_valid_link)
|
||||
else generalGetString(MR.strings.simplex_name_unconfirmed)
|
||||
@@ -1842,14 +1842,14 @@ object ChatController {
|
||||
|
||||
suspend fun apiVerifyContactDomain(rh: Long?, contactId: Long): Pair<Contact, String?>? {
|
||||
val r = sendCmd(rh, CC.ApiVerifyContactDomain(contactId))
|
||||
if (r is API.Result && r.res is CR.ContactNameVerified) return r.res.contact to r.res.verificationFailure
|
||||
if (r is API.Result && r.res is CR.ContactDomainVerified) return r.res.contact to r.res.verificationFailure
|
||||
Log.e(TAG, "apiVerifyContactDomain bad response: ${r.responseType} ${r.details}")
|
||||
return null
|
||||
}
|
||||
|
||||
suspend fun apiVerifyGroupDomain(rh: Long?, groupId: Long): Pair<GroupInfo, String?>? {
|
||||
val r = sendCmd(rh, CC.ApiVerifyGroupDomain(groupId))
|
||||
if (r is API.Result && r.res is CR.GroupNameVerified) return r.res.groupInfo to r.res.verificationFailure
|
||||
if (r is API.Result && r.res is CR.GroupDomainVerified) return r.res.groupInfo to r.res.verificationFailure
|
||||
Log.e(TAG, "apiVerifyGroupDomain bad response: ${r.responseType} ${r.details}")
|
||||
return null
|
||||
}
|
||||
@@ -6591,8 +6591,8 @@ sealed class CR {
|
||||
@Serializable @SerialName("joinedGroupMember") class JoinedGroupMember(val user: UserRef, val groupInfo: GroupInfo, val member: GroupMember): CR()
|
||||
@Serializable @SerialName("connectedToGroupMember") class ConnectedToGroupMember(val user: UserRef, val groupInfo: GroupInfo, val member: GroupMember, val memberContact: Contact? = null): CR()
|
||||
@Serializable @SerialName("groupUpdated") class GroupUpdated(val user: UserRef, val toGroup: GroupInfo): CR()
|
||||
@Serializable @SerialName("contactNameVerified") class ContactNameVerified(val user: UserRef, val contact: Contact, val verificationFailure: String? = null): CR()
|
||||
@Serializable @SerialName("groupNameVerified") class GroupNameVerified(val user: UserRef, val groupInfo: GroupInfo, val verificationFailure: String? = null): CR()
|
||||
@Serializable @SerialName("contactDomainVerified") class ContactDomainVerified(val user: UserRef, val contact: Contact, val verificationFailure: String? = null): CR()
|
||||
@Serializable @SerialName("groupDomainVerified") class GroupDomainVerified(val user: UserRef, val groupInfo: GroupInfo, val verificationFailure: String? = null): CR()
|
||||
@Serializable @SerialName("groupLinkDataUpdated") class GroupLinkDataUpdated(val user: UserRef, val groupInfo: GroupInfo, val groupLink: GroupLink, val groupRelays: List<GroupRelay>, val relaysChanged: Boolean): CR()
|
||||
@Serializable @SerialName("groupRelayUpdated") class GroupRelayUpdated(val user: UserRef, val groupInfo: GroupInfo, val member: GroupMember, val groupRelay: GroupRelay): CR()
|
||||
@Serializable @SerialName("groupLinkCreated") class GroupLinkCreated(val user: UserRef, val groupInfo: GroupInfo, val groupLink: GroupLink): CR()
|
||||
@@ -6784,8 +6784,8 @@ sealed class CR {
|
||||
is JoinedGroupMember -> "joinedGroupMember"
|
||||
is ConnectedToGroupMember -> "connectedToGroupMember"
|
||||
is GroupUpdated -> "groupUpdated"
|
||||
is ContactNameVerified -> "contactNameVerified"
|
||||
is GroupNameVerified -> "groupNameVerified"
|
||||
is ContactDomainVerified -> "contactDomainVerified"
|
||||
is GroupDomainVerified -> "groupDomainVerified"
|
||||
is GroupLinkDataUpdated -> "groupLinkDataUpdated"
|
||||
is GroupRelayUpdated -> "groupRelayUpdated"
|
||||
is GroupLinkCreated -> "groupLinkCreated"
|
||||
@@ -6970,8 +6970,8 @@ sealed class CR {
|
||||
is JoinedGroupMember -> withUser(user, "groupInfo: $groupInfo\nmember: $member")
|
||||
is ConnectedToGroupMember -> withUser(user, "groupInfo: $groupInfo\nmember: $member\nmemberContact: $memberContact")
|
||||
is GroupUpdated -> withUser(user, json.encodeToString(toGroup))
|
||||
is ContactNameVerified -> withUser(user, "contact: ${json.encodeToString(contact)}\nverificationFailure: $verificationFailure")
|
||||
is GroupNameVerified -> withUser(user, "groupInfo: ${json.encodeToString(groupInfo)}\nverificationFailure: $verificationFailure")
|
||||
is ContactDomainVerified -> withUser(user, "contact: ${json.encodeToString(contact)}\nverificationFailure: $verificationFailure")
|
||||
is GroupDomainVerified -> withUser(user, "groupInfo: ${json.encodeToString(groupInfo)}\nverificationFailure: $verificationFailure")
|
||||
is GroupLinkDataUpdated -> withUser(user, "groupInfo: $groupInfo\ngroupLink: $groupLink\ngroupRelays: $groupRelays\nrelaysChanged: $relaysChanged")
|
||||
is GroupRelayUpdated -> withUser(user, "groupInfo: $groupInfo\nmember: $member\ngroupRelay: $groupRelay")
|
||||
is GroupLinkCreated -> withUser(user, "groupInfo: $groupInfo\ngroupLink: $groupLink")
|
||||
@@ -7438,7 +7438,7 @@ sealed class ChatErrorType {
|
||||
is ChatStoreChanged -> "chatStoreChanged"
|
||||
is ConnectionPlanChatError -> "connectionPlan"
|
||||
is InvalidConnReq -> "invalidConnReq"
|
||||
is CESimplexDomain -> "simplexDomain"
|
||||
is SimplexDomainNotReady -> "simplexDomainNotReady"
|
||||
is UnsupportedConnReq -> "unsupportedConnReq"
|
||||
is InvalidChatMessage -> "invalidChatMessage"
|
||||
is ConnReqMessageProhibited -> "connReqMessageProhibited"
|
||||
@@ -7521,7 +7521,7 @@ sealed class ChatErrorType {
|
||||
@Serializable @SerialName("chatStoreChanged") object ChatStoreChanged: ChatErrorType()
|
||||
@Serializable @SerialName("connectionPlan") class ConnectionPlanChatError(val connectionPlan: ConnectionPlan): ChatErrorType()
|
||||
@Serializable @SerialName("invalidConnReq") object InvalidConnReq: ChatErrorType()
|
||||
@Serializable @SerialName("simplexDomain") class CESimplexDomain(val simplexDomain: SimplexDomain, val simplexDomainError: SimplexDomainError): ChatErrorType()
|
||||
@Serializable @SerialName("simplexDomain") class SimplexDomainNotReady(val simplexDomain: SimplexDomain, val simplexDomainError: SimplexDomainError): ChatErrorType()
|
||||
@Serializable @SerialName("unsupportedConnReq") object UnsupportedConnReq: ChatErrorType()
|
||||
@Serializable @SerialName("invalidChatMessage") class InvalidChatMessage(val connection: Connection, val message: String): ChatErrorType()
|
||||
@Serializable @SerialName("connReqMessageProhibited") object ConnReqMessageProhibited: ChatErrorType()
|
||||
|
||||
+2
-2
@@ -1111,8 +1111,8 @@ ChatStoreChanged:
|
||||
InvalidConnReq:
|
||||
- type: "invalidConnReq"
|
||||
|
||||
SimplexDomain:
|
||||
- type: "simplexDomain"
|
||||
SimplexDomainNotReady:
|
||||
- type: "simplexDomainNotReady"
|
||||
- simplexDomain: [SimplexDomain](#simplexdomain)
|
||||
- simplexDomainError: [SimplexDomainError](#simplexdomainerror)
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ undocumentedResponses =
|
||||
"CRContactAliasUpdated",
|
||||
"CRContactCode",
|
||||
"CRContactInfo",
|
||||
"CRContactNameVerified",
|
||||
"CRContactDomainVerified",
|
||||
"CRContactRatchetSyncStarted",
|
||||
"CRContactSwitchAborted",
|
||||
"CRContactSwitchStarted",
|
||||
@@ -168,7 +168,7 @@ undocumentedResponses =
|
||||
"CRGroupMemberRatchetSyncStarted",
|
||||
"CRGroupMemberSwitchAborted",
|
||||
"CRGroupMemberSwitchStarted",
|
||||
"CRGroupNameVerified",
|
||||
"CRGroupDomainVerified",
|
||||
"CRGroupProfile",
|
||||
"CRGroupUserChanged",
|
||||
"CRItemsReadForChat",
|
||||
|
||||
@@ -1042,7 +1042,7 @@ export type ChatErrorType =
|
||||
| ChatErrorType.ChatNotStopped
|
||||
| ChatErrorType.ChatStoreChanged
|
||||
| ChatErrorType.InvalidConnReq
|
||||
| ChatErrorType.SimplexDomain
|
||||
| ChatErrorType.SimplexDomainNotReady
|
||||
| ChatErrorType.UnsupportedConnReq
|
||||
| ChatErrorType.ConnReqMessageProhibited
|
||||
| ChatErrorType.ContactNotReady
|
||||
@@ -1120,7 +1120,7 @@ export namespace ChatErrorType {
|
||||
| "chatNotStopped"
|
||||
| "chatStoreChanged"
|
||||
| "invalidConnReq"
|
||||
| "simplexDomain"
|
||||
| "simplexDomainNotReady"
|
||||
| "unsupportedConnReq"
|
||||
| "connReqMessageProhibited"
|
||||
| "contactNotReady"
|
||||
@@ -1275,8 +1275,8 @@ export namespace ChatErrorType {
|
||||
type: "invalidConnReq"
|
||||
}
|
||||
|
||||
export interface SimplexDomain extends Interface {
|
||||
type: "simplexDomain"
|
||||
export interface SimplexDomainNotReady extends Interface {
|
||||
type: "simplexDomainNotReady"
|
||||
simplexDomain: SimplexDomain
|
||||
simplexDomainError: SimplexDomainError
|
||||
}
|
||||
|
||||
@@ -788,8 +788,8 @@ class ChatErrorType_chatStoreChanged(TypedDict):
|
||||
class ChatErrorType_invalidConnReq(TypedDict):
|
||||
type: Literal["invalidConnReq"]
|
||||
|
||||
class ChatErrorType_simplexDomain(TypedDict):
|
||||
type: Literal["simplexDomain"]
|
||||
class ChatErrorType_simplexDomainNotReady(TypedDict):
|
||||
type: Literal["simplexDomainNotReady"]
|
||||
simplexDomain: "SimplexDomain"
|
||||
simplexDomainError: "SimplexDomainError"
|
||||
|
||||
@@ -1023,7 +1023,7 @@ ChatErrorType = (
|
||||
| ChatErrorType_chatNotStopped
|
||||
| ChatErrorType_chatStoreChanged
|
||||
| ChatErrorType_invalidConnReq
|
||||
| ChatErrorType_simplexDomain
|
||||
| ChatErrorType_simplexDomainNotReady
|
||||
| ChatErrorType_unsupportedConnReq
|
||||
| ChatErrorType_connReqMessageProhibited
|
||||
| ChatErrorType_contactNotReady
|
||||
@@ -1080,7 +1080,7 @@ ChatErrorType = (
|
||||
| ChatErrorType_exception
|
||||
)
|
||||
|
||||
ChatErrorType_Tag = Literal["noActiveUser", "noConnectionUser", "noSndFileUser", "noRcvFileUser", "userUnknown", "userExists", "chatRelayExists", "differentActiveUser", "cantDeleteActiveUser", "cantDeleteLastUser", "cantHideLastUser", "hiddenUserAlwaysMuted", "emptyUserPassword", "userAlreadyHidden", "userNotHidden", "invalidDisplayName", "chatNotStarted", "chatNotStopped", "chatStoreChanged", "invalidConnReq", "simplexDomain", "unsupportedConnReq", "connReqMessageProhibited", "contactNotReady", "contactNotActive", "contactDisabled", "connectionDisabled", "groupUserRole", "groupMemberInitialRole", "contactIncognitoCantInvite", "groupIncognitoCantInvite", "groupContactRole", "groupDuplicateMember", "groupDuplicateMemberId", "groupNotJoined", "groupMemberNotActive", "cantBlockMemberForSelf", "groupMemberUserRemoved", "groupMemberNotFound", "groupCantResendInvitation", "groupInternal", "fileNotFound", "fileSize", "fileAlreadyReceiving", "fileCancelled", "fileCancel", "fileAlreadyExists", "fileWrite", "fileSend", "fileRcvChunk", "fileInternal", "fileImageType", "fileImageSize", "fileNotReceived", "fileNotApproved", "fallbackToSMPProhibited", "inlineFileProhibited", "invalidForward", "invalidChatItemUpdate", "invalidChatItemDelete", "hasCurrentCall", "noCurrentCall", "callContact", "directMessagesProhibited", "agentVersion", "agentNoSubResult", "commandError", "agentCommandError", "invalidFileDescription", "connectionIncognitoChangeProhibited", "connectionUserChangeProhibited", "peerChatVRangeIncompatible", "relayTestError", "internalError", "exception"]
|
||||
ChatErrorType_Tag = Literal["noActiveUser", "noConnectionUser", "noSndFileUser", "noRcvFileUser", "userUnknown", "userExists", "chatRelayExists", "differentActiveUser", "cantDeleteActiveUser", "cantDeleteLastUser", "cantHideLastUser", "hiddenUserAlwaysMuted", "emptyUserPassword", "userAlreadyHidden", "userNotHidden", "invalidDisplayName", "chatNotStarted", "chatNotStopped", "chatStoreChanged", "invalidConnReq", "simplexDomainNotReady", "unsupportedConnReq", "connReqMessageProhibited", "contactNotReady", "contactNotActive", "contactDisabled", "connectionDisabled", "groupUserRole", "groupMemberInitialRole", "contactIncognitoCantInvite", "groupIncognitoCantInvite", "groupContactRole", "groupDuplicateMember", "groupDuplicateMemberId", "groupNotJoined", "groupMemberNotActive", "cantBlockMemberForSelf", "groupMemberUserRemoved", "groupMemberNotFound", "groupCantResendInvitation", "groupInternal", "fileNotFound", "fileSize", "fileAlreadyReceiving", "fileCancelled", "fileCancel", "fileAlreadyExists", "fileWrite", "fileSend", "fileRcvChunk", "fileInternal", "fileImageType", "fileImageSize", "fileNotReceived", "fileNotApproved", "fallbackToSMPProhibited", "inlineFileProhibited", "invalidForward", "invalidChatItemUpdate", "invalidChatItemDelete", "hasCurrentCall", "noCurrentCall", "callContact", "directMessagesProhibited", "agentVersion", "agentNoSubResult", "commandError", "agentCommandError", "invalidFileDescription", "connectionIncognitoChangeProhibited", "connectionUserChangeProhibited", "peerChatVRangeIncompatible", "relayTestError", "internalError", "exception"]
|
||||
|
||||
ChatFeature = Literal["timedMessages", "fullDelete", "reactions", "voice", "files", "calls", "sessions"]
|
||||
|
||||
|
||||
@@ -778,8 +778,8 @@ data ChatResponse
|
||||
| CRContactCode {user :: User, contact :: Contact, connectionCode :: Text}
|
||||
| CRGroupMemberCode {user :: User, groupInfo :: GroupInfo, member :: GroupMember, connectionCode :: Text}
|
||||
| CRConnectionVerified {user :: User, verified :: Bool, expectedCode :: Text}
|
||||
| CRContactNameVerified {user :: User, contact :: Contact, verificationFailure :: Maybe Text}
|
||||
| CRGroupNameVerified {user :: User, groupInfo :: GroupInfo, verificationFailure :: Maybe Text}
|
||||
| CRContactDomainVerified {user :: User, contact :: Contact, verificationFailure :: Maybe Text}
|
||||
| CRGroupDomainVerified {user :: User, groupInfo :: GroupInfo, verificationFailure :: Maybe Text}
|
||||
| CRTagsUpdated {user :: User, userTags :: [ChatTag], chatTags :: [ChatTagId]}
|
||||
| CRNewChatItems {user :: User, chatItems :: [AChatItem]}
|
||||
| CRChatItemUpdated {user :: User, chatItem :: AChatItem}
|
||||
@@ -1432,7 +1432,7 @@ data ChatErrorType
|
||||
| CEChatNotStopped
|
||||
| CEChatStoreChanged
|
||||
| CEInvalidConnReq
|
||||
| CESimplexDomain {simplexDomain :: SimplexDomain, simplexDomainError :: SimplexDomainError}
|
||||
| CESimplexDomainNotReady {simplexDomain :: SimplexDomain, simplexDomainError :: SimplexDomainError}
|
||||
| CEUnsupportedConnReq
|
||||
| CEInvalidChatMessage {connection :: Connection, msgMeta :: Maybe MsgMetaJSON, messageData :: Text, message :: String}
|
||||
| CEConnReqMessageProhibited
|
||||
|
||||
@@ -1504,7 +1504,7 @@ processChatCommand cxt nm = \case
|
||||
case sl_ of
|
||||
Just sl | shortLinkDataSet -> do
|
||||
NameRecord {nrSimplexContact} <- withAgent $ \a -> resolveSimplexName a nm (aUserId user) domain
|
||||
unless (nameResolvesTo sl nrSimplexContact) $ throwChatError $ CESimplexDomain domain SDENoValidLink
|
||||
unless (nameResolvesTo sl nrSimplexContact) $ throwChatError $ CESimplexDomainNotReady domain SDENoValidLink
|
||||
pure $ Just (CLShort sl)
|
||||
_ -> throwCmdError "create the address short link and add it to name"
|
||||
let p' = (fromLocalProfile p :: Profile) {contactDomain = mkDomainClaim <$> domain_, contactLink = cl'}
|
||||
@@ -2296,14 +2296,14 @@ processChatCommand cxt nm = \case
|
||||
domain <- maybe (throwCmdError "contact has no name to verify") pure contactDomain
|
||||
(verified, reason) <- verifyEntityDomain user nm NTContact domain connLink_
|
||||
ct' <- maybe (pure ct) (\v -> withFastStore' $ \db -> setContactDomainVerified db user ct v) verified
|
||||
pure $ CRContactNameVerified user ct' reason
|
||||
pure $ CRContactDomainVerified user ct' reason
|
||||
APIVerifyGroupDomain groupId -> withUser $ \user -> do
|
||||
g@GroupInfo {groupProfile = GroupProfile {publicGroup}, preparedGroup} <- withFastStore $ \db -> getGroupInfo db cxt user groupId
|
||||
let connLink_ = preparedGroup >>= \PreparedGroup {connLinkToConnect = CCLink _ sLnk_} -> ACSL SCMContact <$> sLnk_
|
||||
domain <- maybe (throwCmdError "group has no name to verify") pure $ publicGroup >>= publicGroupAccess >>= groupDomainClaim
|
||||
(verified, reason) <- verifyEntityDomain user nm NTPublicGroup domain connLink_
|
||||
g' <- maybe (pure g) (\v -> withFastStore' $ \db -> setGroupDomainVerified db user g v) verified
|
||||
pure $ CRGroupNameVerified user g' reason
|
||||
pure $ CRGroupDomainVerified user g' reason
|
||||
APIConnectContactViaAddress userId incognito contactId -> withUserId userId $ \user -> do
|
||||
ct@Contact {profile = LocalProfile {contactLink}} <- withFastStore $ \db -> getContact db cxt user contactId
|
||||
ccLink <- case contactLink of
|
||||
@@ -3140,7 +3140,7 @@ processChatCommand cxt nm = \case
|
||||
forM_ (claimDomain <$> newClaim) $ \newDomain ->
|
||||
when (Just newDomain /= (claimDomain <$> (existingAccess >>= groupDomainClaim))) $ do
|
||||
NameRecord {nrSimplexChannel} <- withAgent $ \a -> resolveSimplexName a nm (aUserId user) newDomain
|
||||
unless (nameResolvesTo groupLink nrSimplexChannel) $ throwChatError $ CESimplexDomain newDomain SDENoValidLink
|
||||
unless (nameResolvesTo groupLink nrSimplexChannel) $ throwChatError $ CESimplexDomainNotReady newDomain SDENoValidLink
|
||||
runUpdateGroupProfile user gInfo p {publicGroup = Just pg {publicGroupAccess = Just access}}
|
||||
Nothing -> throwChatError $ CECommandError "not a public group"
|
||||
APICreateGroupLink groupId mRole -> withUser $ \user -> withGroupLock "createGroupLink" groupId $ do
|
||||
@@ -4214,7 +4214,7 @@ processChatCommand cxt nm = \case
|
||||
(Just _, Just p) -> updateContactFromLinkData user ct' p
|
||||
_ -> pure ct'
|
||||
forM_ verifiedName $ \SimplexNameInfo {nameDomain} ->
|
||||
unless (linkDomain_ == Just nameDomain) $ throwChatError $ CESimplexDomain nameDomain SDEUnknownDomain
|
||||
unless (linkDomain_ == Just nameDomain) $ throwChatError $ CESimplexDomainNotReady nameDomain SDEUnknownDomain
|
||||
withFastStore' (\db -> getContactWithoutConnViaShortAddress db cxt user l') >>= \case
|
||||
Just ct' | not (contactDeleted ct') -> do
|
||||
ct'' <- refreshContact ct'
|
||||
@@ -4287,7 +4287,7 @@ processChatCommand cxt nm = \case
|
||||
CPGroupLink (GLPOwnLink GroupInfo {groupProfile}) -> Just groupProfile
|
||||
CPGroupLink (GLPConnectingProhibit (Just GroupInfo {groupProfile})) -> Just groupProfile
|
||||
_ -> (\GroupShortLinkData {groupProfile} -> groupProfile) <$> groupSLinkData_
|
||||
in unless (domain_ == Just nameDomain) $ throwChatError $ CESimplexDomain nameDomain SDEUnknownDomain
|
||||
in unless (domain_ == Just nameDomain) $ throwChatError $ CESimplexDomainNotReady nameDomain SDEUnknownDomain
|
||||
pure $ case plan of
|
||||
CPGroupLink glp@(GLPOk {}) -> (con l' cReq, CPGroupLink glp {verifiedName})
|
||||
_ -> (con l' cReq, plan)
|
||||
@@ -4317,7 +4317,7 @@ processChatCommand cxt nm = \case
|
||||
let (candidates, ctType) = case nameType of
|
||||
NTContact -> (nrSimplexContact, CCTContact)
|
||||
NTPublicGroup -> (nrSimplexChannel, CCTChannel)
|
||||
maybe (throwChatError $ CESimplexDomain nameDomain SDENoValidLink) pure $ firstNameLink ctType candidates
|
||||
maybe (throwChatError $ CESimplexDomainNotReady nameDomain SDENoValidLink) pure $ firstNameLink ctType candidates
|
||||
connectWithPlan :: User -> IncognitoEnabled -> ACreatedConnLink -> ConnectionPlan -> CM ChatResponse
|
||||
connectWithPlan user@User {userId} incognito ccLink plan
|
||||
| connectionPlanProceed plan = do
|
||||
|
||||
@@ -148,8 +148,8 @@ chatResponseToView hu cfg@ChatConfig {logLevel, showReactions, testView} liveIte
|
||||
CRContactRatchetSyncStarted {} -> ["connection synchronization started"]
|
||||
CRGroupMemberRatchetSyncStarted {} -> ["connection synchronization started"]
|
||||
CRConnectionVerified u verified code -> ttyUser u [plain $ if verified then "connection verified" else "connection not verified, current code is " <> code]
|
||||
CRContactNameVerified u (Contact {profile = LocalProfile {contactDomain}}) result -> ttyUser u $ viewNameVerified NTContact (claimDomain <$> contactDomain) result
|
||||
CRGroupNameVerified u g result -> ttyUser u $ viewNameVerified NTPublicGroup (groupSimplexDomain g) result
|
||||
CRContactDomainVerified u (Contact {profile = LocalProfile {contactDomain}}) result -> ttyUser u $ viewDomainVerified NTContact (claimDomain <$> contactDomain) result
|
||||
CRGroupDomainVerified u g result -> ttyUser u $ viewDomainVerified NTPublicGroup (groupSimplexDomain g) result
|
||||
CRContactCode u ct code -> ttyUser u $ viewContactCode ct code testView
|
||||
CRGroupMemberCode u g m code -> ttyUser u $ viewGroupMemberCode g m code testView
|
||||
CRNewChatItems u chatItems -> viewChatItems ttyUser unmuted u chatItems ts tz testView
|
||||
@@ -1132,8 +1132,8 @@ groupSimplexDomain :: GroupInfo -> Maybe SimplexDomain
|
||||
groupSimplexDomain GroupInfo {groupProfile = GroupProfile {publicGroup}} =
|
||||
claimDomain <$> (publicGroup >>= publicGroupAccess >>= groupDomainClaim)
|
||||
|
||||
viewNameVerified :: SimplexNameType -> Maybe SimplexDomain -> Maybe Text -> [StyledString]
|
||||
viewNameVerified nameType domain_ result =
|
||||
viewDomainVerified :: SimplexNameType -> Maybe SimplexDomain -> Maybe Text -> [StyledString]
|
||||
viewDomainVerified nameType domain_ result =
|
||||
let nameStr = maybe "name" (\d -> "SimpleX name " <> shortNameInfoStr (SimplexNameInfo nameType d)) domain_
|
||||
in case result of
|
||||
Nothing -> [plain nameStr <> " verified"]
|
||||
@@ -2682,7 +2682,7 @@ viewChatError isCmd logLevel testView = \case
|
||||
CEChatNotStopped -> ["error: chat not stopped"]
|
||||
CEChatStoreChanged -> ["error: chat store changed, please restart chat"]
|
||||
CEInvalidConnReq -> viewInvalidConnReq
|
||||
CESimplexDomain domain domainErr ->
|
||||
CESimplexDomainNotReady domain domainErr ->
|
||||
let reason = case domainErr of
|
||||
SDENoValidLink -> "has no valid connection link"
|
||||
SDEUnknownDomain -> "is not included in the connection link's profile"
|
||||
|
||||
Reference in New Issue
Block a user