public ApiAuthService(HttpClient httpClient, IInterfaceConfigProvider <IApiConfig> configProvider, IEncryptionService encryption, IDatabaseProvider <PluginManifest> database)
     : base(httpClient)
 {
     httpClient.BaseAddress = new(configProvider.InitConfig(PluginManifest.ApiConfigFileName).PopulateApiConfig().ApiHost);
     _encryption            = encryption;
     _guildConfig           = database.GetMongoDatabase().GetCollection <GuildConfig>(nameof(GuildConfig));
 }
示例#2
0
    public BroadcastsListener(ILogger <BroadcastsListener> logger, IInterfaceConfigProvider <IApiConfig> configProvider,
                              DiscordClient discordClient, IDatabaseProvider <PluginManifest> database, TrustlistClient trustlistUserApiService)
    {
        IApiConfig config = configProvider.InitConfig(PluginManifest.ApiConfigFileName).PopulateApiConfig();

        _logger          = logger;
        _discordClient   = discordClient;
        _trustlistClient = trustlistUserApiService;
        _guildConfig     = database.GetMongoDatabase().GetCollection <GuildConfig>(nameof(GuildConfig));

        _hubConnection = new HubConnectionBuilder()
                         .WithUrl(config.ApiHost + "/hubs/trustlist")
                         .AddMessagePackProtocol()
                         .WithAutomaticReconnect()
                         .Build();

        void LogBroadcast(string name, ulong userid) => logger.LogDebug("Received SignalR Boradcast: {name} {userId}", name, userid);

        _hubConnection.On <ulong, TrustlistEntry>(nameof(ITrustlistHubPush.NotifyNewEntry), async(userId, entry) =>
        {
            LogBroadcast(nameof(ITrustlistHubPush.NotifyNewEntry), userId);
            await BroadcastUpdateAsync(BroadcastUpdateType.NewEntry, userId, entry);
        });

        _hubConnection.On <ulong, TrustlistEntry, byte>(nameof(ITrustlistHubPush.NotifyEscalatedEntry), async(userId, entry, level) =>
        {
            LogBroadcast(nameof(ITrustlistHubPush.NotifyEscalatedEntry), userId);
            await BroadcastUpdateAsync(BroadcastUpdateType.Escalation, userId, entry);
        });

        _hubConnection.On <ulong, TrustlistEntry>(nameof(ITrustlistHubPush.NotifyDeletedEntry), (userId, entry) =>
        {
            LogBroadcast(nameof(ITrustlistHubPush.NotifyDeletedEntry), userId);
        });
    }
示例#3
0
 public LocalEncryptionService(IInterfaceConfigProvider <IApiConfig> configProvider)
 {
     encryptionKey = configProvider.InitConfig(PluginManifest.ApiConfigFileName).PopulateApiConfig().EncryptionKey;
 }