mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-08 06:46:58 +00:00
bd8ba4d5c6
* core: chat relays protocol wip * types, notes * remove file * removal protocol * schema * status * update * recovery * update * formatting * rename * more types * comment * more docs * decrease number of steps * format * correct * update * update protocol * update * typo * todo * update doc * update * update * remove added * update * update * XGrpRelayReady * link to chat relays * update * remove from protocol * update * json * wip * remove comment * wip * update * wip * wip * update * wip * wip * plans * better view * fix * fix * relay acceptance * rework api * add relays to link * comment * active on con, fix send * comments * direct in group plan * prepare * member connection wip * comments * member connection wip * fix forwarding * introduce moderators to new member * enable relay tests * plans * security objectives * refactor * add to threat model * stress test wip * stress test wip * Revert "stress test wip" This reverts commitacde8a1fb3. * Revert "stress test wip" This reverts commit6435808438. * remove stress test * improve output * invert relay fkey * postgres schema * comments * group in progress, remove auto-select relays commented code * comments * corrections * comment * lint * redundant import * core: chat relay request worker (#6509) * update plans * strict tables * core: update group link asynchronously with relay link (#6548) * update simplexmq * docs: connection to chat relays rfc (#6554) * add test for 2 relays (doesn't pass) * create unknown member in same transaction as checking * fix relays choosing different memberId (XContactRelay) * plans, api * use same incognito profile for relays, connect concurrently, save correct link for plan * test * don't duplicate items on group connection * check relay record exists when joining * use mapConcurrently when adding relays, update schemas * fix multi-relay join for postgres (savepoint) * core: async retry connection to chat relays (#6584) * update simplexmq * fix api tests * prefer throwing temp error on connection * check group relays when deleting from configuration * relay_request_err_reason * relay role * rename, fix syntax * plans * rename, style --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
207 lines
7.0 KiB
Haskell
207 lines
7.0 KiB
Haskell
{-# LANGUAGE DeriveGeneric #-}
|
|
{-# LANGUAGE DuplicateRecordFields #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
{-# LANGUAGE StandaloneDeriving #-}
|
|
{-# LANGUAGE TypeApplications #-}
|
|
{-# OPTIONS_GHC -Wno-orphans #-}
|
|
|
|
module API.Docs.Responses where
|
|
|
|
import API.Docs.Types
|
|
import API.TypeInfo
|
|
import Data.List (find)
|
|
import GHC.Generics
|
|
import Simplex.Chat.Controller
|
|
import Simplex.Messaging.Parsers (dropPrefix)
|
|
|
|
data CRDoc = CRDoc
|
|
{ consName :: ConsName,
|
|
responseType :: ATUnionMember,
|
|
responseDescr :: String
|
|
}
|
|
|
|
instance ConstructorName CRDoc where consName' CRDoc {consName} = consName
|
|
|
|
chatResponsesDocs :: [CRDoc]
|
|
chatResponsesDocs = map toResp chatResponsesDocsData
|
|
where
|
|
toResp (consName, responseDescr)
|
|
| consName == "CRChatCmdError" =
|
|
let field = toAPIField consName $ FieldInfo "chatError" (ti "ChatError")
|
|
responseType = ATUnionMember (dropPrefix "CR" consName) [field]
|
|
in CRDoc {consName, responseType, responseDescr}
|
|
| otherwise = case find ((consName ==) . consName') chatResponsesTypeInfo of
|
|
Just RecordTypeInfo {fieldInfos} ->
|
|
let fields = map (toAPIField consName) fieldInfos
|
|
responseType = ATUnionMember (dropPrefix "CR" consName) fields
|
|
in CRDoc {consName, responseType, responseDescr}
|
|
Nothing -> error $ "Missing response type info for " <> consName
|
|
|
|
deriving instance Generic ChatResponse
|
|
|
|
chatResponsesTypeInfo :: [RecordTypeInfo]
|
|
chatResponsesTypeInfo = recordTypesInfo @ChatResponse
|
|
|
|
chatResponsesDocsData :: [(ConsName, String)]
|
|
chatResponsesDocsData =
|
|
[ ("CRAcceptingContactRequest", "Contact request accepted"),
|
|
("CRActiveUser", "Active user profile"),
|
|
("CRChatItemNotChanged", "Message not changed"),
|
|
("CRChatItemReaction", "Message reaction"),
|
|
("CRChatItemUpdated", "Message updated"),
|
|
("CRChatItemsDeleted", "Messages deleted"),
|
|
("CRChatRunning", ""),
|
|
("CRChatStarted", ""),
|
|
("CRChatStopped", ""),
|
|
("CRCmdOk", "Ok"),
|
|
("CRChatCmdError", "Command error (only used in WebSockets API)"), -- Haskell code uses Either, with error in Left
|
|
("CRConnectionPlan", "Connection link information"),
|
|
("CRContactAlreadyExists", ""),
|
|
("CRContactConnectionDeleted", "Connection deleted"),
|
|
("CRContactDeleted", ""),
|
|
("CRContactPrefsUpdated", "Contact preferences updated"),
|
|
("CRContactRequestRejected", ""),
|
|
("CRContactsList", "Contacts"),
|
|
("CRGroupDeletedUser", "User deleted group"),
|
|
("CRGroupLink", ""),
|
|
("CRGroupLinkCreated", ""),
|
|
("CRGroupLinkDeleted", ""),
|
|
("CRGroupCreated", ""),
|
|
("CRPublicGroupCreated", ""),
|
|
("CRGroupMembers", ""),
|
|
("CRGroupUpdated", ""),
|
|
("CRGroupsList", "Groups"),
|
|
("CRInvitation", "One-time invitation"),
|
|
("CRLeftMemberUser", "User left group"),
|
|
("CRMemberAccepted", "Member accepted to group"),
|
|
("CRMembersBlockedForAllUser", "Members blocked for all by admin"),
|
|
("CRMembersRoleUser", "Members role changed by user"),
|
|
("CRNewChatItems", "New messages"),
|
|
("CRRcvFileAccepted", "File accepted to be received"),
|
|
("CRRcvFileAcceptedSndCancelled", "File accepted, but no longer sent"),
|
|
("CRRcvFileCancelled", "Cancelled receiving file"),
|
|
("CRSentConfirmation", "Confirmation sent to one-time invitation"),
|
|
("CRSentGroupInvitation", "Group invitation sent"),
|
|
("CRSentInvitation", "Invitation sent to contact address"),
|
|
("CRSndFileCancelled", "Cancelled sending file"),
|
|
("CRUserAcceptedGroupSent", "User accepted group invitation"),
|
|
("CRUserContactLink", "User contact address"),
|
|
("CRUserContactLinkCreated", "User contact address created"),
|
|
("CRUserContactLinkDeleted", "User contact address deleted"),
|
|
("CRUserContactLinkUpdated", "User contact address updated"),
|
|
("CRUserDeletedMembers", "Members deleted"),
|
|
("CRUserProfileUpdated", "User profile updated"),
|
|
("CRUserProfileNoChange", "User profile was not changed"),
|
|
("CRUsersList", "Users")
|
|
-- ("CRApiChat", "Chat and messages"),
|
|
-- ("CRApiChats", "Chats with the most recent messages"),
|
|
-- ("CRChatCleared", ""),
|
|
-- ("CRChatItemInfo", "Message information"),
|
|
-- ("CRChatItems", "The most recent messages"),
|
|
-- ("CRConnectionAliasUpdated", ""),
|
|
-- ("CRContactAliasUpdated", ""),
|
|
-- ("CRContactRatchetSyncStarted", "Contact encryption synchronization started"),
|
|
-- ("CRGroupAliasUpdated", ""),
|
|
-- ("CRGroupMemberRatchetSyncStarted", "Member encryption synchronization started"),
|
|
-- ("CRItemsReadForChat", "Messages marked as read"),
|
|
-- ("CRReactionMembers", "Members who set reaction on the message"),
|
|
]
|
|
|
|
undocumentedResponses :: [ConsName]
|
|
undocumentedResponses =
|
|
[ "CRAgentQueuesInfo",
|
|
"CRAgentServersSummary",
|
|
"CRAgentSubs",
|
|
"CRAgentSubsDetails",
|
|
"CRAgentSubsTotal",
|
|
"CRAgentWorkersDetails",
|
|
"CRAgentWorkersSummary",
|
|
"CRApiChat",
|
|
"CRApiChats",
|
|
"CRAppSettings",
|
|
"CRArchiveExported",
|
|
"CRArchiveImported",
|
|
"CRBroadcastSent",
|
|
"CRCallInvitations",
|
|
"CRChatCleared",
|
|
"CRChatContentTypes",
|
|
"CRChatHelp",
|
|
"CRChatItemId",
|
|
"CRChatItemInfo",
|
|
"CRChatItems",
|
|
"CRChatItemTTL",
|
|
"CRChats",
|
|
"CRConnectionsDiff",
|
|
"CRChatTags",
|
|
"CRConnectionAliasUpdated",
|
|
"CRConnectionIncognitoUpdated",
|
|
"CRConnectionUserChanged",
|
|
"CRConnectionVerified",
|
|
"CRConnNtfMessages",
|
|
"CRContactAliasUpdated",
|
|
"CRContactCode",
|
|
"CRContactInfo",
|
|
"CRContactRatchetSyncStarted",
|
|
"CRContactSwitchAborted",
|
|
"CRContactSwitchStarted",
|
|
"CRContactUserChanged",
|
|
"CRCurrentRemoteHost",
|
|
"CRCustomChatResponse",
|
|
"CRDebugLocks",
|
|
"CRFileTransferStatus",
|
|
"CRFileTransferStatusXFTP",
|
|
"CRForwardPlan",
|
|
"CRGroupAliasUpdated",
|
|
"CRGroupChatItemsDeleted",
|
|
"CRGroupDescription",
|
|
"CRGroupInfo",
|
|
"CRGroupMemberCode",
|
|
"CRGroupMemberInfo",
|
|
"CRGroupMemberRatchetSyncStarted",
|
|
"CRGroupMemberSwitchAborted",
|
|
"CRGroupMemberSwitchStarted",
|
|
"CRGroupProfile",
|
|
"CRGroupUserChanged",
|
|
"CRItemsReadForChat",
|
|
"CRJoinedGroupMember",
|
|
"CRMemberSupportChatRead",
|
|
"CRMemberSupportChatDeleted",
|
|
"CRMemberSupportChats",
|
|
"CRNetworkConfig",
|
|
"CRNewMemberContact",
|
|
"CRNewMemberContactSentInv",
|
|
"CRMemberContactAccepted",
|
|
"CRNewPreparedChat",
|
|
"CRNtfConns",
|
|
"CRNtfToken",
|
|
"CRNtfTokenStatus",
|
|
"CRQueueInfo",
|
|
"CRRcvStandaloneFileCreated",
|
|
"CRReactionMembers",
|
|
"CRRemoteCtrlConnected",
|
|
"CRRemoteCtrlConnecting",
|
|
"CRRemoteCtrlList",
|
|
"CRRemoteFileStored",
|
|
"CRRemoteHostList",
|
|
"CRRemoteHostStarted",
|
|
"CRSentInvitationToContact",
|
|
"CRServerOperatorConditions",
|
|
"CRServerTestResult",
|
|
"CRSlowSQLQueries",
|
|
"CRSndStandaloneFileCreated",
|
|
"CRSQLResult",
|
|
"CRStandaloneFileInfo",
|
|
"CRStartedConnectionToContact",
|
|
"CRStartedConnectionToGroup",
|
|
"CRTagsUpdated",
|
|
"CRUsageConditions",
|
|
"CRUserPrivacy",
|
|
"CRUserProfile",
|
|
"CRUserProfileImage",
|
|
"CRUserServers",
|
|
"CRUserServersValidation",
|
|
"CRVersionInfo",
|
|
"CRWelcome"
|
|
]
|