예제 #1
0
        public async Task Post([FromBody] TopGgWebhook baseHook, [FromHeader(Name = "Authorization")] string auth)
        {
            if (auth != _cfg.TopGgApiKey)
            {
                return;
            }

            var dbWebhook = new DatabaseUpvoteWebhook
            {
                BotId       = baseHook.BotId.AsUlong(),
                UserId      = baseHook.UserId.AsUlong(),
                UpvoteType  = baseHook.Type,
                IsWeekend   = baseHook.IsWeekend,
                QueryParams = baseHook.Query,
                TimeVoted   = DateTime.Now.ToOADate(),
                VoteId      = Guid.NewGuid().ToString()
            };

            try
            {
                await _db.InsertAsync(dbWebhook);

                _uvNotifier.Enqueue(dbWebhook);
            }
            catch (Exception e)
            {
                await ConsoleLogger.LogAsync(e, "An error occurred when trying to insert a Top.GG authorized " +
                                             $"webhook for user {dbWebhook.UserId}.");

                return;
            }


            await ConsoleLogger.LogAsync($"[Kaguya Api]: Authorized Top.GG Webhook received for user {dbWebhook.UserId}.", LogLvl.INFO);
        }
예제 #2
0
 public void Enqueue(DatabaseUpvoteWebhook item) => _voteQueue.Add(item);