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>
This commit is contained in:
Evgeny
2026-06-01 21:33:35 +01:00
committed by GitHub
parent 5ac3e71d97
commit 83f4f6cd38
8 changed files with 21 additions and 21 deletions
+1 -1
View File
@@ -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 {
@@ -2219,7 +2219,7 @@ data class PublicGroupAccess(
@Serializable
data class RelayCapabilities(
val baseWebUrl: String? = null
val webDomain: String? = null
)
@Serializable
+1 -1
View File
@@ -3361,7 +3361,7 @@ ParseError:
## RelayCapabilities
**Record type**:
- baseWebUrl: string?
- webDomain: string?
---
@@ -3762,7 +3762,7 @@ export namespace RcvMsgError {
}
export interface RelayCapabilities {
baseWebUrl?: string
webDomain?: string
}
export interface RelayProfile {
@@ -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
+10 -10
View File
@@ -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 <baseWebUrl>/<publicGroupId>.json
├── Serves JSON at https://<webDomain>/group/<publicGroupId>.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
<div id="simplex-channel"
data-channel-id="<publicGroupId>"
data-relays="<baseWebUrl1>,<baseWebUrl2>">
data-relays="<webDomain1>,<webDomain2>">
</div>
<script src="https://simplex.chat/channel-preview.js"></script>
```
@@ -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`
+2 -2
View File
@@ -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 [])
+4 -4
View File
@@ -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 =