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

FieldTypeRequiredDescriptionConstraints
offer_idstringyesThe canonical (root) offer of the merge group; the vote row is stored on it.
  • pattern ^dof_[0-9A-HJKMNP-TV-Z]{26}$
listing_idstringyesThe offer the request addressed: the root, or an offer merged into it.
  • pattern ^dof_[0-9A-HJKMNP-TV-Z]{26}$
valueenumyesThe new effective vote; 0 = removed.
  • one of 1, -1, 0
previousenumyesThe effective vote before; always different from value.
  • one of 1, -1, 0
weightnumberyesWeight stored with this vote: 1, or DEALS_NEW_ACCOUNT_WEIGHT (default 0.25) for an account new to Deals.
votesobjectyesTally of effective votes across the merge group after the change (a voter counts once).
  • no other fields
votes.upintegeryes
  • minimum 0
votes.downintegeryes
  • minimum 0
votes.up_weightnumberyesSum of the up voters' weights, 4 decimals.
votes.down_weightnumberyesSum of the down voters' weights, 4 decimals.
hotnessobjectyesThe snapshot taken with this vote; its inputs are kept in deal_hotness_snapshots (GET /api/v1/offers/:id/hotness).
  • no other fields
hotness.formulastringyesCurrently hot@1: hot = round6(score / (ageHours + 2)^1.5).
  • pattern ^hot@[0-9]+$
hotness.hotnumberyes
hotness.scorenumberyesup_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 }] }