Repository navigation
A vote hook for NX Credit (off unless configured) - #1006
Merged
Merged
Conversation
…/POST /vote, which gives an account RUSTMS_VOTE_NX NX Credit once per RUSTMS_VOTE_COOLDOWN_HOURS (votes table)
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.
Row 205, NX source 4 (the last one): the world server can listen for a vote site. When a site reports a vote, the account gets NX Credit, once per cooldown. The hook is off unless configured.
RUSTMS_VOTE_HOOK_ADDRplusRUSTMS_VOTE_HOOK_SECRETturn it on.RUSTMS_VOTE_NX(default 1000) andRUSTMS_VOTE_COOLDOWN_HOURS(default 12) set the amount and the cooldown.runtime::vote_hook): a site sendsGETorPOST /votewithaccount(the login name) andsecret. They can come in the query, a form body, or anX-Vote-Secretheader. The head is capped at 8 KB, the body at 4 KB, and a caller has 5 s to send its request. The secret is compared in constant time.votestable, written bydb::vote::record. One transaction locks the account row, checks the last vote against the cooldown, inserts the vote and adds the credit.db::cash_shop::grantnow shares its credit logic with it (add_cash).HARNESS_VOTE_PORT). The newtests/vote_hook.rscovers a wrong secret (403), an unknown account (404), a form POST with the header secret (200), a second vote (429), and the credit in the Cash Shop.Verified:
cargo test -p runtime vote_hook: 3 parser tests pass.vote_hook,earned_nx,gm_commandsandlogin_to_worldpass.