Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const handleNewModel = async (db, attrs) => {
// console.log('emitter', attrs);
if (attrs.radiksType !== 'Message') {
return true;
}
const { content, createdBy } = attrs;
console.log(`@${createdBy}: ${content}`);
const matches = linkify.find(content);
const mentions = {};
matches.forEach((match) => {
if (match.type === 'mention') {
const username = match.value.slice(1);
mentions[username] = true;
}
});
const mentionedUsers = Object.keys(mentions);
console.log('Mentions:', mentionedUsers.join(','));
const centralCollection = db.collection(CENTRAL_COLLECTION);
const collectMentionsToSend = mentionedUsers.map((username) => new Promise(async (resolve, reject) => {
try {
_processHyperlinks: _.throttle(function() {
var that = this,
messageText = this.ui.messageBody.val()||'',
links = linkify.find(messageText),
missingLinks = [],
goneModels = [];
//console.log("_processHyperlinks called");
//console.log(links);
//console.log(this.attachmentsCollection);
// this.attachmentsCollection.comparator = function (attachmentModel) {
// var index = _.findIndex(links, function(link) {
// //console.log(attachmentModel.getDocument().get('uri'), link.href);
// return attachmentModel.getDocument().get('uri') === link.href;
// })
// //console.log("attachmentsCollection comparator returning: ", index);
// return index;
// };
goneModels = that.attachmentsCollection.filter(function(attachment) {
var document = attachment.getDocument();
passToNextState(msgTimes, msgContent){
let links = [];
if(msgTimes) {
console.log("messagestimes", msgTimes.length);
this.setState({messagesTimes: msgTimes});
}
if(msgContent) {
console.log("messagesContent", msgContent.length);
links = linkify.find(msgContent).filter((d)=>{return d.type === "url"; });
this.setState({messagesContent: links});
}
// only for DEV
// this.saveToLocalStorage(msgTimes, links);
this.setState({dataReady: true});
}
module.exports = (
ctx,
comment,
{
asset: {
settings: { premodLinksEnable },
},
}
) => {
if (premodLinksEnable) {
const links = linkify.find(comment.body.replace(/\xAD/g, ''));
if (!links || links.length === 0) {
return;
}
// Add the flag related to Trust to the comment.
return {
status: 'SYSTEM_WITHHELD',
actions: [
{
action_type: 'FLAG',
user_id: null,
group_id: 'LINKS',
metadata: {
links: comment.body,
},
},
const handleNewModel = async (db, attrs) => {
if (attrs.radiksType !== 'Message') {
return true;
}
const { content, createdBy } = attrs;
console.log(`@${createdBy}: ${content}`);
const matches = linkify.find(content);
const mentions = {};
matches.forEach((match) => {
if (match.type === 'mention') {
const username = match.value.slice(1);
mentions[username] = true;
}
});
const mentionedUsers = Object.keys(mentions);
console.log('Mentions:', mentionedUsers.join(','));
const centralCollection = db.collection(CENTRAL_COLLECTION);
const collectMentionsToSend = mentionedUsers.map(
(username) =>
parseURLs(value, filterValue, parseImg) {
const grabLinks = linkify.find(value)
const highlightedValue = this.highlightValue(value, filterValue)
if (isEmpty(grabLinks)) {
if (isDataURL(value)) {
return this.renderImage(value, parseImg, true)
}
return highlightedValue
}
const firstLink = head(grabLinks)
let image = null
if (parseImg && firstLink.type === 'url') {
image = this.renderImage(value, parseImg)
}
return (
<a href="{firstLink.href}"> e.stopPropagation()}>
{image || highlightedValue}
</a>
export default function(str) {
const links = linkify.find(str);
for (let link of Array.from(links)) {
str = str.replace(link.value, _getTag(link));
}
return str;
}