diff --git a/src/nostr/Event.js b/src/nostr/Event.js index a92b9b0f4..cc341dc46 100644 --- a/src/nostr/Event.js +++ b/src/nostr/Event.js @@ -5,6 +5,11 @@ import Thread from './Thread'; export default class Event { constructor() { + /** + * The original event + */ + this.Original = null; + /** * Id of the event * @type {string} @@ -117,11 +122,12 @@ export default class Event { } let ret = new Event(); + ret.Original = obj; ret.Id = obj.id; ret.PubKey = obj.pubkey; ret.CreatedAt = obj.created_at; ret.Kind = obj.kind; - ret.Tags = obj.tags.map((e, i) => new Tag(e, i)); + ret.Tags = obj.tags.map((e, i) => new Tag(e, i)).filter(a => !a.Invalid); ret.Content = obj.content; ret.Signature = obj.sig; return ret; diff --git a/src/nostr/Tag.js b/src/nostr/Tag.js index 804455368..84e885b83 100644 --- a/src/nostr/Tag.js +++ b/src/nostr/Tag.js @@ -7,6 +7,7 @@ export default class Tag { this.Marker = null; this.Other = null; this.Index = index; + this.Invalid = false; switch (this.Key) { case "e": { @@ -14,11 +15,17 @@ export default class Tag { this.Event = tag[1]; this.Relay = tag.length > 2 ? tag[2] : null; this.Marker = tag.length > 3 ? tag[3] : null; + if (!this.Event) { + this.Invalid = true; + } break; } case "p": { // ["p", ] this.PubKey = tag[1]; + if (!this.PubKey) { + this.Invalid = true; + } break; } default: {