How to use the ssb-ref.isMsg function in ssb-ref

To help you get started, we’ve selected a few ssb-ref examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssbc / ssb-peer-invites / types.js View on Github external
exports.isAccept = function (msg) {
  return isObject(msg) && isObject(msg.content) && (
    'user-invite/accept' === msg.content.type &&
    msg.content.id == msg.author &&
    ref.isMsg(msg.content.receipt) &&
    isMaybeBase64(msg.content.key) &&
    // can't verify this without having the invite message.
    // (that's intentional, forces implementers not to cut corners,
    // but to check that the receipt is correct)
    isSignature(msg.content.signature)
  )
}
github blockades / scuttle-dark-crystal / root / async / get.js View on Github external
return function (rootId, cb) {
    if (!isMsg(rootId)) return cb(new Error(`getRoot expects a Message key, got ${JSON.stringify(rootId)}`))

    // mix: could write this as server.get -> server.private.unbox
    // but this index gives us unboxed for free
    // and our test are publishing publish messages!

    const query = [{
      $filter: {
        key: rootId,
        value: {
          author: server.id,
          content: { type: 'dark-crystal/root' }
        }
      }
    }]

    pull(
github ticktackim / ticktack-workplan / ssb-server-ticktack.js View on Github external
function getBlogKey (blog) {
  if (isMsgRef(blog)) return blog
  // else if (isMsgRef(blog.key) && isBlog(blog)) return blog.key
  else if (isMsgRef(blog.key) && (isBlog(blog) || isPlog(blog))) return blog.key
}
github ssbc / ssb-ooo / index.js View on Github external
sbot.get.hook(function (fn, args) {
      var id = args[0]
      var cb = args[1]
      if(!isMsg(id.id || id))
        return fn.apply(this, args)
      if(id.ooo === false && isMsg(id.id)) fn(id, cb)
      else
        fn(id, function (err, value) {
          if(!err) cb(null, value)
          else get(id, function (_err, data) {
            if(_err) fn(id, cb) //just in-case, try the log again
            else cb(null, id.meta === true ? data : data.value)
          })
        })
    })
github regular / ssb-cms / db.js View on Github external
opts = opts || {}
    let syncCount = opts.sync ? (ref.isMsg(root) ? 3 : 2) : 1
    return pull(
      many([
        pull(
          pull.once(root),
          pull.asyncMap(getMessageOrDraft),
          pull.map( value => opts.sync ? [
            { key: root, value},
            { sync: true }
          ] : [ 
            { key: root, value}
          ]),
          pull.flatten()
        ),
        ref.isMsg(root) ? pull(
          ssb.links(Object.assign({}, opts, {
            rel: 'revisionRoot',
            dest: root,
            keys: true,
            values: true
          }))
        ) : pull.empty(),
        drafts.byRevisionRoot(root, opts)
      ]),
      uniqueKeys(),
      filterSync(syncCount)
    )
  }
github ProjectEntropy / scuttle-vue / modules / thread.js View on Github external
screen_view: function(id) {
    if(ref.isMsg(id)) {
      var meta = {
        type: 'post',
        root: id,
        branch: id //mutated when thread is loaded.
      }

      var content = h('div.column.scroller__content')
      var div = h('div.column.scroller',
        {style: {'overflow-y': 'auto'}},
        h('div.scroller__wrapper',
          content,
          api.message_compose(meta, {/*shrink: false,*/ placeholder: 'Write a reply'})
        )
      )

      api.message_name(id, function (err, name) {
github ticktackim / ticktack-workplan / message / obs / webshares.js View on Github external
function isShare(c) {
  if (c.type !== 'share') return false

  if (!c.share || !c.share.link || !ref.isMsg(c.share.link) || !c.share.hasOwnProperty('url')) {
    return false
  }

  return true
}
github blockades / scuttle-dark-crystal / recover / async / recombine.js View on Github external
return function recombine (root, cb) {
    if (!isMsg(root)) return cb(new Error('Invalid root'))

    fetch(server)(root, (err, data) => {
      if (err) return cb(err)
      mend(data, cb)
    })
  }
}