NetworkUserUpdatedPayload network.user.updated@1

Generated at from openvibe-contracts v0.44.0 and openvibe-sdk v0.9.1.

Version
1.0.0
Owner
network
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/events/payloads/network.user.updated.v1.json

network.user.updated v1 (OpenVibe.Network server/identity/profile-events.js; roadmap WS-B task 2). What other services may know about a person changed: their username, display name, picture, colour, role or ban. The payload is the person's whole current profile, not a diff, so a consumer keeps a projection by writing it over the one it has, and ignores one whose revision is not newer (events can arrive out of order). Emitted in the transaction of the change: a profile edit, a rename, a role grant or removal, a ban or unban. Consumers use it instead of their own copies: roles go both ways (a downgrade too), and a ban arrives even for someone who never comes back. Envelope: subject { type: user, id }, visibility internal, actor the person (their own edit) or the staff member.

Fields

FieldTypeRequiredDescriptionConstraints
subjectobjectyesThe person (identity.subject-ref@1, a user).
  • no other fields
subject.typeconstyes
  • = "user"
subject.idstringyes
  • pattern ^usr_[0-9A-HJKMNP-TV-Z]{26}$
network_user_idintegeryesNetwork's numeric user id (the legacy id services linked before subjects).
  • minimum 1
revisionintegeryesGrows with every change to this person's profile; a consumer keeps the highest it has seen.
  • minimum 1
usernamestringyes
  • minLength 1
  • maxLength 64
display_namestring | null
  • maxLength 120
avatar_urlstring | null
  • maxLength 500
profile_colorstring | null
  • maxLength 32
roleenumyesThe staff map's role (policy.staff-map); capabilities follow from it.
  • one of "user", "streamer", "global_mod", "admin"
bannedbooleanyes
changedarray of enumyesWhat this change touched ('created' for a new account), so a consumer can skip work it does not need.
  • minItems 1
  • unique items
  • items: one of "username", "display_name", "avatar_url", "profile_color", "role", "banned", "created"

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: renamed-and-banned
{
  "subject": {
    "type": "user",
    "id": "usr_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3"
  },
  "network_user_id": 7,
  "revision": 9,
  "username": "alex_new",
  "display_name": "Alex",
  "avatar_url": "https://openvibe.media/avatar/alex_new",
  "profile_color": null,
  "role": "streamer",
  "banned": true,
  "changed": [
    "username",
    "banned"
  ]
}
Valid: role-removed
{
  "subject": {
    "type": "user",
    "id": "usr_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3"
  },
  "network_user_id": 7,
  "revision": 4,
  "username": "alex",
  "display_name": "Alex",
  "avatar_url": null,
  "profile_color": "#8b5cf6",
  "role": "user",
  "banned": false,
  "changed": [
    "role"
  ]
}
Rejected: nothing-changed
{
  "subject": {
    "type": "user",
    "id": "usr_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3"
  },
  "network_user_id": 7,
  "revision": 1,
  "username": "alex",
  "role": "user",
  "banned": false,
  "changed": []
}
Rejected: unknown-role
{
  "subject": {
    "type": "user",
    "id": "usr_01J8Z3Q4R5S6T7V8W9X0Y1Z2A3"
  },
  "network_user_id": 7,
  "revision": 1,
  "username": "alex",
  "role": "owner",
  "banned": false,
  "changed": [
    "role"
  ]
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('network.user.updated@1', value);   // { valid, errors: [{ path, message }] }