Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
)
}
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(
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
}
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)
})
})
})
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)
)
}
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) {
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
}
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)
})
}
}