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

Commit feffe9a

Browse files
committed
Unify returns, Add 204 response to GET /data
1 parent c2d81e8 commit feffe9a

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

api/src/core/routes/migration.tsp

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace Migration {
1919
@tag("Migration - Registration required")
2020
@route("/migration/")
2121
namespace Registered {
22-
//TODO: Add routes concerned with data migration.
2322
@route("/redirect")
2423
@post
2524
@added(Version.`v1.0-alpha.1`)
@@ -32,7 +31,9 @@ namespace Migration {
3231
* 1. A key trial must be passed
3332
* 2. The "new" actor named in this request must confirm setting up this redirect.
3433
*
35-
* @returns `200` if the link has been created, `202` if the other account still needs to accept to establish the link. Returns a key trial
34+
* @returns
35+
* - `200` if the link has been created
36+
* - `202` if the other account still needs to accept to establish the link. Contains a key trial
3637
* @param newActorFid The FID of the actor, that this actor would like to be redirected to.
3738
*/
3839
op setupRedirect(@body newActorFid: string): {
@@ -81,7 +82,9 @@ namespace Migration {
8182
/**
8283
* Tell the homeserver of the "old" actor account that you intend to set up a redirect to
8384
* this actor
84-
* @returns `200` if the link has been created, `202` if the other account still needs to accept to establish the link.
85+
* @returns
86+
* - `200` if the link has been created
87+
* - `202` if the other account still needs to accept to establish the link.
8588
*/
8689
op setupRedirectExtern(@body redirectSourceFid: string): {
8790
@statusCode statusCode: 202 | 200
@@ -93,7 +96,9 @@ namespace Migration {
9396
@summary("Abort message re-signing")
9497
/**
9598
* Stop an in-progress or existing re-signing process.
96-
* @returns `204`: Action executed; `404`: No re-signing request found for mentioned actor
99+
* @returns
100+
* - `204` Action executed
101+
* - `404` No re-signing request found for mentioned actor
97102
* @param removeActorFid The FID of the actor to whom messages should no longer be re-signable for
98103
*/
99104
op removeResigningExtern(@query removeActorFid: string): {
@@ -109,7 +114,7 @@ namespace Migration {
109114
@summary("Request message re-signing")
110115
/**
111116
* Request allowing message re-signing. To fulfill this action, a key trial must be passed.
112-
* @returns Returns a key trial
117+
* @returns a key trial
113118
* @param allowedResigningKeys List of PEM encoded `SubjectPublicKeyInfo`s. Only key pairs mentioned in this list are allowed to re-sign messages after the key trial has been passed.
114119
*/
115120
op requestAllowResigning(@body body: { newActorFid: string, allowedResigningKeys: string[] }): {
@@ -124,7 +129,12 @@ namespace Migration {
124129
/**
125130
* Commit messages that have been re-signed to the server.
126131
* @param messages Messages. The distinct format of messages is up to the specific p2 extension to define.
127-
* @returns `200` On success; `400` if re-signed messages are improperly formatted; `403` if messages have been modified where the original keys have not passed the key trial, if a key trial has not been passed at all or if the messages have been signed with keys that were not on the `allowedResigningKeys` list.
132+
* @returns
133+
* - `200` On success
134+
* - `400` if re-signed messages are improperly formatted
135+
* - `403` if messages have been modified where the original keys have not passed the key
136+
* trial, if a key trial has not been passed at all or if the messages have been signed
137+
* with keys that were not on the `allowedResigningKeys` list.
128138
*/
129139
op commitMessages(@body messages: polyproto.core.models.MessageBatch<string>[]): {
130140
@statusCode statusCode: 200 | 400 | 403;
@@ -160,7 +170,10 @@ namespace Migration {
160170
* allow changes which concern information tied to these exact keys.
161171
*
162172
* @param body Completed key trials.
163-
* @returns Returns `200` if the key trials were processed and deemed to be valid. Returns `202`, if the server needs additional time to process the key trials. 400 is received if one or more completed key trials were faulty. Contains faulty key trials in the response body.
173+
* @returns
174+
* - `200` if the key trials were processed and deemed to be valid
175+
* - `202`, if the server needs additional time to process the key trials
176+
* - `400`, if one or more completed key trials were faulty. Contains faulty key trials in the response body.
164177
*/
165178
op keyTrialRedirectExtern(@body body: polyproto.core.models.KeyTrialCompleted[]): {
166179
@doc("Returns `200` if the key trials were processed and deemed to be valid. Returns `202`, if the server needs additional time to process the key trials.")
@@ -183,7 +196,10 @@ namespace Migration {
183196
*
184197
* Only key trials which have at least one completion, and - more importantly - where the
185198
* `expiration` UNIX time stamp has passed, can be fetched.
186-
* @returns `204`: No keytrials found for specified actor; `404`: Specified actor not known; `200`: Completed key trials of requested actor
199+
* @returns
200+
* - `204`: No keytrials found for specified actor
201+
* - `404`: Specified actor not known
202+
* - `200`: Completed key trials of requested actor
187203
*/
188204
op getKeyTrials(@path fid: string, @query limit?: uint16 = 0): {
189205
@statusCode statusCode: 204;
@@ -207,7 +223,9 @@ namespace Migration {
207223
* Delete all data associated with you from the server.
208224
* @param breakRedirect If a redirect has been set up previously: Whether to break that redirect
209225
* with this action. Defaults to false.
210-
* @returns `202` and a key trial, if one still needs to be passed; `204`: Action executed
226+
* @returns
227+
* - `202` and a key trial, if one still needs to be passed
228+
* - `204`: Action executed
211229
*/
212230
op deleteData(@query breakRedirect?: boolean = false): {
213231
@statusCode statusCode: 202;
@@ -223,8 +241,12 @@ namespace Migration {
223241
@summary("Export all data")
224242
/**
225243
* Export all of your data for safekeeping or for importing it to another server
226-
* @returns `202` and a key trial, if one still needs to be passed; `200` and the
227-
* appropriate data if the key trial has been passed and is not yet expired.
244+
* @returns - `202` and a key trial, if one still needs to be passed
245+
* - `200` and the appropriate data if the key trial has been passed and is not yet expired.
246+
* - `204` if the server needs time to gather the data. A `Retry-After` header is included in
247+
* the response, indicating to the actor the point in time at which they should query this
248+
* endpoint again. If this point in time is after the expiry timestamp of the completed key trial,
249+
* another key trial needs to be performed to access the data.
228250
* Contains all data of the user.
229251
*/
230252
op exportData(): {
@@ -233,6 +255,13 @@ namespace Migration {
233255
} | {
234256
@statusCode statusCode: 200;
235257
@body body: polyproto.core.models.MessageBatch<string>[];
258+
} | {
259+
@statusCode statusCode: 204;
260+
@header({name: "Retry-After"}) retryAfter: uint64;
236261
};
237262
}
238-
}
263+
}
264+
265+
/* TODO things that are missing:
266+
* - CawR routes
267+
*/

0 commit comments

Comments
 (0)