event fix?
This commit is contained in:
parent
cfe6aa200b
commit
6c6121b504
2 changed files with 20 additions and 23 deletions
|
|
@ -1,13 +1,8 @@
|
|||
import { getRepository } from "typeorm";
|
||||
import { User } from "./storage/entity/User";
|
||||
import { UserOffer } from "./storage/entity/UserOffer";
|
||||
import { validateEvent, type Event as BaseNostrEvent } from "nostr-tools";
|
||||
import { ManagementGrant } from "./storage/entity/ManagementGrant";
|
||||
import { NostrSend, NostrSettings } from "./nostr/handler";
|
||||
|
||||
type NostrEvent = BaseNostrEvent & {
|
||||
appId: string;
|
||||
};
|
||||
import { NostrEvent, NostrSend, NostrSettings } from "./nostr/handler.js";
|
||||
|
||||
export class ManagementManager {
|
||||
private nostrSend: NostrSend;
|
||||
|
|
@ -30,13 +25,6 @@ export class ManagementManager {
|
|||
}
|
||||
const appPubkey = app.publicKey;
|
||||
|
||||
// Validate event
|
||||
const isValid = validateEvent(event);
|
||||
if (!isValid) {
|
||||
console.error("Invalid event");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check grant
|
||||
const userIdTag = event.tags.find((t: string[]) => t[0] === 'p');
|
||||
if (!userIdTag) {
|
||||
|
|
|
|||
|
|
@ -26,15 +26,16 @@ export type NostrSettings = {
|
|||
clients: ClientInfo[]
|
||||
maxEventContentLength: number
|
||||
}
|
||||
export type NostrEvent = {
|
||||
id: string
|
||||
pub: string
|
||||
content: string
|
||||
appId: string
|
||||
startAtNano: string
|
||||
startAtMs: number
|
||||
kind: number
|
||||
}
|
||||
export type NostrEvent = Event & {
|
||||
/** Identifier of the application as defined in NostrSettings.apps */
|
||||
appId: string;
|
||||
/** High-resolution timer capture when processing began (BigInt serialized as string to keep JSON friendly) */
|
||||
startAtNano: string;
|
||||
/** wall-clock millis when processing began */
|
||||
startAtMs: number;
|
||||
/** Convenience duplicate of the sender pubkey (e.pubkey) kept for backwards-compat */
|
||||
pub: string;
|
||||
};
|
||||
|
||||
type SettingsRequest = {
|
||||
type: 'settings'
|
||||
|
|
@ -216,7 +217,15 @@ export default class Handler {
|
|||
return
|
||||
|
||||
}
|
||||
this.eventCallback({ id: eventId, content, pub: e.pubkey, appId: app.appId, startAtNano, startAtMs, kind: e.kind })
|
||||
const nostrEvent: NostrEvent = {
|
||||
...e,
|
||||
content,
|
||||
appId: app.appId,
|
||||
startAtNano,
|
||||
startAtMs,
|
||||
pub: e.pubkey,
|
||||
}
|
||||
this.eventCallback(nostrEvent)
|
||||
}
|
||||
|
||||
async Send(initiator: SendInitiator, data: SendData, relays?: string[]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue