noxy: disable images and link previews
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details

noxy is not running at the moment and was enabled for events
with enough POW.

temporary disabled noxy link previews and images.
pull/76/head
OFF0 1 year ago
parent 9036f6a073
commit b67f59ebec
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -2,7 +2,7 @@ import {Event} from 'nostr-tools';
import {elem, elemCanvas} from './utils/dom'; import {elem, elemCanvas} from './utils/dom';
import {getHost, getNoxyUrl} from './utils/url'; import {getHost, getNoxyUrl} from './utils/url';
import {getViewContent, getViewElem} from './view'; import {getViewContent, getViewElem} from './view';
import {validatePow} from './events'; // import {validatePow} from './events';
import {parseContent} from './media'; import {parseContent} from './media';
type Metadata = { type Metadata = {
@ -55,11 +55,11 @@ const setMetadata = (
user.picture = imgUrl.href; user.picture = imgUrl.href;
// update profile images that used some nip-13 work // update profile images that used some nip-13 work
if (imgUrl.href && validatePow(evt)) { // if (imgUrl.href && validatePow(evt)) {
document.body // document.body
.querySelectorAll(`canvas[data-pubkey="${evt.pubkey}"]`) // .querySelectorAll(`canvas[data-pubkey="${evt.pubkey}"]`)
.forEach(canvas => canvas.parentNode?.replaceChild(elem('img', {src: imgUrl.href}), canvas)); // .forEach(canvas => canvas.parentNode?.replaceChild(elem('img', {src: imgUrl.href}), canvas));
} // }
} }
} }
@ -110,16 +110,16 @@ export const getProfile = (pubkey: string) => userList.find(user => user.pubkey
export const getMetadata = (evt: Event, relay: string) => { export const getMetadata = (evt: Event, relay: string) => {
const host = getHost(relay); const host = getHost(relay);
const user = getProfile(evt.pubkey); const user = getProfile(evt.pubkey);
const userImg = user?.picture; // const userImg = user?.picture;
const name = user?.metadata[relay]?.name || user?.name; const name = user?.metadata[relay]?.name || user?.name;
const userName = name || evt.pubkey.slice(0, 8); const userName = name || evt.pubkey.slice(0, 8);
const userAbout = user?.metadata[relay]?.about || ''; const userAbout = user?.metadata[relay]?.about || '';
const img = (userImg && validatePow(evt)) ? elem('img', { const img = /* (userImg && validatePow(evt)) ? elem('img', {
alt: `${userName} ${host}`, alt: `${userName} ${host}`,
loading: 'lazy', loading: 'lazy',
src: userImg, src: userImg,
title: `${userName} on ${host} ${userAbout}`, title: `${userName} on ${host} ${userAbout}`,
}) : elemCanvas(evt.pubkey); }) : */ elemCanvas(evt.pubkey);
const time = new Date(evt.created_at * 1000); const time = new Date(evt.created_at * 1000);
return {host, img, name, time, userName}; return {host, img, name, time, userName};
}; };

@ -1,12 +1,12 @@
import {Event} from 'nostr-tools'; import {Event} from 'nostr-tools';
import {elem, elemArticle, parseTextContent} from './utils/dom'; import {elem, elemArticle, parseTextContent} from './utils/dom';
import {dateTime, formatTime} from './utils/time'; import {dateTime, formatTime} from './utils/time';
import {validatePow, sortByCreatedAt} from './events'; import {/*validatePow,*/ sortByCreatedAt} from './events';
import {setViewElem} from './view'; import {setViewElem} from './view';
import {config} from './settings'; import {config} from './settings';
import {getReactions, getReactionContents} from './reactions'; import {getReactions, getReactionContents} from './reactions';
import {openWriteInput} from './write'; import {openWriteInput} from './write';
import {linkPreview} from './media'; // import {linkPreview} from './media';
import {getMetadata} from './profiles'; import {getMetadata} from './profiles';
import {EventWithNip19, replyList} from './notes'; import {EventWithNip19, replyList} from './notes';
@ -60,10 +60,10 @@ export const createTextNote = (
' ', ' ',
elem('a', {href: `/${evt.nip19.note}`}, elem('time', {dateTime: time.toISOString()}, formatTime(time))), elem('a', {href: `/${evt.nip19.note}`}, elem('time', {dateTime: time.toISOString()}, formatTime(time))),
]), ]),
elem('div', {/* data: isLongContent ? {append: evt.content.slice(280)} : null*/}, [ elem('div', {/* data: isLongContent ? {append: evt.content.slice(280)} : null*/}, content /*[
...content, ...content,
(firstLink && validatePow(evt)) ? linkPreview(firstLink, evt.id, relay) : null, (firstLink && validatePow(evt)) ? linkPreview(firstLink, evt.id, relay) : null,
]), ]*/),
buttons, buttons,
]), ]),
...(replies[0] ? [elem('div', {className: 'mbox-replies'}, replyFeed)] : []), ...(replies[0] ? [elem('div', {className: 'mbox-replies'}, replyFeed)] : []),

Loading…
Cancel
Save