-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAppBskyActor_GetPreferences.cs
More file actions
47 lines (40 loc) · 1.11 KB
/
Copy pathAppBskyActor_GetPreferences.cs
File metadata and controls
47 lines (40 loc) · 1.11 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
using System.Security.Claims;
using System.Text.Json.Nodes;
using dnproto.auth;
using dnproto.ws;
using Microsoft.AspNetCore.Http;
namespace dnproto.pds.xrpc;
/// <summary>
/// Preferences are the exception to the general rule of
/// "proxy requests to /xrpc/app.bsky.* to the AppView"
/// Not sure why.
/// </summary>
public class AppBskyActor_GetPreferences : BaseXrpcCommand
{
public IResult GetResponse()
{
IncrementStatistics();
//
// Require auth
//
if(UserIsAuthenticated() == false)
{
var (response, statusCode) = GetAuthenticationFailureResponse();
return Results.Json(response, statusCode: statusCode);
}
//
// Get preferences from PDS config
//
if(Pds.PdsDb.GetPreferencesCount() == 0)
{
// return 204
return Results.Json(new { }, statusCode: 204);
}
string? prefsJson = Pds.PdsDb.GetPreferences();
//
// Return prefs json
//
return Results.Json(JsonNode.Parse(prefsJson),
statusCode: 200);
}
}