Skip to content

Commit

Permalink
Post p tags as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed Aug 9, 2024
1 parent 51cb1d9 commit 70256f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const RELAYS_STORAGE_KEY = "__nostrRelays" as const;
export const PLUS_CODE_TAG_KEY = "l" as const;
export const LABEL_NAMESPACE_TAG = "L";
export const OPEN_LOCATION_CODE_NAMESPACE_TAG = "open-location-code";
export const MAP_NOTE_KIND = 397 as Kind;
export const MAP_NOTE_REPOST_KIND = 30627;
export const MAP_NOTE_KIND = 397;
export const MAP_NOTE_REPOST_KIND = 30398;
export const DEFAULT_RELAYS = [
"wss://relay.primal.net",
"wss://relay.damus.io",
Expand Down
11 changes: 9 additions & 2 deletions validation/repost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ function generateRepostedEvent(originalEvent: Event, privateKey: Uint8Array) {
const derivedContent = deriveContent(originalEvent);
const dTag = ["d", `${originalEvent.pubkey}:${originalEvent.id}`];
const eTag = ["e", originalEvent.id];
const pTag = ["p", originalEvent.pubkey];

const eventTemplate: EventTemplate = {
kind: MAP_NOTE_REPOST_KIND,
created_at: Math.floor(Date.now() / 1000),
tags: [eTag, dTag, ...derivedTags],
tags: [eTag, pTag, dTag, ...derivedTags],
content: derivedContent,
};
const signedEvent = finalizeEvent(eventTemplate, privateKey);
Expand Down Expand Up @@ -72,7 +73,13 @@ function createFilter(isDev: true | undefined): nostrTools.Filter {
export async function repost(privateKey: Uint8Array, isDev: true | undefined) {
const filter = createFilter(isDev);

const oneose = isDev ? () => relay.close() : () => {};
const oneose = isDev
? () => {
globalThis.setTimeout(() => {
relay.close();
}, 10e3);
}
: () => {};

const sub = relay.subscribe([filter], {
onevent: (event) => {
Expand Down

0 comments on commit 70256f7

Please sign in to comment.