From 83f4f6cd382f0262905f8b3832f15d897052902a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 1 Jun 2026 21:33:35 +0100 Subject: [PATCH] core: rename field in protocol (#7038) * core: rename field in protocol * update bot apis --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com> --- apps/ios/SimpleXChat/ChatTypes.swift | 2 +- .../chat/simplex/common/model/ChatModel.kt | 2 +- bots/api/TYPES.md | 2 +- .../types/typescript/src/types.ts | 2 +- .../src/simplex_chat/types/_types.py | 2 +- plans/2026-05-25-channel-web-preview.md | 20 +++++++++---------- src/Simplex/Chat/Protocol.hs | 4 ++-- src/Simplex/Chat/Store/Groups.hs | 8 ++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index 7181ba2de0..5e0c302720 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -2539,7 +2539,7 @@ public struct PublicGroupAccess: Codable, Hashable { } public struct RelayCapabilities: Codable, Hashable { - public var baseWebUrl: String? + public var webDomain: String? } public struct PublicGroupProfile: Codable, Hashable { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index 8ecfa0fd93..11c0f9e7f6 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -2219,7 +2219,7 @@ data class PublicGroupAccess( @Serializable data class RelayCapabilities( - val baseWebUrl: String? = null + val webDomain: String? = null ) @Serializable diff --git a/bots/api/TYPES.md b/bots/api/TYPES.md index 4875079749..a87bcae5e4 100644 --- a/bots/api/TYPES.md +++ b/bots/api/TYPES.md @@ -3361,7 +3361,7 @@ ParseError: ## RelayCapabilities **Record type**: -- baseWebUrl: string? +- webDomain: string? --- diff --git a/packages/simplex-chat-client/types/typescript/src/types.ts b/packages/simplex-chat-client/types/typescript/src/types.ts index f0cf58de64..5e671169de 100644 --- a/packages/simplex-chat-client/types/typescript/src/types.ts +++ b/packages/simplex-chat-client/types/typescript/src/types.ts @@ -3762,7 +3762,7 @@ export namespace RcvMsgError { } export interface RelayCapabilities { - baseWebUrl?: string + webDomain?: string } export interface RelayProfile { 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 08308ed2d4..66ba77c062 100644 --- a/packages/simplex-chat-python/src/simplex_chat/types/_types.py +++ b/packages/simplex-chat-python/src/simplex_chat/types/_types.py @@ -2640,7 +2640,7 @@ RcvMsgError = RcvMsgError_dropped | RcvMsgError_parseError RcvMsgError_Tag = Literal["dropped", "parseError"] class RelayCapabilities(TypedDict): - baseWebUrl: NotRequired[str] + webDomain: NotRequired[str] class RelayProfile(TypedDict): displayName: str diff --git a/plans/2026-05-25-channel-web-preview.md b/plans/2026-05-25-channel-web-preview.md index de0f02506b..561d3948e7 100644 --- a/plans/2026-05-25-channel-web-preview.md +++ b/plans/2026-05-25-channel-web-preview.md @@ -19,7 +19,7 @@ simplex-chat CLI (--relay --web-json-dir=... --web-base-url=...) └── Regenerate Caddy CORS config → caddy reload Caddy (operator-configured) - ├── Serves JSON at /.json + ├── Serves JSON at https:///group/.json └── Imports generated CORS config file Channel page (static HTML+JS, hosted by owner or on GitHub) @@ -105,7 +105,7 @@ Extend `toPublicGroupProfile` to accept and pass through `Maybe PublicGroupAcces New record for relay capabilities (extensible for future fields): ```haskell data RelayCapabilities = RelayCapabilities - { baseWebUrl :: Maybe Text + { webDomain :: Maybe Text } ``` @@ -132,7 +132,7 @@ Encoding: `XGrpRelayCap cap -> o ["relayCap" .= cap]` Sent by relay to owner only when capabilities change (not periodic). Relay detects change by comparing current config against persisted state on startup. -### 3. Store `baseWebUrl` per relay +### 3. Store `webDomain` per relay **File:** `src/Simplex/Chat/Operators.hs` (line 278) @@ -152,7 +152,7 @@ Add: `relayCap :: Maybe RelayCapabilities` Stored as separate columns (same pattern as `PublicGroupAccess`): **Migration:** `ALTER TABLE group_relays ADD COLUMN base_web_url TEXT` -`relayCap` constructed from columns: `Just RelayCapabilities {baseWebUrl}` when any capability column is non-NULL, `Nothing` otherwise. +`relayCap` constructed from columns: `Just RelayCapabilities {webDomain}` when any capability column is non-NULL, `Nothing` otherwise. **Handlers in `src/Simplex/Chat/Library/Subscriber.hs`:** - `XGrpRelayAcpt` (line 770): store `RelayCapabilities` in relay record on acceptance @@ -168,7 +168,7 @@ New record bundling all web preview options: ```haskell data RelayWebOptions = RelayWebOptions { webJsonDir :: FilePath, -- --web-json-dir: where to write JSON files - webBaseUrl :: Text, -- --web-base-url: public URL prefix (sent in XGrpRelayAcpt) + webDomain :: Text, -- --web-base-url: public URL prefix (sent in XGrpRelayAcpt) webCorsFile :: FilePath, -- --web-cors-file: generated Caddy CORS config path webUpdateInterval :: Int -- --web-update-interval: seconds (default 300) } @@ -443,7 +443,7 @@ data class PublicGroupProfile( @Serializable data class RelayCapabilities( - val baseWebUrl: String? = null + val webDomain: String? = null ) // Extend existing GroupRelay: @@ -473,7 +473,7 @@ New nav destination opens `ChannelWebPageView`. - Text field: domain (`groupDomain`) - Toggle: allow embedding (`allowEmbeding`) - Toggle: show on domain's page (`domainWebPage`) - stored but inert until RSLV ships -- Section: embed snippet (read-only, auto-generated from relay `baseWebUrl` values + `publicGroupId`) +- Section: embed snippet (read-only, auto-generated from relay `webDomain` values + `publicGroupId`) - Save button -> `apiUpdateGroup` with updated `GroupProfile` ### Subscriber: Channel info page @@ -518,12 +518,12 @@ simplex-chat --relay \ ### Embed snippet (shown to owner) -The "Channel web page" screen auto-generates this from the channel's relay `baseWebUrl` values and `publicGroupId`. Owner copies it into their page: +The "Channel web page" screen auto-generates this from the channel's relay `webDomain` values and `publicGroupId`. Owner copies it into their page: ```html
+ data-relays=",">
``` @@ -565,7 +565,7 @@ Separate repo or folder. `channel-preview.js` + minimal CSS: - `src/Simplex/Chat/Protocol.hs` - `RelayCapabilities` record, extend `XGrpRelayAcpt`, add `XGrpRelayCap` - `src/Simplex/Chat/Options.hs` - `RelayWebOptions` record, `relayWebOptions :: Maybe RelayWebOptions` in `CoreChatOpts` - `src/Simplex/Chat/Core.hs` - start web preview thread in `runSimplexChat` -- `src/Simplex/Chat/Operators.hs` - `baseWebUrl` in `GroupRelay` +- `src/Simplex/Chat/Operators.hs` - `webDomain` in `GroupRelay` - `src/Simplex/Chat/Store/Groups.hs` - read/write `PublicGroupAccess` columns; `getWebPublishGroups` - `src/Simplex/Chat/Store/Shared.hs` - `toPublicGroupAccess`, extend `toPublicGroupProfile` and `GroupInfoRow` - `src/Simplex/Chat/Library/Subscriber.hs` - handle `RelayCapabilities` in `XGrpRelayAcpt` and `XGrpRelayCap` diff --git a/src/Simplex/Chat/Protocol.hs b/src/Simplex/Chat/Protocol.hs index 71daeec635..9b8f6da766 100644 --- a/src/Simplex/Chat/Protocol.hs +++ b/src/Simplex/Chat/Protocol.hs @@ -263,12 +263,12 @@ data ReportReason = RRSpam | RRContent | RRCommunity | RRProfile | RROther | RRU deriving (Eq, Show) data RelayCapabilities = RelayCapabilities - { baseWebUrl :: Maybe Text + { webDomain :: Maybe Text } deriving (Eq, Show) defaultRelayCapabilities :: RelayCapabilities -defaultRelayCapabilities = RelayCapabilities {baseWebUrl = Nothing} +defaultRelayCapabilities = RelayCapabilities {webDomain = Nothing} $(pure []) diff --git a/src/Simplex/Chat/Store/Groups.hs b/src/Simplex/Chat/Store/Groups.hs index e2a9d6816a..8c207d99a7 100644 --- a/src/Simplex/Chat/Store/Groups.hs +++ b/src/Simplex/Chat/Store/Groups.hs @@ -1352,9 +1352,9 @@ groupRelayQuery = |] toGroupRelay :: (Int64, GroupMemberId, DBEntityId, ShortLinkContact, Text, Text, Maybe Text, Maybe ImageData, Text, BoolInt) :. (Maybe BoolInt, BoolInt, BoolInt, RelayStatus, Maybe ShortLinkContact, Maybe Text) -> GroupRelay -toGroupRelay ((groupRelayId, groupMemberId, chatRelayId, address, displayName, fullName, shortDescr, image, domains, BI preset) :. (tested, BI enabled, BI deleted, relayStatus, relayLink, baseWebUrl)) = +toGroupRelay ((groupRelayId, groupMemberId, chatRelayId, address, displayName, fullName, shortDescr, image, domains, BI preset) :. (tested, BI enabled, BI deleted, relayStatus, relayLink, webDomain)) = let userChatRelay = UserChatRelay {chatRelayId, address, relayProfile = toRelayProfile (displayName, fullName, shortDescr, image), domains = T.splitOn "," domains, preset, tested = unBI <$> tested, enabled, deleted} - relayCap = RelayCapabilities {baseWebUrl} + relayCap = RelayCapabilities {webDomain} in GroupRelay {groupRelayId, groupMemberId, userChatRelay, relayStatus, relayLink, relayCap} createRelayForOwner :: DB.Connection -> VersionRangeChat -> TVar ChaChaDRG -> User -> GroupInfo -> UserChatRelay -> ExceptT StoreError IO GroupMember @@ -1496,7 +1496,7 @@ setRelayLinkConfId db m confId relayLink = do (relayLink, currentTs, groupMemberId' m) updateRelayCapabilities :: DB.Connection -> GroupMember -> RelayCapabilities -> IO () -updateRelayCapabilities db m RelayCapabilities {baseWebUrl} = do +updateRelayCapabilities db m RelayCapabilities {webDomain} = do currentTs <- getCurrentTime DB.execute db @@ -1505,7 +1505,7 @@ updateRelayCapabilities db m RelayCapabilities {baseWebUrl} = do SET base_web_url = ?, updated_at = ? WHERE group_member_id = ? |] - (baseWebUrl, currentTs, groupMemberId' m) + (webDomain, currentTs, groupMemberId' m) getRelayConfId :: DB.Connection -> GroupMember -> ExceptT StoreError IO ConfirmationId getRelayConfId db m =