Upgrade nostr-tools, do npub stuff, query own events in feed

This commit is contained in:
Alex Gleason 2023-03-18 16:39:34 -05:00
parent 9f81d0d572
commit c28c644265
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 8 additions and 4 deletions

View File

@ -38,6 +38,7 @@ const fetchFollows = (pubkey: string): Promise<SignedEvent<3> | null> => {
function fetchFeed(event3: Event<3>): Promise<SignedEvent<1>[]> {
const authors = event3.tags.filter((tag) => tag[0] === 'p').map((tag) => tag[1]);
const results: SignedEvent<1>[] = [];
authors.push(event3.pubkey); // see own events in feed
return new Promise((resolve) => {
pool.subscribe(

View File

@ -3,5 +3,5 @@ export { Hono, validator };
export { cors } from 'https://deno.land/x/hono@v3.0.2/middleware.ts';
export { z } from 'https://deno.land/x/zod@v3.20.5/mod.ts';
export { Author, RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.5.3';
export { getEventHash, getPublicKey, signEvent } from 'https://dev.jspm.io/nostr-tools@1.6.0';
export { getEventHash, getPublicKey, nip19, signEvent } from 'npm:nostr-tools@^1.7.4';
export type { Context };

View File

@ -1,3 +1,5 @@
import { nip19 } from '@/deps.ts';
import { LOCAL_DOMAIN } from './config.ts';
import { fetchUser } from './client.ts';
import { jsonSchema, MetaContent, metaContentSchema } from './schema.ts';
@ -16,10 +18,11 @@ function toAccount(event: Event<0>) {
const { pubkey } = event;
const content: MetaContent = parseContent(event);
const { host, origin } = new URL(LOCAL_DOMAIN);
const npub = nip19.npubEncode(pubkey);
return {
id: pubkey,
acct: content.nip05 || pubkey,
acct: content.nip05 || npub,
avatar: content.picture || DEFAULT_AVATAR,
avatar_static: content.picture || DEFAULT_AVATAR,
bot: false,
@ -35,9 +38,9 @@ function toAccount(event: Event<0>) {
header_static: content.banner,
locked: false,
note: content.about,
fqn: content.nip05 || `${pubkey}@${host}`,
fqn: content.nip05 || `${npub}@${host}`,
url: `${origin}/users/${pubkey}`,
username: content.nip05 || pubkey,
username: content.nip05 || npub,
};
}