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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Create and vote on polls on ssb
background details relevant to understanding what this module does
repos:
ssb://%uUPqduvyGE2mUBIWdVwMg4jYcKUjxN+TF2wG4a7StM8=.sha256
git@github.com:ssbc/scuttle-poll.git
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:
}
Requires a scuttlebutt server with the following plugins installed:
ssb-backlinks
ScuttlePoll = require('scuttle-poll')
scuttlePoll = ScuttlePoll(server)
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)
With npm installed, run
m install scuttle-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
pe: 'position',
ot: MessageKey,
tails: Object
chooseOne details:
oice:
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.
MIT