Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Merge branch '1.7.3' of github.com:LiskHQ/lisk-explorer into 1.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Tuleja committed Aug 13, 2018
2 parents d47cae8 + 9a74688 commit a8cdb0e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions services/newsfeed/TwitterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ const client = new Twitter({
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
});

const safeRef = (obj, path) => {
try {
// eslint-disable-next-line
return path.split('.').reduce((xs, x) => (xs && xs[x]) ? xs[x] : null, obj);
} catch (e) {
return null;
}
};

const tweetUrl = (o) => {
if (o.retweeted_status) {
return o.retweeted_status.entities.urls[0].url;
return safeRef(o, 'retweeted_status.entities.urls.0.url');
} else if (o.extended_entities) {
return o.extended_entities.media[0].url;
return safeRef(o, 'extended_entities.media.0.url');
} else if (o.entities) {
return o.entities.urls[0].url;
return safeRef(o, 'entities.urls.0.url');
}
return null;
};
Expand Down

0 comments on commit a8cdb0e

Please sign in to comment.