feat: add v1 api client and webhook support - #35
Open
Zont1k wants to merge 10 commits into
Open
Conversation
Project, metrics, announcements, slash commands and votes for the new top.gg v1 api. Shared serializer options, loose string/number conversion and a robust ulong converter are included.
HMAC SHA-256 check against the x-topgg-signature header with an optional timestamp age limit, plus models for vote.create and webhook.test events.
v0 expects the raw token in the Authorization header. Removed the dead deserialization branch in GetAsync and flagged both clients as legacy.
The api field was never assigned, Stop() threw and there were two copies of DiscordNetDblUtils.
Posts server and shard count to PATCH /projects/@me/metrics on a timer, for regular and sharded clients.
Webhook signatures, event deserialization and the v1 client against a fake handler. Live v0 tests now skip unless BOT_ID and API_KEY are set.
Keeps recent votes in memory keyed by both top.gg and platform ids. Feed it from vote.create webhooks and check HasActiveVote without a single API call, so reward checks stay clear of the rate limits. Can be backfilled or refreshed from the v1 api.
Timer-based metrics posting for any project type, not just discord.net. Posts immediately on Start and then on a configurable interval (30 minutes by default), with Posted and PostFailed events.
GetAllVotesAsync crashed when the api returned a non-empty last page with no cursor.
Webhook ingestion, expiry, pruning and api sync for the cache; posting, failure and overlap handling for the autoposter. The sync test also catches the empty-cursor paging bug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the current top.gg v1 api to the library:
Version bumped to 1.7.0.