{"id":28396219,"url":"https://github.com/ssbc/scuttle-poll","last_synced_at":"2025-06-23T06:32:18.041Z","repository":{"id":143907866,"uuid":"122894532","full_name":"ssbc/scuttle-poll","owner":"ssbc","description":null,"archived":false,"fork":false,"pushed_at":"2019-01-11T20:59:39.000Z","size":303,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-18T07:47:51.888Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ssbc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-02-26T01:12:07.000Z","updated_at":"2021-03-13T22:25:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"3536236d-ad10-485b-beee-2fdd3258c7ae","html_url":"https://github.com/ssbc/scuttle-poll","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/ssbc/scuttle-poll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fscuttle-poll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fscuttle-poll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fscuttle-poll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fscuttle-poll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssbc","download_url":"https://codeload.github.com/ssbc/scuttle-poll/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fscuttle-poll/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260952585,"owners_count":23087894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-31T21:37:26.385Z","updated_at":"2025-06-23T06:32:18.033Z","avatar_url":"https://github.com/ssbc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scuttle-poll\n\n\u003e Create and vote on polls on ssb\n\nbackground details relevant to understanding what this module does\n\nrepos:\n- git-ssb: `ssb://%uUPqduvyGE2mUBIWdVwMg4jYcKUjxN+TF2wG4a7StM8=.sha256`\n- github: `git@github.com:ssbc/scuttle-poll.git`\n\n## Usage\n\n### Init\n```js\nvar Sbot = require('ssb-client')\nSbot((err, server) =\u003e {\n  if (err) {\n    return console.log(err)\n  }\n  var ScuttlePoll = require('scuttle-poll')\n  var scuttlePoll = ScuttlePoll(server)\n})\n```\nwhere `server` is a scuttlebot instance (or a remote connection provided by `ssb-client`)\n\nNote - `server` can also be an observeable which resolves to a scuttlebot instance\n(this is more experimental, it will turn your sync functions into obs functions)\n\nThis returns an object with methods defined in `methods.js` that looks like:\n\n```js\n{\n  poll: {\n    async: {\n      chooseOne:  \n      get:\n    },\n    sync: {\n      isPoll:\n      isChooseOnePoll:\n    } \n  },\n  position: {\n    async: {\n      chooseOne:\n      position:\n    \n    },\n    sync: {\n      isPosition:\n      chooseOneResults:\n    } \n  }\n}\n\n```\n\n## Dependencies\n\nRequires a scuttlebutt server with the following plugins installed:\n  - `ssb-backlinks`\n\n\n## API\n\n```js\nvar ScuttlePoll = require('scuttle-poll')\nvar scuttlePoll = ScuttlePoll(server)\n```\n\n### Methods\n\n#### `scuttle.poll.sync.isPoll(msg) =\u003e Boolean`\n\nTakes a msg or the contents of a msg\n\nYou can also check for subtypes of poll e.g.\n\n```js\nisPoll.chooseOne(msg)\n// =\u003e Boolean\n```\n\n### `scuttle.poll.async.get(key, cb)`\n\nfetches all the messages associated with a particular poll, and returns a delightfully accessible object:\n\n```js\n{\n  key:        MessageKey,\n  value:      MessageValue,\n\n  author:     FeedId,\n  title:      String,\n  body:       (String|Null),\n\n  positions:  Array,\n  myPosition: Object,\n  results:    Array,\n  resolution: Msessage,\n  errors:     Object\n\n  heads:      Array\n}\n```\n\n\n#### `scuttle.poll.async.publishChooseOne(opts, cb)`\n\n// NOT BUILT YET\n\nwhere `opts` is an object of form:\n```js\n{\n  title: String,    // required\n  choices: Array,   // required\n  body: String,\n}\n```\nand `cb` is a callback of signature `(err, newPollMsg)`\n\n\n## Install\n\nWith [npm](https://npmjs.org/) installed, run\n\n```\n$ npm install scuttle-poll\n```\n\n## Schemas\n\n### Poll\n\nPoll message content\n```js\n{\n  type:       'poll',          // required\n  details: PollDetails     // required\n  title:       String,         // required\n  closesAt:    Integer         // required\n  body:        String,\n  channel,\n  mentions,\n  recps\n}\n\n```\n\nWhere `PollDetails` is an object which has the details needed for each type of poll: Dot, Proposal, Score\n\nDot vote PollDetails\n```js\n{\n  type: 'dot', // required\n  maxStanceScore: 'Integer \u003e= 0', // required\n  maxChoiceScore: 'Integer \u003e= 0', //optional\n  choices: Array, // required\n}\n```\n\nProposal PollDetails\n```js\n{\n  type: 'proposal', // required\n  proposal: String, // required\n}\n```\n\nScore PollDetails\n```js\n{\n  type: 'score', // required\n  maxChoiceScore: 'Integer \u003e= 0', //required\n  choices: Array, // required\n}\n```\n\n### Position\n\n```js\n{\n  type:           'position',\n  root:            MessageKey,\n  details: Object\n}\n```\n\nchooseOne details:\n```js\n{\n  choice:\n\n}\n```\n\n## Acknowledgments\n\n`scuttle-poll` was inspired by [Loomio](https://www.github.com/loomio/loomio)! Massive thanks to Rob Guthrie and James Kiesel for spending time giving us a brain dump of their data model.\n\n\n\n## See Also\n\n\n## License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fscuttle-poll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssbc%2Fscuttle-poll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fscuttle-poll/lists"}