-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathComAtprotoSync_GetRepo.cs
More file actions
35 lines (27 loc) · 1004 Bytes
/
Copy pathComAtprotoSync_GetRepo.cs
File metadata and controls
35 lines (27 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Microsoft.AspNetCore.Http;
namespace dnproto.pds.xrpc;
public class ComAtprotoSync_GetRepo : BaseXrpcCommand
{
public async Task<IResult> GetResponseAsync()
{
IncrementStatistics();
//
// Get did
//
string? did = HttpContext.Request.Query["did"];
if(string.IsNullOrEmpty(did))
{
return Results.Json(new { error = "InvalidRequest", message = "Missing did" }, statusCode: 400);
}
if(did.Equals(Pds.PdsDb.GetConfigProperty("UserDid"), StringComparison.OrdinalIgnoreCase) == false)
{
return Results.Json(new { error = "NotFound", message = "Repo not found" }, statusCode: 404);
}
//
// Write the MST to stream, using "application/vnd.ipld.car" content type
//
HttpContext.Response.ContentType = "application/vnd.ipld.car";
await Pds.UserRepo.WriteToStreamAsync(HttpContext.Response.Body);
return Results.Empty;
}
}