-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathComAtprotoIdentity_ResolveHandle.cs
More file actions
50 lines (37 loc) · 1.28 KB
/
Copy pathComAtprotoIdentity_ResolveHandle.cs
File metadata and controls
50 lines (37 loc) · 1.28 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using dnproto.ws;
using Microsoft.AspNetCore.Http;
namespace dnproto.pds.xrpc;
public class ComAtprotoIdentity_ResolveHandle : BaseXrpcCommand
{
public IResult GetResponse()
{
IncrementStatistics();
//
// Get param
//
string? actor = HttpContext.Request.Query.ContainsKey("handle") ? (string?) HttpContext.Request.Query["handle"] : null;
if(string.IsNullOrEmpty(actor))
{
return Results.Json(new { error = "InvalidRequest", message = "Error: Params must have the property \"handle\"" }, statusCode: 400);
}
//
// Resolve actor
//
ActorInfo? actorInfo = BlueskyClient.ResolveActorInfo(actor, new ActorQueryOptions() { ResolveDidDoc = false } );
//
// Validate response.
//
if(actorInfo == null)
{
return Results.Json(new { error = "NotFound", message = "Error: Handle not found" }, statusCode: 404);
}
if(string.IsNullOrEmpty(actorInfo.Did))
{
return Results.Json(new { error = "NotFound", message = "Error: Handle not found" }, statusCode: 404);
}
//
// Return success
//
return Results.Json(new { did = actorInfo.Did }, statusCode: 200);
}
}