Merge branch 'master' into ep/link-notices

This commit is contained in:
Evgeny @ SimpleX Chat committed 2026-10-20 21:46:21 +00:00
commit 2a86c24a57
1320 files changed
+121675 -7495

No files matched your search

+3
View File
@@ -119,6 +119,7 @@ chatCommandsDocsData =
( "Group commands",
"Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.",
[ ("APIAddMember", [], "Add contact to group. Requires bot to have Admin role.", ["CRSentGroupInvitation", "CRChatCmdError"], [], Just UNInteractive, "/_add #" <> Param "groupId" <> " " <> Param "contactId" <> " " <> Param "memberRole"),
("APIAddMemberViaGroup", [], "Add member of another group to group. Requires bot to have Admin role in the group, and direct messages allowed for its role in another group.", ["CRSentGroupInvitationViaGroup", "CRChatCmdError"], [TD "CEPeerChatVRangeIncompatible" "Member's client version is older than required"], Just UNInteractive, "/_add #" <> Param "groupId" <> " #" <> Param "viaGroupId" <> " " <> Param "groupMemberId" <> " " <> Param "memberRole"),
("APIJoinGroup", ["enableNtfs"], "Join group.", ["CRUserAcceptedGroupSent", "CRChatCmdError"], [], Just UNInteractive, "/_join #" <> Param "groupId"),
("APIAcceptMember", [], "Accept group member. Requires Admin role.", ["CRMemberAccepted", "CRChatCmdError"], [TD "CEGroupMemberNotActive" "Member is not connected yet"], Just UNBackground, "/_accept member #" <> Param "groupId" <> " " <> Param "groupMemberId" <> " " <> Param "memberRole"),
("APIMembersRole", [], "Set members role. Requires Admin role.", ["CRMembersRoleUser", "CRChatCmdError"], [], Just UNBackground, "/_member role #" <> Param "groupId" <> " " <> Join ',' "groupMemberIds" <> " " <> Param "memberRole"),
@@ -369,6 +370,7 @@ undocumentedCommands =
"APIConnectPreparedGroup",
"APIContactInfo",
"APIContactQueueInfo",
"APICreateBadgeInvoice",
"APICreateChatItems",
"APICreateChatTag",
"APICreateMemberContact",
@@ -415,6 +417,7 @@ undocumentedCommands =
"APIPlanForwardChatItems",
"APIPrepareContact",
"APIPrepareGroup",
"APIPurchaseBadge",
"APIRedeemBadgeCode",
"APIRegisterToken",
"APIRejectCall",
+4
View File
@@ -85,6 +85,7 @@ chatEventsDocsData =
"Bots may use these events to manage users' groups and business address groups.\n\n\
\*Please note*: programming groups is more complex than programming direct connections",
[ ("CEvtReceivedGroupInvitation", ""),
("CEvtReceivedGroupInvitationViaGroup", "Received group invitation from member of another group."),
("CEvtUserJoinedGroup", "Bot user joined group. Received when connection via group link completes."),
("CEvtGroupUpdated", "Group profile or preferences updated."),
("CEvtJoinedGroupMember", "Another member joined group."),
@@ -202,6 +203,7 @@ undocumentedEvents =
"CEvtContactRequestRejected",
"CEvtContactSwitch",
"CEvtCustomChatEvent",
"CEvtDuplicateGroupMessage",
"CEvtGroupMemberRatchetSync",
"CEvtGroupMemberSwitch",
"CEvtServiceSubStatus",
@@ -221,6 +223,8 @@ undocumentedEvents =
"CEvtSndFileRedirectStartXFTP",
"CEvtSndFileStart", -- legacy SMP files
"CEvtSndStandaloneFileComplete",
"CEvtStorePurchaseCredited",
"CEvtStorePurchaseRefused",
"CEvtConnectionsDiff",
"CEvtSubscriptionEnd",
"CEvtTerminalEvent",
+22 -23
View File
@@ -60,10 +60,7 @@ commandsCodeText =
<> respAliasLine
where
constrName = T.pack $ fstToUpper tag
classDef =
("class " <> constrName <> "(TypedDict):\n")
<> bodyOrPass (fieldsCodePy " " "T." params)
<> "\n"
classDef = typedDictCode constrName (fieldsCodePy "T." params) <> "\n"
cmdStringFunc =
("\ndef " <> constrName <> "_cmd_string(self: " <> constrName <> ") -> str:\n")
<> " return " <> pySelfSyntaxText "T." (fstToUpper tag, params) syntax <> "\n"
@@ -143,9 +140,7 @@ typesCodeText =
"FileProtocol" -> map toUpper m
_ -> m
typeDefCode = case typeDef of
ATDRecord fields ->
("\nclass " <> name' <> "(TypedDict):\n")
<> bodyOrPass (fieldsCodePy " " "" fields)
ATDRecord fields -> "\n" <> typedDictCode name' (fieldsCodePy "" fields)
ATDEnum cs ->
"\n" <> name' <> " = Literal["
<> T.intercalate ", " (map (\m -> "\"" <> T.pack (enumValue m) <> "\"") $ L.toList cs)
@@ -231,9 +226,7 @@ unionTypeCodePy memberName typesNamespace name cs =
constrTypeRef (ATUnionMember tag _) = memberName name tag
tagLiterals = T.intercalate ", " $ map (\(ATUnionMember tag _) -> "\"" <> T.pack tag <> "\"") $ L.toList cs
memberClass (ATUnionMember tag fields) =
("\nclass " <> memberName name tag <> "(TypedDict):\n")
<> (" type: Literal[\"" <> T.pack tag <> "\"]\n")
<> fieldsCodePy " " typesNamespace fields
"\n" <> typedDictCode (memberName name tag) (("type", "Literal[\"" <> T.pack tag <> "\"]", "") : fieldsCodePy typesNamespace fields)
-- | Render the right-hand side of a union alias: either inline (one line) or
-- multi-line wrapped in parentheses with `|` separators between alternatives.
@@ -248,21 +241,27 @@ unionAliasRhs lhs constr cs
(h : t) -> h : map ("| " <>) t
cs' = map constr cs
-- | Emit a body of `pass` if there are no fields, otherwise the rendered
-- fields as-is.
bodyOrPass :: Text -> Text
bodyOrPass body
| T.null body = " pass\n"
| otherwise = body
typedDictCode :: Text -> [(Text, Text, Text)] -> Text
typedDictCode name fields
| any (\(field, _, _) -> field `elem` pyKeywords) fields =
(name <> " = TypedDict(\"" <> name <> "\", {\n")
<> foldMap (\(field, t, comment) -> " \"" <> field <> "\": " <> t <> "," <> comment <> "\n") fields
<> "})\n"
| null fields = "class " <> name <> "(TypedDict):\n pass\n"
| otherwise =
("class " <> name <> "(TypedDict):\n")
<> foldMap (\(field, t, comment) -> " " <> field <> ": " <> t <> comment <> "\n") fields
-- | Render record fields for a TypedDict body. Each field becomes
-- `<indent><name>: <type>[ # <comment>]`. Optional fields wrap the type in
-- `NotRequired[...]`.
fieldsCodePy :: Text -> Text -> [APIRecordField] -> Text
fieldsCodePy indent namespace = foldMap render
pyKeywords :: [Text]
pyKeywords =
["False", "None", "True", "and", "as", "assert", "async", "await", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "nonlocal", "not", "or", "pass", "raise", "return", "try", "while", "with", "yield"]
-- | Render record fields for a TypedDict as name, type and comment.
-- Optional fields wrap the type in `NotRequired[...]`.
fieldsCodePy :: Text -> [APIRecordField] -> [(Text, Text, Text)]
fieldsCodePy namespace = map render
where
render (APIRecordField name t) =
indent <> T.pack name <> ": " <> wrapOptional t (typeText t) <> typeComment t <> "\n"
render (APIRecordField name t) = (T.pack name, wrapOptional t (typeText t), typeComment t)
wrapOptional t inner = case t of
ATOptional _ -> "NotRequired[" <> inner <> "]"
_ -> inner
+2
View File
@@ -92,6 +92,7 @@ chatResponsesDocsData =
("CRRemoteCtrlConnecting", "Remote controller is connecting."),
("CRSentConfirmation", "Confirmation sent to one-time invitation"),
("CRSentGroupInvitation", "Group invitation sent"),
("CRSentGroupInvitationViaGroup", "Group invitation sent to member of another group"),
("CRSentInvitation", "Invitation sent to contact address"),
("CRSentInvitationToContact", "Invitation sent to contact (when connecting via SimpleX name to a known contact address)."),
("CRServiceReplyAccepted", "Service reply accepted for delivery. `connectionId` correlates the reply delivery event."),
@@ -134,6 +135,7 @@ undocumentedResponses =
"CRAppSettings",
"CRArchiveExported",
"CRArchiveImported",
"CRBadgeInvoice",
"CRBadgeLedger",
"CRBadgeRedeemed",
"CRBadgeState",
+12 -2
View File
@@ -224,6 +224,7 @@ chatTypesDocsData =
(sti @BadgeServiceErrorCode, STEnum' (consSep "BSE" '_'), "", ["BSEUnknown"], "", ""),
(sti @BlockingInfo, STRecord, "", [], "", ""),
(sti @BlockingReason, STEnum, "BR", [], "", ""),
(sti @BlockToken, STUnion, "", [], "", ""),
(sti @BrokerErrorType, STUnion, "", [], "", ""),
(sti @BusinessChatInfo, STRecord, "", [], "", ""),
(sti @BusinessChatType, STEnum, "BC", [], "", ""),
@@ -285,7 +286,7 @@ chatTypesDocsData =
(sti @FileStatus, STEnum, "FS", [], "", ""),
(sti @FileTransferMeta, STRecord, "", [], "", ""),
(sti @FileType, STEnum' (consLower "FT"), "", [], "", ""),
(sti @Format, STUnion, "", ["Unknown"], "", ""),
(sti @Format, STUnion, "", ["Unknown"], "", "The format markup is a token of block Markdown syntax; its text is the syntax. The format escape is the backslash of a backslash escape. Bold singleStar: written with single stars."),
(sti @FormattedText, STRecord, "", [], "", ""),
(sti @FullGroupPreferences, STRecord, "", [], "", ""),
(sti @FullPreferences, STRecord, "", [], "", ""),
@@ -298,7 +299,7 @@ chatTypesDocsData =
(sti @GroupLink, STRecord, "", [], "", ""),
(sti @GroupLinkOwner, STRecord, "", [], "", ""),
(sti @GroupLinkPlan, STUnion, "GLP", [], "", ""),
(sti @GroupMember, STRecord, "", [], "", ""),
(removeField "memberBadgeProof" $ sti @GroupMember, STRecord, "", [], "", ""),
(sti @GroupMemberAdmission, STRecord, "", [], "", ""),
(sti @GroupMemberCategory, STEnum' (dropPfxSfx "GC" "Member"), "", [], "", ""),
(sti @GroupMemberRef, STRecord, "", [], "", ""),
@@ -322,8 +323,10 @@ chatTypesDocsData =
(sti @LinkNotice, STRecord, "", [], "", ""),
(sti @LinkOwnerSig, STRecord, "", [], "", ""),
(sti @LinkPreview, STRecord, "", [], "", ""),
(sti @ListEntry, STRecord, "", [], "", ""),
(sti @BadgeInfo, STRecord, "", [], "", ""),
(sti @LocalProfile, STRecord, "", [], "", ""),
(sti @MarkdownBlock, STUnion, "", ["UnknownBlock"], "", ""),
(sti @MemberCriteria, STEnum1, "MC", [], "", ""),
(sti @MsgChatLink, STUnion, "MCL", [], "", "Connection link sent in a message - only short links are allowed."),
(sti @MsgContent, STUnion, "MC", [], "", ""),
@@ -372,6 +375,7 @@ chatTypesDocsData =
(sti @ReportReason, STEnum' (dropPfxSfx "RR" ""), "", ["RRUnknown"], "", ""),
(sti @RoleGroupPreference, STRecord, "", [], "", ""),
(sti @SecurityCode, STRecord, "", [], "", ""),
(sti @SegmentRange, STRecord, "", [], "", ""),
(sti @SimplePreference, STRecord, "", [], "", ""),
(sti @SimplexDomain, STRecord, "", [], "", ""),
(sti @SimplexDomainClaim, STRecord, "", [], "", ""),
@@ -392,6 +396,7 @@ chatTypesDocsData =
(sti @SubscriptionStatus, STUnion, "SS", [], "", ""),
(sti @SupportGroupPreference, STRecord, "", [], "", ""),
(sti @SwitchPhase, STEnum, "SP", [], "", ""),
(sti @TableAlign, STEnum, "TA", [], "", ""),
(sti @TimedMessagesGroupPreference, STRecord, "", [], "", ""),
(sti @TimedMessagesPreference, STRecord, "", [], "", ""),
(sti @TransportError, STUnion, "TE", [], "", ""),
@@ -458,6 +463,7 @@ deriving instance Generic BadgeRedeemError
deriving instance Generic BadgeServiceErrorCode
deriving instance Generic BlockingInfo
deriving instance Generic BlockingReason
deriving instance Generic BlockToken
deriving instance Generic BrokerErrorType
deriving instance Generic BusinessChatInfo
deriving instance Generic BusinessChatType
@@ -563,8 +569,10 @@ deriving instance Generic LinkContent
deriving instance Generic LinkNotice
deriving instance Generic LinkOwnerSig
deriving instance Generic LinkPreview
deriving instance Generic ListEntry
deriving instance Generic BadgeInfo
deriving instance Generic LocalProfile
deriving instance Generic MarkdownBlock
deriving instance Generic MemberCriteria
deriving instance Generic MsgChatLink
deriving instance Generic MsgContent
@@ -612,6 +620,7 @@ deriving instance Generic RemoteCtrlSessionState
deriving instance Generic RemoteCtrlStopReason
deriving instance Generic ReportReason
deriving instance Generic SecurityCode
deriving instance Generic SegmentRange
deriving instance Generic SimplexDomain
deriving instance Generic SimplexDomainClaim
deriving instance Generic SimplexDomainError
@@ -631,6 +640,7 @@ deriving instance Generic StoreError
deriving instance Generic SubscriptionStatus
deriving instance Generic SupportGroupPreference
deriving instance Generic SwitchPhase
deriving instance Generic TableAlign
deriving instance Generic TimedMessagesGroupPreference
deriving instance Generic TimedMessagesPreference
deriving instance Generic TransportError