Commit 0411de2819fd37e1f9396464199f86706819a483
Handle about message with string image property
Fix %zCMPlRVQ/bz6NjNT6Guj5yv3McskZdvvXQlwoH5VcmY=.sha256Charles Lehner committed on 7/29/2016, 5:52:42 AM
Parent: 71104198f6cb039c70c3961bf6bd71165fb10d10
Files changed
lib/about.js | changed |
lib/about.js | ||
---|---|---|
@@ -11,8 +11,12 @@ | ||
11 | 11 | var cat = require('pull-cat') |
12 | 12 | var asyncMemo = require('asyncmemo') |
13 | 13 | var u = require('./util') |
14 | 14 | |
15 | +function getLink(obj) { | |
16 | + return typeof obj === 'string' ? obj : obj ? obj.link : null | |
17 | +} | |
18 | + | |
15 | 19 | module.exports = function (sbot, id) { |
16 | 20 | var getAbout = asyncMemo(getAboutFull, sbot, id) |
17 | 21 | |
18 | 22 | getAbout.getName = function (id, cb) { |
@@ -70,9 +74,9 @@ | ||
70 | 74 | var c = msg.value.content |
71 | 75 | if (!info.name && c.name) |
72 | 76 | info.name = c.name |
73 | 77 | if (!info.image && c.image) |
74 | - info.image = c.image.link | |
78 | + info.image = getLink(c.image) | |
75 | 79 | }, function (err) { |
76 | 80 | if (err && err !== true) return cb(err) |
77 | 81 | if (!info.name) info.name = u.truncate(target, 20) |
78 | 82 | cb(null, info) |
@@ -96,14 +100,14 @@ | ||
96 | 100 | // TODO: give about from source (self) priority over about from owner |
97 | 101 | if (c.name) |
98 | 102 | info.name = c.name |
99 | 103 | if (c.image) |
100 | - info.image = c.image.link | |
104 | + info.image = getLink(c.image) | |
101 | 105 | } else { |
102 | 106 | if (c.name && !info.name) |
103 | 107 | info.name = c.name |
104 | 108 | if (c.image && !info.image) |
105 | - info.image = c.image.link | |
109 | + info.image = getLink(c.image) | |
106 | 110 | } |
107 | 111 | }, function (err) { |
108 | 112 | if (err) console.error('about', err) |
109 | 113 | }) |
Built with git-ssb-web