How to use the ssb-ref.isBlob 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 Happy0 / ssb-chess / modules_embedded / sbot.js View on Github external
content.mentions.forEach(function (mention) {
        if(ref.isBlob(mention.link)) {
          sbot.blobs.push(mention.link, function (err) {
            if(err) console.error(err)
          })
        }
      })
github Happy0 / ssb-chess / modules_basic / avatar / edit.js View on Github external
getAvatar({links: api.sbot_links}, self_id, id, (err, _avatar) => {
      if (err) return console.error(err)
      //don't show user has already selected an avatar.
      if(ref.isBlob(_avatar.image))
        avatar.original.set(api.blob_url(_avatar.image))
    })
github staltz / manyverse / src / ssb / opinions / sbot.ts View on Github external
content.mentions.forEach((mention: any) => {
                    if (Ref.isBlob(mention.link)) {
                      sbot.blobs.push(mention.link, (err: any) => {
                        if (err) console.error(err);
                      });
                    }
                  });
                }
github staltz / manyverse / src / backend / plugins / feedUtilsBack.ts View on Github external
publish(content: NonNullable<content>, cb: Callback) {
        if (content.recps) {
          content = ssbKeys.box(
            content,
            content.recps.map((e: any) =&gt; {
              return Ref.isFeed(e) ? e : e.link;
            }),
          );
        } else if ((content as PostContent).mentions) {
          for (const mention of (content as PostContent).mentions!) {
            if (Ref.isBlob(mention.link)) {
              ssb.blobs.push(mention.link, (err: any) =&gt; {
                if (err) console.error(err);
              });
            }
          }
        }

        ssb.publish(content, (err: any, msg: any) =&gt; {
          if (err) console.error(err);
          if (cb) cb(err, msg);
        });
      },
</content>
github ssbc / ssb-db / lib / validators.js View on Github external
blobId: function (v) {
    if (!ref.isBlob(v))
      return 'type'
  },
github Happy0 / ssb-chess / modules_basic / markdown.js View on Github external
toUrl: function (id) {
        if(ref.isBlob(id)) return api.blob_url(id)
        return '#'+(mentions[id]?mentions[id]:id)
      }
    })
github regular / ssb-cms / default-renderers.js View on Github external
function(value) {
      if (!ref.isBlob(value)) return
      return h('a', {href: `${config.blobsRoot}/${value}`}, value)
    },
    ho.basic()
github regular / ssb-cms / blobs.js View on Github external
traverse(kv.value.content || {}).forEach( function(v) {
      if (ref.isBlob(v)) {
        let blob = v
        let newBlob = !knownBlobs.has(blob)
        if (newBlob) {
          knownBlobs.add(blob)
          refs++
          updateStuff()
          
          if (!sizeObs[blob]) {
            sizeObs[blob] = Value('...')

            if (blobsLs.includes(blob)) {
              getSize(blob)
            } else {
              sizeObs[blob].set('wanted ...')
              ssb.blobs.want(blob, err => {
                if (err) return sizeObs[blob].set(err.message)
github Happy0 / ssb-chess / app / html / page / blob.js View on Github external
function blobView (path) {
    if (!ref.isBlob(path)) return

    return h('Blob', { id: path, title: path.slice(0, 9) + '...' }, [
      h('iframe', {
        src: api.blob.sync.url(path),
        sandbox: ''
      })
    ])
  }
}