git ssb

16+

Dominic / patchbay



Commit a4c97b2c28b8bb16232a873162d6d9992353cedc

Check link type before getting message

cel committed on 10/17/2016, 9:05:51 PM
Parent: 9018a0991550b3edcb6e308bf5957a8024df4487

Files changed

modules/message-link.jschanged
modules/notifications.jschanged
modules/message-link.jsView
@@ -1,5 +1,6 @@
11 var h = require('hyperscript')
2 +var ref = require('ssb-ref')
23
34 var sbot_get = require('../plugs').first(exports.sbot_get = [])
45
56 exports.message_link = function (id) {
@@ -8,8 +9,9 @@
89 throw new Error('link must be to message id')
910
1011 var link = h('a', {href: '#'+id}, id.substring(0, 10)+'...')
1112
13 + if(ref.isMsg(id))
1214 sbot_get(id, function (err, value) {
1315 if(err) {
1416 if (err.name == 'NotFoundError')
1517 link.textContent += ' (missing)'
modules/notifications.jsView
@@ -4,8 +4,9 @@
44 var Scroller = require('pull-scroll')
55 var paramap = require('pull-paramap')
66 var plugs = require('../plugs')
77 var cont = require('cont')
8 +var ref = require('ssb-ref')
89
910 var message_render = plugs.first(exports.message_render = [])
1011 var sbot_log = plugs.first(exports.sbot_log = [])
1112 var sbot_get = plugs.first(exports.sbot_get = [])
@@ -30,8 +31,9 @@
3031
3132 function isOurMsg(id, cb) {
3233 if (!id) return cb(null, false)
3334 if (typeof id === 'object' && typeof id.link === 'string') id = id.link
35 + if (!ref.isMsg(id)) return cb(null, false)
3436 sbot_get(id, function (err, msg) {
3537 if (err && err.name == 'NotFoundError') cb(null, false)
3638 else if (err) cb(err)
3739 else if (msg.content.type === 'issue' || msg.content.type === 'pull-request')

Built with git-ssb-web