trending posts into system, check sigs

This commit is contained in:
Martti Malmi 2024-01-03 20:21:35 +02:00
parent e700c97c71
commit 98e1be883b
3 changed files with 34 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { useState } from "react";
import { NostrLink, TaggedNostrEvent } from "@snort/system";
import { EventExt, NostrLink, TaggedNostrEvent } from "@snort/system";
import { useReactions } from "@snort/system-react";
import PageSpinner from "@/Element/PageSpinner";
@ -15,6 +15,7 @@ import ImageGridItem from "@/Element/Feed/ImageGridItem";
import { SpotlightThreadModal } from "@/Element/Spotlight/SpotlightThreadModal";
import useLogin from "@/Hooks/useLogin";
import useCachedFetch from "@/Hooks/useCachedFetch";
import { System } from "@/index";
export default function TrendingNotes({ count = Infinity, small = false }) {
const api = new NostrBandApi();
@ -26,7 +27,18 @@ export default function TrendingNotes({ count = Infinity, small = false }) {
data: trendingNotesData,
isLoading,
error,
} = useCachedFetch(trendingNotesUrl, storageKey, data => data.notes.map(a => a.event));
} = useCachedFetch(trendingNotesUrl, storageKey, data => {
return data.notes.map(a => {
const ev = a.event;
const id = EventExt.createId(ev);
if (!System.QueryOptimizer.schnorrVerify(id, ev.sig, ev.pubkey)) {
console.error(`Event with invalid sig\n\n${ev}\n\nfrom ${trendingNotesUrl}`);
return;
}
System.HandleEvent(ev);
return ev;
});
});
const login = useLogin();
const displayAsInitial = small ? "list" : login.feedDisplayAs ?? "list";

View File

@ -75,6 +75,9 @@
"0HFX0T": {
"defaultMessage": "Use Exact Location"
},
"0MndVW": {
"defaultMessage": "Generic LNDHub wallet (BTCPayServer / Alby / LNBits)"
},
"0jOEtS": {
"defaultMessage": "Invalid LNURL"
},
@ -165,6 +168,9 @@
"3gOsZq": {
"defaultMessage": "Translators"
},
"3natuV": {
"defaultMessage": "Cashu mint wallet"
},
"3qnJlS": {
"defaultMessage": "You are voting with {amount} sats"
},
@ -996,6 +1002,9 @@
"XICsE8": {
"defaultMessage": "File hosts"
},
"XPB8VV": {
"defaultMessage": "Alby wallet connection"
},
"XQiFEl": {
"defaultMessage": "Follows Relay Health"
},
@ -1054,6 +1063,9 @@
"aMaLBK": {
"defaultMessage": "Supported Extensions"
},
"aSGz4J": {
"defaultMessage": "Connect to your own LND node with Lightning Node Connect"
},
"aWpBzj": {
"defaultMessage": "Show more"
},
@ -1102,6 +1114,9 @@
"cFbU1B": {
"defaultMessage": "Using Alby? Go to {link} to get your NWC config!"
},
"cG/bKQ": {
"defaultMessage": "Native nostr wallet connection"
},
"cHCwbF": {
"defaultMessage": "Photography"
},

View File

@ -24,6 +24,7 @@
"0Azlrb": "Manage",
"0BUTMv": "Search...",
"0HFX0T": "Use Exact Location",
"0MndVW": "Generic LNDHub wallet (BTCPayServer / Alby / LNBits)",
"0jOEtS": "Invalid LNURL",
"0mch2Y": "name has disallowed characters",
"0siT4z": "Politics",
@ -54,6 +55,7 @@
"3QwfJR": "~{amount}",
"3cc4Ct": "Light",
"3gOsZq": "Translators",
"3natuV": "Cashu mint wallet",
"3qnJlS": "You are voting with {amount} sats",
"3t3kok": "{n,plural,=1{{n} new note} other{{n} new notes}}",
"3tVy+Z": "{n} Followers",
@ -328,6 +330,7 @@
"X7xU8J": "nsec, npub, nip-05, hex, mnemonic",
"XECMfW": "Send usage metrics",
"XICsE8": "File hosts",
"XPB8VV": "Alby wallet connection",
"XQiFEl": "Follows Relay Health",
"XXm7jJ": "Trending Hashtags",
"XgWvGA": "Reactions",
@ -347,6 +350,7 @@
"a7TDNm": "Notes will stream in real time into global and notes tab",
"aHje0o": "Name or nym",
"aMaLBK": "Supported Extensions",
"aSGz4J": "Connect to your own LND node with Lightning Node Connect",
"aWpBzj": "Show more",
"b12Goz": "Mnemonic",
"b5vAk0": "Your handle will act like a lightning address and will redirect to your chosen LNURL or Lightning address",
@ -363,6 +367,7 @@
"c35bj2": "If you have an enquiry about your NIP-05 order please DM {link}",
"c3g2hL": "Broadcast Again",
"cFbU1B": "Using Alby? Go to {link} to get your NWC config!",
"cG/bKQ": "Native nostr wallet connection",
"cHCwbF": "Photography",
"cPIKU2": "Following",
"cQfLWb": "URL..",