fix(rust): send reward notices, and keep a downed line's credit rule (W21, W4)
W21: the permission push named its fields one by one and left out `notices`, so no kit reward, lend or give ever told its player anything (D333). The body is now built by `pushBody`, which carries every field the payload has; a test fails if a payload field is dropped again. W4: a downed patrol helicopter, Chinook or Bradley is stored with the credit rule in force when it arrived, and the feed reads that stamp. Before, the line re-credited past rows with the server's current rule while the Rotorbane/Tankbreaker counts kept the old one. Rows stored before this change keep today's reading. PLAN_LAST_FIXES.md stage 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -28,6 +28,7 @@ const rewards = require('../eventRewards')
|
||||
const leases = require('../eventLeases')
|
||||
const templates = require('../eventTemplates')
|
||||
const model = require('../model/permissions/permissions.model')
|
||||
const reconcile = require('../model/permissions/reconcile')
|
||||
|
||||
const entitle = rewards.ACTIONS.find((a) => a.id === 'rust.kit.entitle')
|
||||
const ok = (data) => ({ ok: true, status: 'ok', data })
|
||||
@@ -163,6 +164,19 @@ test('the sync carries each untold message to the account the reward picked', ()
|
||||
])
|
||||
})
|
||||
|
||||
test('the push carries the notices, and every other field the payload built (W21)', () => {
|
||||
const permSync = require('../permSync')
|
||||
const desired = model.buildDesired('main', authored([grantRow({ notice: 'You earned kit vip', noticeDelivery: 'chat' })]))
|
||||
const held = reconcile.withHold(desired, new Set())
|
||||
const body = permSync.pushBody(desired.hash, held.payload, [], [])
|
||||
assert.deepStrictEqual(body.notices, [
|
||||
{ key: '7:3:11', steamId: '76561190000000001', message: 'You earned kit vip', delivery: 'chat' },
|
||||
])
|
||||
// A field the model adds and the push forgets is how W21 happened.
|
||||
for (const field of Object.keys(held.payload)) assert.ok(field in body, `the push drops payload.${field}`)
|
||||
assert.strictEqual(body.setId, desired.hash)
|
||||
})
|
||||
|
||||
test('a notice moves the digest, so a new one is pushed and a told one is dropped', () => {
|
||||
const none = model.buildDesired('main', authored([grantRow({})]))
|
||||
const one = model.buildDesired('main', authored([grantRow({ notice: 'hi', noticeDelivery: 'chat' })]))
|
||||
|
||||
Reference in New Issue
Block a user