Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function processPost(post){
const postUUID = post.uid
, postBody = post.body
try{
const postTags = _.uniq(twitter.extractHashtags(postBody))
if (!postTags || postTags.length == 0) {
return
}
console.log(postTags)
await dbAdapter.linkHashtagsByNames(postTags, postUUID)
} catch (e) {
console.log("-------------------------------------------------------")
console.log(e)
console.log("-------------------------------------------------------")
}
}
function parseCustomTagsTwitter (payload) {
const rawCustomTags = twitter.extractHashtags(payload)
if (rawCustomTags.length === 0) {
return ''
}
const prefix = '#tags:'
const customTags = prefix + rawCustomTags.reduce((acc, cur) => acc + ', ' + cur)
return customTags
}
}
if (e.key === "Enter") {
e.preventDefault();
this.typing = false;
clearTimeout(this.typeTimeout);
this.channel.push("new_typing", {uuid: this.props.userReducer.uuid, typing: false});
if(e.target.value.length > 0 ) {
if (e.target.value[0] === '#' && !e.target.value.includes(" ")) {
return this.processTagFromInput(e);
}
const message = e.target.value;
let allTags = this.state.tags.slice(0,1);
const urls = this.props.userReducer.urlPreviews ? twitter.extractUrls(message).map((url) => url.startsWith('http') ? url : 'https://' + url) : [];
const extractedTags = twitter.extractHashtags(message);
extractedTags.forEach((extractedTag) => {
const downcaseTag = extractedTag.toLowerCase();
allTags = allTags.includes(downcaseTag) ? allTags : [
...allTags,
downcaseTag
]
})
this.pubKeyObj = this.pubKeyObj || openpgp.key.readArmored(this.props.cryptoReducer.groups[this.room].publicKey).keys
const options = {
data: message,
publicKeys: this.pubKeyObj,
armored: false
};
openpgp.encrypt(options).then((ciphertext) => {
return (
{!word.startsWith(`@${mention[0]}`) &&
word.slice(0, word.indexOf(mention[0]) - 1)}
<a> onClickMention && onClickMention(mention[0])}
className={`${parentClass}__mention`}
>
@{mention[0]}
</a>
{!word.endsWith(mention[0]) &&
word.slice(word.indexOf(mention[0]) + mention[0].length)}
);
} else if (onClickHashtag && word.includes('#')) {
const hashtag = twitter.extractHashtags(word);
if (!hashtag.length) return word;
return (
{!word.startsWith(`#${hashtag[0]}`) &&
word.slice(0, word.indexOf(hashtag[0]) - 1)}
<a> onClickHashtag && onClickHashtag(hashtag[0])}
className={`${parentClass}__hashtag`}
>
#{hashtag[0]}
</a>
{!word.endsWith(hashtag[0]) &&
word.slice(word.indexOf(hashtag[0]) + hashtag[0].length)}
);