mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 04:12:25 +00:00
chore(ai): event schema validation tool + fixes
- Added `scripts/agent/validate-events.mjs` to validate event builders against schemas. - Fixed `NOTE_TYPES.REPOST` schema content format (json instead of empty). - Added `NOTE_TYPES.MUTE_LIST` and `buildMuteListEvent`. - Added `buildProfileMetadataEvent` to standardise Kind 0 creation. - Updated `js/ui/profileModalController.js` to use `buildProfileMetadataEvent`. - Updated `js/userBlocks.js` to use `buildMuteListEvent` for publishing mute list snapshots. - Updated `docs/nostr-event-schemas.md` with new schemas and builders.
This commit is contained in:
1 parent
474071e84a
commit
4d2bb8bf3d
5 files changed
+406
-26
No files matched your search
+11
-16
@@ -6,7 +6,7 @@ import {
|
||||
import { getActiveSigner } from "./nostr/index.js";
|
||||
import { isSessionActor } from "./nostr/sessionActor.js";
|
||||
import { normalizeNostrPubkey } from "./nostr/nip46Client.js";
|
||||
import { buildBlockListEvent, BLOCK_LIST_IDENTIFIER, NOTE_TYPES } from "./nostrEventSchemas.js";
|
||||
import { buildBlockListEvent, buildMuteListEvent, BLOCK_LIST_IDENTIFIER, NOTE_TYPES } from "./nostrEventSchemas.js";
|
||||
import { CACHE_POLICIES, STORAGE_TIERS } from "./nostr/cachePolicies.js";
|
||||
import { devLogger, userLogger } from "./utils/logger.js";
|
||||
import {
|
||||
@@ -1536,20 +1536,13 @@ class UserBlockListManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tags = sanitizeMuteTags(blockedPubkeys, owner);
|
||||
const sanitizedTags = sanitizeMuteTags(blockedPubkeys, owner);
|
||||
const pTags = sanitizedTags.map((tag) => tag[1]);
|
||||
|
||||
const timestamp = Number.isFinite(createdAt)
|
||||
? Math.max(0, Math.floor(createdAt))
|
||||
: Math.floor(Date.now() / 1000);
|
||||
|
||||
const event = {
|
||||
kind: 10000,
|
||||
pubkey: owner,
|
||||
created_at: timestamp,
|
||||
tags,
|
||||
content: "",
|
||||
};
|
||||
|
||||
const payloadText = typeof plaintext === "string" ? plaintext : "";
|
||||
let encryptedContent = "";
|
||||
let encryptionTagValue = "";
|
||||
@@ -1579,12 +1572,14 @@ class UserBlockListManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (encryptedContent) {
|
||||
event.content = encryptedContent;
|
||||
if (encryptionTagValue) {
|
||||
event.tags.push(["encrypted", encryptionTagValue]);
|
||||
}
|
||||
}
|
||||
const event = buildMuteListEvent({
|
||||
pubkey: owner,
|
||||
created_at: timestamp,
|
||||
pTags,
|
||||
content: encryptedContent,
|
||||
encrypted: !!encryptionTagValue,
|
||||
encryptionTag: encryptionTagValue,
|
||||
});
|
||||
|
||||
onStatus?.({ status: "mute-publishing" });
|
||||
|
||||
|
||||
Reference in new issue
Block a user