git ssb

30+

cel / git-ssb-web



Commit 0411de2819fd37e1f9396464199f86706819a483

Handle about message with string image property

Fix %zCMPlRVQ/bz6NjNT6Guj5yv3McskZdvvXQlwoH5VcmY=.sha256
Charles Lehner committed on 7/29/2016, 5:52:42 AM
Parent: 71104198f6cb039c70c3961bf6bd71165fb10d10

Files changed

lib/about.jschanged
lib/about.jsView
@@ -11,8 +11,12 @@
1111 var cat = require('pull-cat')
1212 var asyncMemo = require('asyncmemo')
1313 var u = require('./util')
1414
15+function getLink(obj) {
16+ return typeof obj === 'string' ? obj : obj ? obj.link : null
17+}
18+
1519 module.exports = function (sbot, id) {
1620 var getAbout = asyncMemo(getAboutFull, sbot, id)
1721
1822 getAbout.getName = function (id, cb) {
@@ -70,9 +74,9 @@
7074 var c = msg.value.content
7175 if (!info.name && c.name)
7276 info.name = c.name
7377 if (!info.image && c.image)
74- info.image = c.image.link
78+ info.image = getLink(c.image)
7579 }, function (err) {
7680 if (err && err !== true) return cb(err)
7781 if (!info.name) info.name = u.truncate(target, 20)
7882 cb(null, info)
@@ -96,14 +100,14 @@
96100 // TODO: give about from source (self) priority over about from owner
97101 if (c.name)
98102 info.name = c.name
99103 if (c.image)
100- info.image = c.image.link
104+ info.image = getLink(c.image)
101105 } else {
102106 if (c.name && !info.name)
103107 info.name = c.name
104108 if (c.image && !info.image)
105- info.image = c.image.link
109+ info.image = getLink(c.image)
106110 }
107111 }, function (err) {
108112 if (err) console.error('about', err)
109113 })

Built with git-ssb-web