mirror of
https://github.com/spacebarchat/server.git
synced 2026-03-30 16:05:41 +00:00
some type fixes in UApi
This commit is contained in:
@@ -13,6 +13,7 @@ public class ApplicationRpcController : ControllerBase {
|
||||
//
|
||||
// }
|
||||
|
||||
// TODO: implement disclosures
|
||||
[HttpGet("disclosures")]
|
||||
public ApplicationDisclosures GetApplicationDisclosures(string applicationId) {
|
||||
return new ApplicationDisclosures {
|
||||
@@ -22,27 +23,22 @@ public class ApplicationRpcController : ControllerBase {
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks a list of flags as acknowledged
|
||||
/// </summary>
|
||||
/// <param name="applicationId">ID of the application</param>
|
||||
/// <param name="ack">The list of flags to mark as acknowledged</param>
|
||||
/// <returns>The new list of acknowledged flags</returns>
|
||||
[HttpPost("disclosures")]
|
||||
public ApplicationDisclosures AckApplicationDisclosures(string applicationId) {
|
||||
// TODO: type is wrong, normally only `disclosures` is returned
|
||||
return new ApplicationDisclosures {
|
||||
Disclosures = [],
|
||||
AckedDisclosures = [],
|
||||
AllAcked = true
|
||||
};
|
||||
public ApplicationDisclosureAck AckApplicationDisclosures(string applicationId, ApplicationDisclosureAck ack) {
|
||||
return ack;
|
||||
}
|
||||
}
|
||||
|
||||
public class ApplicationDisclosures {
|
||||
public class ApplicationDisclosureAck {
|
||||
[JsonPropertyName("disclosures")]
|
||||
public List<ApplicationDisclosureType> Disclosures { get; set; }
|
||||
|
||||
[JsonPropertyName("acked_disclosures")]
|
||||
public List<ApplicationDisclosureType> AckedDisclosures { get; set; }
|
||||
|
||||
[JsonPropertyName("all_acked")]
|
||||
public bool AllAcked { get; set; }
|
||||
|
||||
public enum ApplicationDisclosureType {
|
||||
UnspecifiedDisclosure = 0,
|
||||
IpLocation = 1,
|
||||
@@ -51,6 +47,14 @@ public class ApplicationDisclosures {
|
||||
}
|
||||
}
|
||||
|
||||
public class ApplicationDisclosures : ApplicationDisclosureAck {
|
||||
[JsonPropertyName("acked_disclosures")]
|
||||
public List<ApplicationDisclosureType> AckedDisclosures { get; set; }
|
||||
|
||||
[JsonPropertyName("all_acked")]
|
||||
public bool AllAcked { get; set; }
|
||||
}
|
||||
|
||||
public class RpcApplicationInfo {
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; }
|
||||
@@ -66,7 +70,7 @@ public class RpcApplicationInfo {
|
||||
|
||||
[JsonPropertyName("summary")]
|
||||
public string Summary { get; set; }
|
||||
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
public ApplicationType? Type { get; set; } // what is this?
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ app.Use((context, next) => {
|
||||
// add some special sauce
|
||||
app.Map("/", async context => {
|
||||
var client = new StreamingHttpClient();
|
||||
var cfg = context.RequestServices.GetService<UApiConfiguration>();
|
||||
var cfg = context.RequestServices.GetRequiredService<UApiConfiguration>();
|
||||
var requestMessage = new HttpRequestMessage(new HttpMethod(context.Request.Method), cfg.FallbackApiEndpoint);
|
||||
|
||||
foreach (var header in context.Request.Headers)
|
||||
@@ -122,11 +122,9 @@ app.Map("/", async context => {
|
||||
await context.Response.Body.WriteAsync(data);
|
||||
});
|
||||
|
||||
// fallback to proxy in case we dont have a specific endpoint...
|
||||
// TODO config
|
||||
app.MapFallback("{*_}", async context => {
|
||||
var client = new StreamingHttpClient();
|
||||
var cfg = context.RequestServices.GetService<UApiConfiguration>();
|
||||
var cfg = context.RequestServices.GetRequiredService<UApiConfiguration>();
|
||||
var requestMessage = new HttpRequestMessage(
|
||||
new HttpMethod(context.Request.Method),
|
||||
cfg.FallbackApiEndpoint + context.Request.Path + context.Request.QueryString
|
||||
|
||||
Reference in New Issue
Block a user