rename
This commit is contained in:
@ -33,7 +33,7 @@ interface EventCommon {
|
|||||||
|
|
||||||
export interface SetMetadataEvent extends EventCommon {
|
export interface SetMetadataEvent extends EventCommon {
|
||||||
kind: EventKind.SetMetadata
|
kind: EventKind.SetMetadata
|
||||||
userMetadata: UserMetadata
|
content: UserMetadata
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserMetadata {
|
export interface UserMetadata {
|
||||||
@ -44,7 +44,7 @@ export interface UserMetadata {
|
|||||||
|
|
||||||
export interface TextNoteEvent extends EventCommon {
|
export interface TextNoteEvent extends EventCommon {
|
||||||
kind: EventKind.TextNote
|
kind: EventKind.TextNote
|
||||||
note: string
|
content: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UnknownEvent extends EventCommon {
|
export interface UnknownEvent extends EventCommon {
|
||||||
@ -210,7 +210,7 @@ function parseEvent(raw: RawEvent): Event {
|
|||||||
return {
|
return {
|
||||||
...event,
|
...event,
|
||||||
kind: EventKind.SetMetadata,
|
kind: EventKind.SetMetadata,
|
||||||
userMetadata,
|
content: userMetadata,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ function parseEvent(raw: RawEvent): Event {
|
|||||||
return {
|
return {
|
||||||
...event,
|
...event,
|
||||||
kind: EventKind.TextNote,
|
kind: EventKind.TextNote,
|
||||||
note: raw.content,
|
content: raw.content,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,11 +235,9 @@ function serializeEventTags(_event: Event): string[][] {
|
|||||||
|
|
||||||
function serializeEventContent(event: Event): string {
|
function serializeEventContent(event: Event): string {
|
||||||
if (event.kind === EventKind.SetMetadata) {
|
if (event.kind === EventKind.SetMetadata) {
|
||||||
// TODO Maybe rename userMetadata to content?
|
return JSON.stringify(event.content)
|
||||||
return JSON.stringify(event.userMetadata)
|
|
||||||
} else if (event.kind === EventKind.TextNote) {
|
} else if (event.kind === EventKind.TextNote) {
|
||||||
// TODO Maybe rename note to content?
|
return event.content
|
||||||
return event.note
|
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -253,17 +251,17 @@ function cloneEvent(event: Event): Event {
|
|||||||
if (event.kind === EventKind.SetMetadata) {
|
if (event.kind === EventKind.SetMetadata) {
|
||||||
return {
|
return {
|
||||||
kind: EventKind.SetMetadata,
|
kind: EventKind.SetMetadata,
|
||||||
userMetadata: {
|
content: {
|
||||||
about: event.userMetadata.about,
|
about: event.content.about,
|
||||||
name: event.userMetadata.name,
|
name: event.content.name,
|
||||||
picture: event.userMetadata.picture,
|
picture: event.content.picture,
|
||||||
},
|
},
|
||||||
...common,
|
...common,
|
||||||
}
|
}
|
||||||
} else if (event.kind === EventKind.TextNote) {
|
} else if (event.kind === EventKind.TextNote) {
|
||||||
return {
|
return {
|
||||||
kind: EventKind.TextNote,
|
kind: EventKind.TextNote,
|
||||||
note: event.note,
|
content: event.content,
|
||||||
...common,
|
...common,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,7 @@ describe("single event communication", function () {
|
|||||||
assert.equal(event.pubkey.toString(), pubkey.toString())
|
assert.equal(event.pubkey.toString(), pubkey.toString())
|
||||||
assert.equal(event.createdAt.toString(), timestamp.toString())
|
assert.equal(event.createdAt.toString(), timestamp.toString())
|
||||||
if (event.kind === EventKind.TextNote) {
|
if (event.kind === EventKind.TextNote) {
|
||||||
assert.equal(event.note, note)
|
assert.equal(event.content, note)
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is a bug with the nostr relay used for testing where if the publish and
|
// There is a bug with the nostr relay used for testing where if the publish and
|
||||||
@ -46,7 +46,7 @@ describe("single event communication", function () {
|
|||||||
{
|
{
|
||||||
kind: EventKind.TextNote,
|
kind: EventKind.TextNote,
|
||||||
createdAt: timestamp,
|
createdAt: timestamp,
|
||||||
note,
|
content: note,
|
||||||
pubkey,
|
pubkey,
|
||||||
},
|
},
|
||||||
secret
|
secret
|
||||||
|
Reference in New Issue
Block a user