Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit a76b1a7

Browse files
committed
Define behavior for RawR & data export/import
1 parent b62207d commit a76b1a7

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

api/src/core/routes/migration.tsp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,21 @@ namespace Migration {
6161
@post
6262
@added(Version.`v1.0-alpha.1`)
6363
@summary("Import data to server")
64+
@tag("Sensitive Actions")
6465
/**
65-
* //TODO
66+
* Import a `P2Export` file. `messages` in this file must have been re-signed to the current
67+
* actor. Only messages classified as ["Information not tied to a specific context"](https://docs.polyphony.chat/Protocol%20Specifications/core/#:~:text=Example%3A%20Information%20not,without%0Aany%20issues.)
68+
* can be imported.
69+
* @returns
70+
* - `202`: The content has been accepted for processing, but processing has not been
71+
* completed or may not have started.
6672
*/
67-
op importData(@body importData?: polyproto.core.models.MessageBatch<string>[]): {
73+
op importData(
74+
@doc("Sensitive actions require a second factor of authentication to be executed. Read [section 4.1.2 of the protocol definition](https://docs.polyphony.chat/Protocol%20Specifications/core/#412-sensitive-actions) for more information.")
75+
@header({name: "X-P2-Sensitive-Solution"}) sensitiveSolution: string,
76+
@body importData?: polyproto.core.models.P2Export
77+
): {
6878
@statusCode statusCode: 202;
69-
@body body: polyproto.core.models.KeyTrial;
70-
} | {
71-
@statusCode statusCode: 204;
7279
@header({name: "Content-Length"}) contentLength: 0;
7380
};
7481
}
@@ -241,21 +248,10 @@ namespace Migration {
241248
@summary("Export all data")
242249
/**
243250
* Export all of your data for safekeeping or for importing it to another server
244-
* @returns - `202` and a key trial, if one still needs to be passed
251+
* @returns
252+
* - `202` and a key trial, if one still needs to be passed
245253
* - `200` and the appropriate data if the key trial has been passed and is not yet expired.
246-
* The data is a gzipped tarball (.tar.gz) named `export1234567890-user@subdomain.example.com`, where
247-
* - `export[numbers]` is the word `export` with 20 random digits appended to it
248-
* - `user` is the actors' name
249-
* - `subdomain.example.com` is the FQDN of the server the actor is registered on.
250-
*
251-
* This file archive contains a file `messages.json` which is a JSON `MessageBatch` of all
252-
* messages sent by the user. Note the [definition of the word "message" in polyproto](https://docs.polyphony.chat/Protocol%20Specifications/core/#:~:text=software%20for%20clients.-,message%2C%20messages,-%3A%20In%20the%20context).
253-
* If the server where the data export was requested from has [RawR](https://docs.polyphony.chat/Protocol%20Specifications/core/#731-resource-addressing-with-relative-roots)
254-
* enabled, the file archive will contain a folder named `rawr`. This folder contains all
255-
* RawR-content uploaded by the actor to that server. The files in this folder are named after
256-
* the resource ID. File extensions are only added if they were known to the server. An
257-
* example file name might be `2c851bfb6daffa944fa1723c7bd4d362ffbc9defe292f2daaf05e895989d179b.jxl`,
258-
* referencing the file which was hosted at `<server_url>/.p2/core/resource/2c851bfb6daffa944fa1723c7bd4d362ffbc9defe292f2daaf05e895989d179b.jxl`.
254+
* See the `P2Export` schema for more information.
259255
* - `204` if the server needs time to gather the data. A `Retry-After` header is included in
260256
* the response, indicating to the actor the point in time at which they should query this
261257
* endpoint again. If this point in time is after the expiry timestamp of the completed key trial,
@@ -267,7 +263,7 @@ namespace Migration {
267263
@body body: polyproto.core.models.KeyTrial;
268264
} | {
269265
@statusCode statusCode: 200;
270-
@body body: File;
266+
@body body: polyproto.core.models.P2Export;
271267
} | {
272268
@statusCode statusCode: 204;
273269
@header({name: "Retry-After"}) retryAfter: uint64;
@@ -276,6 +272,5 @@ namespace Migration {
276272
}
277273

278274
/* TODO things that are missing:
279-
* - RawR routes
280275
- The description of the RawR .tar.gz file format could be added into the p2 spec
281276
*/

0 commit comments

Comments
 (0)