summary refs log tree commit diff
path: root/extra/admin-api/Spacebar.UApi/Controllers/Applications/ApplicationRpcController.cs
blob: c8dc60caccefb06f19368607b407cac08464b94e (plain) (blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System.Text.Json.Serialization;
using ArcaneLibs.Collections;
using Microsoft.AspNetCore.Mvc;

namespace Spacebar.UApi.Controllers.Applications;

[ApiController]
[Route("/api/v{_}/applications/{applicationId}/")]
public class ApplicationRpcController : ControllerBase {
    private static LruCache<object> _rpcInfoCache = new(10000);
    // [HttpGet]
    // public async Task<object> GetApplicationRpcInfo(string applicationId) {
    //     
    // }

    // TODO: implement disclosures
    [HttpGet("disclosures")]
    public ApplicationDisclosures GetApplicationDisclosures(string applicationId) {
        return new ApplicationDisclosures {
            Disclosures = [],
            AckedDisclosures = [],
            AllAcked = true
        };
    }

    /// <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 ApplicationDisclosureAck AckApplicationDisclosures(string applicationId, ApplicationDisclosureAck ack) {
        return ack;
    }
}

public class ApplicationDisclosureAck {
    [JsonPropertyName("disclosures")]
    public List<ApplicationDisclosureType> Disclosures { get; set; }

    public enum ApplicationDisclosureType {
        UnspecifiedDisclosure = 0,
        IpLocation = 1,
        DisplaysAdvertisements = 2,
        PartnerSdkDataSharingMessage = 3
    }
}

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; }

    [JsonPropertyName("name")]
    public string Name { get; set; }

    [JsonPropertyName("icon")]
    public string Icon { get; set; }

    [JsonPropertyName("description")]
    public string Description { get; set; }

    [JsonPropertyName("summary")]
    public string Summary { get; set; }

    [JsonPropertyName("type")]
    public ApplicationType? Type { get; set; } // what is this?

    [JsonPropertyName("verify_key")]
    public string VerifyKey { get; set; }
}

[Flags]
public enum ApplicationType {
    DeprecatedGame,
    Music,
    TicketedEvents,
    CreatorMonetization,
    Game
}