var twemoji = require('twemoji' );
const { deepPick, has } = require('./util');
const schema = {
id_str: true,
created_at: true,
user: {
screen_name: true,
avatar: true,
name_html: true,
verified: true,
protected: true,
},
html: true,
quoted_status: {
user: {
screen_name: true,
avatar: true,
name_html: true,
verified: true,
protected: true,
},
},
entities: { media: [ {
type: true,
media_url_https: true,
video_info: { variants: [ {
url: true,
content_type: true,
} ] },
} ] },
media: true,
};
var entityProcessors = {
hashtags (tags, tweet) {
tags.forEach((tagObj) => {
tweet.html = tweet.html.replace('#' + tagObj.text, `#${tagObj.text}`);
});
},
symbols (/* symbols, tweet */) {
},
user_mentions (users, tweet) {
users.forEach((userObj) => {
var regex = new RegExp('@' + userObj.screen_name, 'gi' );
tweet.html = tweet.html.replace(regex, `@${userObj.screen_name}`);
});
},
urls (urls, tweet) {
urls.forEach((urlObj) => {
var quotedTweetHtml = '';
var indices = urlObj.indices;
var urlToReplace = (tweet.full_text || tweet.text).substring(indices[0], indices[1]);
var finalText = quotedTweetHtml || urlObj.display_url.link(urlObj.expanded_url);
tweet.html = tweet.html.replace(urlToReplace, finalText);
});
},
media (media, tweet) {
media.forEach((mediaObj) => {
tweet.html = tweet.html.replace(mediaObj.url, '');
return;
// if (mediaObj.type === 'photo') {
// // Use HTTPS if available
// var src = mediaObj.media_url_https ? mediaObj.media_url_https : mediaObj.media_url;
// if (options &&
// options.photoSize &&
// mediaObj.sizes &&
// mediaObj.sizes[options.photoSize]) {
// // If specified size is available, patch image src to use it
// src = src + ':' + options.photoSize;
// }
// tweet.html = tweet.html.replace(mediaObj.url, ``);
// } else if (mediaObj.type === 'video') {
// var source = '';
// mediaObj.video_info.variants.forEach((info) => {
// source += `