Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assetEntity.previews().map(linkPreview => {
linkPreview.obfuscate();
const protoArticle = new Article({permanentUrl: linkPreview.url, title: linkPreview.title}); // deprecated format
const linkPreviewProto = new LinkPreview({
article: protoArticle,
permanentUrl: linkPreview.url,
title: linkPreview.title,
url: linkPreview.url,
urlOffset: 0,
});
return arrayToBase64(LinkPreview.encode(linkPreviewProto).finish());
}),
);
it('maps text messages with deprecated link preview format', async () => {
const event_id = createRandomUuid();
const article = new Article({
permanentUrl: 'test.com',
summary: 'Test description',
title: 'Test title',
});
const link_preview = new LinkPreview({
article,
url: 'test.com',
urlOffset: 0,
});
const base64LinkPreview = await arrayToBase64(LinkPreview.encode(link_preview).finish());
const event = {
conversation: conversation_et.id,
data: {
content: 'test.com',
nonce: event_id,
previews: [base64LinkPreview],
},
from: createRandomUuid,
id: event_id,
time: new Date().toISOString(),
type: ClientEvent.CONVERSATION.MESSAGE_ADD,
};
const messageEntity = await event_mapper.mapJsonEvent(event, conversation_et);
protoLinkPreviews.map(protoLinkPreview => arrayToBase64(LinkPreview.encode(protoLinkPreview).finish())),
);