mirror of
https://github.com/dariusk/rss-to-activitypub.git
synced 2024-11-22 17:29:19 +02:00
Fix bug in JSON parsing when fetching from DB
This commit is contained in:
parent
4966d0a922
commit
90ad278588
|
@ -16,10 +16,10 @@ router.get('/:name', function (req, res) {
|
||||||
return res.status(404).json(`No record found for ${name}.`);
|
return res.status(404).json(`No record found for ${name}.`);
|
||||||
}
|
}
|
||||||
else if (req.headers.accept.includes('application/activity+json') || req.headers.accept.includes('application/json') || req.headers.accept.includes('application/json+ld')) {
|
else if (req.headers.accept.includes('application/activity+json') || req.headers.accept.includes('application/json') || req.headers.accept.includes('application/json+ld')) {
|
||||||
res.json(result.actor);
|
res.json(JSON.parse(result.actor));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let actor = result.actor;
|
let actor = JSON.parse(result.actor);
|
||||||
let username = name.replace('@'+domain,'');
|
let username = name.replace('@'+domain,'');
|
||||||
console.log(username, actor);
|
console.log(username, actor);
|
||||||
let content = db.prepare('select content from feeds where username = ?').get(username);
|
let content = db.prepare('select content from feeds where username = ?').get(username);
|
||||||
|
@ -29,9 +29,10 @@ router.get('/:name', function (req, res) {
|
||||||
let feedData = JSON.parse(content.content);
|
let feedData = JSON.parse(content.content);
|
||||||
let imageUrl = null;
|
let imageUrl = null;
|
||||||
// if image exists set image
|
// if image exists set image
|
||||||
if (feedData.image && feedData.image.url) {
|
if (actor.icon && actor.icon.url) {
|
||||||
imageUrl = feedData.image.url;
|
imageUrl = actor.icon.url;
|
||||||
}
|
}
|
||||||
|
console.log(actor, imageUrl);
|
||||||
res.render('user', { displayName: actor.name, items: feedData.items, accountName: '@'+name, imageUrl: imageUrl });
|
res.render('user', { displayName: actor.name, items: feedData.items, accountName: '@'+name, imageUrl: imageUrl });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ router.get('/', function (req, res) {
|
||||||
return res.status(404).send(`No record found for ${name}.`);
|
return res.status(404).send(`No record found for ${name}.`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.json(result.webfinger);
|
res.json(JSON.parse(result.webfinger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue