mirror of
https://github.com/BlowaterNostr/blowater.git
synced 2024-10-18 07:33:22 +00:00
update nostr.ts (#267)
This commit is contained in:
parent
943f042c7c
commit
a919a350f4
@ -365,9 +365,10 @@ export async function* UI_Interaction_Update(args: {
|
||||
}
|
||||
const profileEvent = await prepareNormalNostrEvent(
|
||||
groupCreation.groupKey,
|
||||
NostrKind.META_DATA,
|
||||
[],
|
||||
JSON.stringify(profileData),
|
||||
{
|
||||
kind: NostrKind.META_DATA,
|
||||
content: JSON.stringify(profileData),
|
||||
},
|
||||
);
|
||||
const err2 = pool.sendEvent(profileEvent);
|
||||
if (err2 instanceof Error) {
|
||||
|
@ -68,7 +68,7 @@ Deno.test("Relay Config", async () => {
|
||||
{
|
||||
const err = await relayConfig.syncWithPool(pool);
|
||||
if (err != undefined) {
|
||||
assertEquals(err.message, "wss://somewhere has been closed, can't wait for it to open");
|
||||
assertEquals(err.message, "wss://somewhere/ has been closed, can't wait for it to open");
|
||||
}
|
||||
|
||||
// add one relay to the pool directly
|
||||
@ -83,7 +83,7 @@ Deno.test("Relay Config", async () => {
|
||||
// will remove urls that's in the pool but not in the config
|
||||
const err2 = await relayConfig.syncWithPool(pool);
|
||||
if (err2 != undefined) {
|
||||
assertEquals(err2.message, "wss://somewhere has been closed, can't wait for it to open");
|
||||
assertEquals(err2.message, "wss://somewhere/ has been closed, can't wait for it to open");
|
||||
}
|
||||
assertEquals(pool.getRelays().map((r) => r.url), ["wss://relay.damus.io"]); // wirednet is removed
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ Deno.test("Database", async () => {
|
||||
if (db instanceof Error) fail(db.message);
|
||||
|
||||
const stream = db.subscribe();
|
||||
const event_to_add = await prepareNormalNostrEvent(ctx, NostrKind.TEXT_NOTE, [], "1");
|
||||
const event_to_add = await prepareNormalNostrEvent(ctx, { kind: NostrKind.TEXT_NOTE, content: "1" });
|
||||
await db.addEvent(event_to_add);
|
||||
assertEquals(
|
||||
db.events.map((e): NostrEvent => {
|
||||
@ -48,7 +48,7 @@ Deno.test("Database", async () => {
|
||||
await db.addEvent(event_to_add); // add a duplicated event
|
||||
assertEquals(db.events.length, 1); // no changes
|
||||
|
||||
const event_to_add2 = await prepareNormalNostrEvent(ctx, NostrKind.TEXT_NOTE, [], "2");
|
||||
const event_to_add2 = await prepareNormalNostrEvent(ctx, { kind: NostrKind.TEXT_NOTE, content: "2" });
|
||||
// console.log(event_to_add2.id, event_to_add.id)
|
||||
await db.addEvent(event_to_add2);
|
||||
const e2 = await stream.pop() as NostrEvent;
|
||||
|
@ -51,9 +51,7 @@ export async function saveProfile(
|
||||
) {
|
||||
const event = await prepareNormalNostrEvent(
|
||||
sender,
|
||||
NostrKind.META_DATA,
|
||||
[],
|
||||
JSON.stringify(profile),
|
||||
{ kind: NostrKind.META_DATA, content: JSON.stringify(profile) },
|
||||
);
|
||||
pool.sendEvent(event);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a2327172fdf711c2e3bf02d8fefe4b6dae9a2910
|
||||
Subproject commit 53303f151e4787ec46e1e77584508634129e6cfd
|
@ -50,9 +50,11 @@ Deno.test("Generate reply event", async () => {
|
||||
|
||||
const message1 = await prepareNormalNostrEvent(
|
||||
userAContext,
|
||||
NostrKind.DIRECT_MESSAGE,
|
||||
[],
|
||||
"text message 1",
|
||||
{
|
||||
kind: NostrKind.DIRECT_MESSAGE,
|
||||
|
||||
content: "text message 1",
|
||||
},
|
||||
);
|
||||
|
||||
const replyMessage1WithText = await prepareReplyEvent(
|
||||
|
34
nostr.ts
34
nostr.ts
@ -168,23 +168,25 @@ export async function prepareReplyEvent(
|
||||
|
||||
return prepareNormalNostrEvent(
|
||||
sender,
|
||||
targetEvent.kind,
|
||||
[
|
||||
[
|
||||
"e",
|
||||
targetEvent.id,
|
||||
"",
|
||||
"reply",
|
||||
],
|
||||
...ps.map((p) =>
|
||||
{
|
||||
kind: targetEvent.kind,
|
||||
tags: [
|
||||
[
|
||||
"p",
|
||||
p,
|
||||
] as TagPubKey
|
||||
),
|
||||
...tags,
|
||||
],
|
||||
content,
|
||||
"e",
|
||||
targetEvent.id,
|
||||
"",
|
||||
"reply",
|
||||
],
|
||||
...ps.map((p) =>
|
||||
[
|
||||
"p",
|
||||
p,
|
||||
] as TagPubKey
|
||||
),
|
||||
...tags,
|
||||
],
|
||||
content,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user