ssbc/scuttle-poll

Name: scuttle-poll

Owner: Secure Scuttlebutt Consortium

Description: null

Created: 2018-02-26 01:12:07.0

Updated: 2018-05-14 09:45:45.0

Pushed: 2018-05-14 09:57:34.0

Homepage: null

Size: 455

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

scuttle-poll

Create and vote on polls on ssb

background details relevant to understanding what this module does

repos:

Usage
Init
Sbot = require('ssb-client')
((err, server) => {
 (err) {
return console.log(err)

r ScuttlePoll = require('scuttle-poll')
r scuttlePoll = ScuttlePoll(server)

where server is a scuttlebot instance (or a remote connection provided by ssb-client)

Note - server can also be an observeable which resolves to a scuttlebot instance (this is more experimental, it will turn your sync functions into obs functions)

This returns an object with methods defined in methods.js that looks like:


ll: {
async: {
  chooseOne:  
  get:
},
sync: {
  isPoll:
  isChooseOnePoll:
} 

sition: {
async: {
  chooseOne:
  position:

},
sync: {
  isPosition:
  chooseOneResults:
} 


Dependencies

Requires a scuttlebutt server with the following plugins installed:

API
ScuttlePoll = require('scuttle-poll')
scuttlePoll = ScuttlePoll(server)
Methods
scuttle.poll.sync.isPoll(msg) => Boolean

Takes a msg or the contents of a msg

You can also check for subtypes of poll e.g.

ll.chooseOne(msg)
> Boolean
scuttle.poll.async.get(key, cb)

fetches all the messages associated with a particular poll, and returns a delightfully accessible object:


y:       MessageKey,
lue:     MessageValue,

thor:    FeedId,
tle:     String,
dy:      (String|Null),

sitions: Array,
sults:   Array,
rors:    Object

scuttle.poll.async.publishChooseOne(opts, cb)

// NOT BUILT YET

where opts is an object of form:


tle: String,    // required
oices: Array,   // required
dy: String,

and cb is a callback of signature (err, newPollMsg)

Install

With npm installed, run

m install scuttle-poll
Schemas
Poll

Poll message content


pe:       'poll',          // required
tails: PollDetails     // required
tle:       String,         // required
osesAt:    Integer         // required
dy:        String,
annel,
ntions,
cps

Where PollDetails is an object which has the details needed for each type of poll: Dot, Proposal, Score

Dot vote PollDetails


pe: 'dot', // required
xStanceScore: 'Integer >= 0', // required
xChoiceScore: 'Integer >= 0', //optional
oices: Array, // required

Proposal PollDetails


pe: 'proposal', // required
oposal: String, // required

Score PollDetails


pe: 'score', // required
xChoiceScore: 'Integer >= 0', //required
oices: Array, // required

Position

pe:           'position',
ot:            MessageKey,
tails: Object

chooseOne details:


oice:


Acknowledgments

scuttle-poll was inspired by Loomio! Massive thanks to Rob Guthrie and James Kiesel for spending time giving us a brain dump of their data model.

See Also
License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.