From afbac2a88cbe0836d6f3c074c52aa4896f6fbf51 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Fri, 5 Jun 2026 22:59:03 +0100 Subject: [PATCH] fix bot API, schema --- bots/api/COMMANDS.md | 2 +- bots/api/TYPES.md | 47 +++++++++++++++++++ bots/src/API/TypeInfo.hs | 4 +- cabal.project | 2 +- .../types/typescript/src/types.ts | 27 +++++++++++ .../src/simplex_chat/types/_types.py | 16 +++++++ scripts/nix/sha256map.nix | 2 +- .../Store/SQLite/Migrations/chat_schema.sql | 7 ++- 8 files changed, 102 insertions(+), 5 deletions(-) diff --git a/bots/api/COMMANDS.md b/bots/api/COMMANDS.md index 19c96f9811..d14435cabd 100644 --- a/bots/api/COMMANDS.md +++ b/bots/api/COMMANDS.md @@ -2,7 +2,7 @@ This file is generated automatically. -[Address commands](# +[Address commands](#address-commands) - [APICreateMyAddress](#apicreatemyaddress) - [APIDeleteMyAddress](#apideletemyaddress) - [APIShowMyAddress](#apishowmyaddress) diff --git a/bots/api/TYPES.md b/bots/api/TYPES.md index a87bcae5e4..e4b0fe5c68 100644 --- a/bots/api/TYPES.md +++ b/bots/api/TYPES.md @@ -10,6 +10,8 @@ This file is generated automatically. - [AgentCryptoError](#agentcryptoerror) - [AgentErrorType](#agenterrortype) - [AutoAccept](#autoaccept) +- [BadgeStatus](#badgestatus) +- [BadgeType](#badgetype) - [BlockingInfo](#blockinginfo) - [BlockingReason](#blockingreason) - [BrokerErrorType](#brokererrortype) @@ -122,6 +124,7 @@ This file is generated automatically. - [LinkContent](#linkcontent) - [LinkOwnerSig](#linkownersig) - [LinkPreview](#linkpreview) +- [LocalBadge](#localbadge) - [LocalProfile](#localprofile) - [MemberCriteria](#membercriteria) - [MsgChatLink](#msgchatlink) @@ -180,6 +183,7 @@ This file is generated automatically. - [StoreError](#storeerror) - [SubscriptionStatus](#subscriptionstatus) - [SupportGroupPreference](#supportgrouppreference) +- [SupporterBadge](#supporterbadge) - [SwitchPhase](#switchphase) - [TimedMessagesGroupPreference](#timedmessagesgrouppreference) - [TimedMessagesPreference](#timedmessagespreference) @@ -353,6 +357,27 @@ INACTIVE: - acceptIncognito: bool +--- + +## BadgeStatus + +**Enum type**: +- "active" +- "expired" +- "failed" + + +--- + +## BadgeType + +**Enum type**: +- "supporter" +- "business" +- "legend" +- "cFInvestor" + + --- ## BlockingInfo @@ -2672,6 +2697,15 @@ Unknown: - content: [LinkContent](#linkcontent)? +--- + +## LocalBadge + +**Record type**: +- badgeStatus: [BadgeStatus](#badgestatus) +- badge: [SupporterBadge](#supporterbadge) + + --- ## LocalProfile @@ -2685,6 +2719,7 @@ Unknown: - contactLink: string? - preferences: [Preferences](#preferences)? - peerType: [ChatPeerType](#chatpeertype)? +- localBadge: [LocalBadge](#localbadge)? - localAlias: string @@ -3029,6 +3064,7 @@ count= - contactLink: string? - preferences: [Preferences](#preferences)? - peerType: [ChatPeerType](#chatpeertype)? +- badge: [SupporterBadge](#supporterbadge)? --- @@ -4029,6 +4065,17 @@ NoSub: - enable: [GroupFeatureEnabled](#groupfeatureenabled) +--- + +## SupporterBadge + +**Record type**: +- proof: string +- presHeader: string +- badgeExpiry: UTCTime? +- badgeType: [BadgeType](#badgetype) + + --- ## SwitchPhase diff --git a/bots/src/API/TypeInfo.hs b/bots/src/API/TypeInfo.hs index dc48131ce7..5ec614fc3d 100644 --- a/bots/src/API/TypeInfo.hs +++ b/bots/src/API/TypeInfo.hs @@ -67,7 +67,7 @@ pattern TUTCTime :: String pattern TUTCTime = "UTCTime" primitiveTypes :: [ConsName] -primitiveTypes = [TBool, TString, TInt, TInt64, TWord32, TDouble, TJSONObject, TUTCTime, "BBSProof", "BBSPresHeader", "ByteString"] +primitiveTypes = [TBool, TString, TInt, TInt64, TWord32, TDouble, TJSONObject, TUTCTime] data SumTypeInfo = STI {typeName :: String, recordTypes :: [RecordTypeInfo]} deriving (Show) @@ -199,6 +199,8 @@ toTypeInfo tr = "AgentRcvFileId", "AgentSndFileId", "B64UrlByteString", + "BBSProof", + "BBSPresHeader", "CbNonce", "ConnectionLink", "ConnShortLink", diff --git a/cabal.project b/cabal.project index 8229c37f36..8c5cfffb02 100644 --- a/cabal.project +++ b/cabal.project @@ -21,7 +21,7 @@ constraints: zip +disable-bzip2 +disable-zstd source-repository-package type: git location: https://github.com/simplex-chat/simplexmq.git - tag: 8418781fc7db2b9956b4df9a24461de5a9b41262 + tag: 39bd7205e202061d96d145e63bca21c69e99e278 source-repository-package type: git diff --git a/packages/simplex-chat-client/types/typescript/src/types.ts b/packages/simplex-chat-client/types/typescript/src/types.ts index 5e671169de..f984fade0b 100644 --- a/packages/simplex-chat-client/types/typescript/src/types.ts +++ b/packages/simplex-chat-client/types/typescript/src/types.ts @@ -186,6 +186,19 @@ export interface AutoAccept { acceptIncognito: boolean } +export enum BadgeStatus { + Active = "active", + Expired = "expired", + Failed = "failed", +} + +export enum BadgeType { + Supporter = "supporter", + Business = "business", + Legend = "legend", + CFInvestor = "cFInvestor", +} + export interface BlockingInfo { reason: BlockingReason notice?: ClientNotice @@ -2940,6 +2953,11 @@ export interface LinkPreview { content?: LinkContent } +export interface LocalBadge { + badgeStatus: BadgeStatus + badge: SupporterBadge +} + export interface LocalProfile { profileId: number // int64 displayName: string @@ -2949,6 +2967,7 @@ export interface LocalProfile { contactLink?: string preferences?: Preferences peerType?: ChatPeerType + localBadge?: LocalBadge localAlias: string } @@ -3299,6 +3318,7 @@ export interface Profile { contactLink?: string preferences?: Preferences peerType?: ChatPeerType + badge?: SupporterBadge } export type ProxyClientError = @@ -4735,6 +4755,13 @@ export interface SupportGroupPreference { enable: GroupFeatureEnabled } +export interface SupporterBadge { + proof: string + presHeader: string + badgeExpiry?: string // ISO-8601 timestamp + badgeType: BadgeType +} + export enum SwitchPhase { Started = "started", Confirmed = "confirmed", diff --git a/packages/simplex-chat-python/src/simplex_chat/types/_types.py b/packages/simplex-chat-python/src/simplex_chat/types/_types.py index 66ba77c062..565503b04d 100644 --- a/packages/simplex-chat-python/src/simplex_chat/types/_types.py +++ b/packages/simplex-chat-python/src/simplex_chat/types/_types.py @@ -138,6 +138,10 @@ AgentErrorType_Tag = Literal["CMD", "CONN", "NO_USER", "SMP", "NTF", "XFTP", "FI class AutoAccept(TypedDict): acceptIncognito: bool +BadgeStatus = Literal["active", "expired", "failed"] + +BadgeType = Literal["supporter", "business", "legend", "cFInvestor"] + class BlockingInfo(TypedDict): reason: "BlockingReason" notice: NotRequired["ClientNotice"] @@ -2059,6 +2063,10 @@ class LinkPreview(TypedDict): image: str content: NotRequired["LinkContent"] +class LocalBadge(TypedDict): + badgeStatus: "BadgeStatus" + badge: "SupporterBadge" + class LocalProfile(TypedDict): profileId: int # int64 displayName: str @@ -2068,6 +2076,7 @@ class LocalProfile(TypedDict): contactLink: NotRequired[str] preferences: NotRequired["Preferences"] peerType: NotRequired["ChatPeerType"] + localBadge: NotRequired["LocalBadge"] localAlias: str MemberCriteria = Literal["all"] @@ -2318,6 +2327,7 @@ class Profile(TypedDict): contactLink: NotRequired[str] preferences: NotRequired["Preferences"] peerType: NotRequired["ChatPeerType"] + badge: NotRequired["SupporterBadge"] class ProxyClientError_protocolError(TypedDict): type: Literal["protocolError"] @@ -3313,6 +3323,12 @@ SubscriptionStatus_Tag = Literal["active", "pending", "removed", "noSub"] class SupportGroupPreference(TypedDict): enable: "GroupFeatureEnabled" +class SupporterBadge(TypedDict): + proof: str + presHeader: str + badgeExpiry: NotRequired[str] # ISO-8601 timestamp + badgeType: "BadgeType" + SwitchPhase = Literal["started", "confirmed", "secured", "completed"] class TimedMessagesGroupPreference(TypedDict): diff --git a/scripts/nix/sha256map.nix b/scripts/nix/sha256map.nix index 3610906390..553b1aafed 100644 --- a/scripts/nix/sha256map.nix +++ b/scripts/nix/sha256map.nix @@ -1,5 +1,5 @@ { - "https://github.com/simplex-chat/simplexmq.git"."b981dcb70b8c99dc3733a99b6c1dc0d0ef83a3f7" = "0wpri01w30rd3wwzw630yngnj9fmyb7rschl3ic1cjd926vpg9b7"; + "https://github.com/simplex-chat/simplexmq.git"."39bd7205e202061d96d145e63bca21c69e99e278" = "0l8if749k2dzsgb52whwka4p3j37angpa4jpwg52lfqh169qc6qj"; "https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38"; "https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d"; "https://github.com/simplex-chat/sqlcipher-simple.git"."a46bd361a19376c5211f1058908fc0ae6bf42446" = "1z0r78d8f0812kxbgsm735qf6xx8lvaz27k1a0b4a2m0sshpd5gl"; diff --git a/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql b/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql index ccff26b38d..871490db43 100644 --- a/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql +++ b/src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql @@ -19,7 +19,12 @@ CREATE TABLE contact_profiles( preferences TEXT, contact_link BLOB, short_descr TEXT, - chat_peer_type TEXT + chat_peer_type TEXT, + badge_proof BLOB, + badge_pres_header BLOB, + badge_expiry TEXT, + badge_type TEXT, + badge_verified INTEGER NOT NULL DEFAULT 0 ) STRICT; CREATE TABLE users( user_id INTEGER PRIMARY KEY,