DealsVoteChangedPayload deals.vote.changed@1
Generated at from
openvibe-contracts v0.34.2 and
openvibe-sdk v0.5.0.
- Version
- 1.0.0
- Owner
- deals
- Visibility
- first-party
- Status
- active
- Compatibility
- backward
- Schema
https://openvibe.network/contracts/events/payloads/deals.vote.changed.v1.json
deals.vote.changed v1 (OpenVibe.Deals server/domain/votes.js apply). A person's effective vote on an offer's merge group changed: set to +1 or -1 (PUT /offers/:id/vote, deals.vote.set) or removed, value 0 (DELETE /offers/:id/vote, deals.vote.remove). Nothing is sent when the vote did not change. Written in the transaction that stored the vote row and a hotness snapshot (reason vote). The payload carries counts and the recomputable hot@1 snapshot, not identities: the voter appears only as the envelope actor, and the IP hash and any vote-ring flags stay in Deals. Envelope: subject { type: offer, id: <canonical offer_id> }, visibility internal, priority important (default), actor user:<voter usr_…> (also when a service casts the vote for them). No consumer is built yet.
Fields
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
offer_id | string | yes | The canonical (root) offer of the merge group; the vote row is stored on it. |
|
listing_id | string | yes | The offer the request addressed: the root, or an offer merged into it. |
|
value | enum | yes | The new effective vote; 0 = removed. |
|
previous | enum | yes | The effective vote before; always different from value. |
|
weight | number | yes | Weight stored with this vote: 1, or DEALS_NEW_ACCOUNT_WEIGHT (default 0.25) for an account new to Deals. | |
votes | object | yes | Tally of effective votes across the merge group after the change (a voter counts once). |
|
votes.up | integer | yes |
| |
votes.down | integer | yes |
| |
votes.up_weight | number | yes | Sum of the up voters' weights, 4 decimals. | |
votes.down_weight | number | yes | Sum of the down voters' weights, 4 decimals. | |
hotness | object | yes | The snapshot taken with this vote; its inputs are kept in deal_hotness_snapshots (GET /api/v1/offers/:id/hotness). |
|
hotness.formula | string | yes | Currently hot@1: hot = round6(score / (ageHours + 2)^1.5). |
|
hotness.hot | number | yes | ||
hotness.score | number | yes | up_weight - down_weight, 4 decimals. |
Examples
From the contract's own test fixtures: valid ones validate, rejected ones must fail.
Valid: removed-on-merged-listing
{
"offer_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"listing_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPV",
"value": 0,
"previous": -1,
"weight": 0.25,
"votes": {
"up": 3,
"down": 0,
"up_weight": 2.25,
"down_weight": 0
},
"hotness": {
"formula": "hot@1",
"hot": 0.029138,
"score": 2.25
}
}Valid: upvote
{
"offer_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"listing_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"value": 1,
"previous": 0,
"weight": 1,
"votes": {
"up": 3,
"down": 1,
"up_weight": 2.25,
"down_weight": 1
},
"hotness": {
"formula": "hot@1",
"hot": 0.067496,
"score": 1.25
}
}Rejected: missing-hotness
{
"offer_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"listing_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"value": 1,
"previous": 0,
"weight": 1,
"votes": {
"up": 3,
"down": 1,
"up_weight": 2.25,
"down_weight": 1
}
}Rejected: value-two
{
"offer_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"listing_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"value": 2,
"previous": 0,
"weight": 1,
"votes": {
"up": 3,
"down": 1,
"up_weight": 2.25,
"down_weight": 1
},
"hotness": {
"formula": "hot@1",
"hot": 0.067496,
"score": 1.25
}
}Rejected: voter-identity
{
"offer_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"listing_id": "dof_01JAB2C3D4E5F6G7H8J9K0MNPQ",
"value": 1,
"previous": 0,
"weight": 1,
"votes": {
"up": 3,
"down": 1,
"up_weight": 2.25,
"down_weight": 1
},
"hotness": {
"formula": "hot@1",
"hot": 0.067496,
"score": 1.25
},
"subject": "usr_01JAB2C3D4E5F6G7H8J9K0MNPX"
}Validate
const contracts = require('openvibe-contracts');
contracts.validate('deals.vote.changed@1', value); // { valid, errors: [{ path, message }] }