Repository navigation
Hold a linked device's history on the server, not Gryt's relay (GRYT-2055) - #366
Merged
Merged
Conversation
…(GRYT-2055) Linking sent the old message history through Gryt's own pairing relay, up to 256 MiB a link. That cost grows with every user. The old device can now leave the sealed chunks on a server both devices are on, and the new device reads them back. It's the same user, because it has the same identity. PUT/GET /api/link-history/:transfer/:n and DELETE /api/link-history/:transfer, behind requireBearerToken. A transfer is visible only to the user who started it. Each user may hold 256 MiB in at most two transfers, a chunk is at most 2 MiB, and a transfer is deleted after an hour, when it's removed, or on a restart. The server can't read the chunks. /info says linkHistory: true where uploads are on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A server_config column, link_history, on by default, set through the same settings patch as the other server switches. When it's off, /api/link-history answers 403 link_history_off and /info says linkHistory: false. The old device then picks another server, or moves no history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new device drops each chunk once it has it, so the server's disk empties as the transfer goes, and that chunk's bytes stop counting against the user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part one of GRYT-2055: the server half of moving a linked device's message history off Gryt's own pairing relay. Today that history goes through
id.gryt.chat, up to 256 MiB a link, so the cost grows with every user. After this, the old device leaves the sealed chunks on a Gryt server both devices are on, and the new one reads them back. Nothing calls these endpoints until the core and app PRs land.What's new
src/routes/linkHistory.ts:PUT /api/link-history/:transfer/:n(raw bytes),GET /api/link-history/:transfer/:n,DELETE /api/link-history/:transfer.requireBearerTokenruns first, then a 401 if there's no server user. The raw-body parser comes after both.link-historyfolder underDATA_DIR, separate from uploads. The whole folder is wiped on start, because the in-memory index of transfers doesn't survive a restart./inforeturnslinkHistory: truewhen uploads are on, so the old device can pick a server that can hold history.Owners can turn it off (second commit)
server_config.link_historycolumn, on by default, set through the settings patch (linkHistory) the same way asvideoProfiles. Off means/api/link-historyanswers 403link_history_offand/infosayslinkHistory: false, so the old device picks another server or moves no history.src/db(the column, its migration and its mapping), which is a review-required path. Test:src/db/sqlite/linkHistorySetting.test.ts.Check
/infois open to everyone.linkHistorytells a stranger whether uploads are on. A failed upload tells them that anyway, but it is one more field.serverUserId. If two devices of one person could ever end up as different server users on the same server, the new device would get a 404 and no history. That fails safe. It wouldn't leak anything.rmonDATA_DIR/link-historydirectly rather than going throughsrc/storage, which has no "delete a folder". Storage is filesystem-only since 1.11.0.Tested
yarn test(2173 pass),yarn build, eslint on the changed files, comment length.Next PRs: core gets a server-backed chunk store and drops the relay for history. Then the client and the phone use it. Then the relay's chunk limit goes to zero and the endpoints are removed.
🤖 Generated with Claude Code