mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-08 13:52:58 +00:00
update
This commit is contained in:
1 parent
000127f88c
commit
071d78dd6c
194 files changed
+28793
-3944
No files matched your search
@@ -2095,7 +2095,13 @@ export class ModerationService {
|
||||
return Number.isFinite(entry.trusted) ? entry.trusted : 0;
|
||||
}
|
||||
|
||||
async submitReport({ eventId, type, targetPubkey = "", content = "" } = {}) {
|
||||
async submitReport({
|
||||
eventId,
|
||||
type,
|
||||
targetPubkey = "",
|
||||
relayHint = "",
|
||||
content = "",
|
||||
} = {}) {
|
||||
const normalizedEventId = normalizeEventId(eventId);
|
||||
if (!normalizedEventId) {
|
||||
const error = new Error("invalid-event-id");
|
||||
@@ -2117,6 +2123,13 @@ export class ModerationService {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const normalizedTarget = normalizeHex(targetPubkey);
|
||||
if (!normalizedTarget) {
|
||||
const error = new Error("invalid-target-pubkey");
|
||||
error.code = "invalid-target-pubkey";
|
||||
throw error;
|
||||
}
|
||||
|
||||
const extension = typeof window !== "undefined" ? window.nostr : null;
|
||||
if (!extension) {
|
||||
const error = new Error("nostr-extension-missing");
|
||||
@@ -2137,17 +2150,20 @@ export class ModerationService {
|
||||
}
|
||||
}
|
||||
|
||||
const sanitizedRelayHint =
|
||||
typeof relayHint === "string" ? relayHint.trim() : "";
|
||||
|
||||
const eventTag = ["e", normalizedEventId, normalizedType];
|
||||
if (sanitizedRelayHint) {
|
||||
eventTag.push(sanitizedRelayHint);
|
||||
}
|
||||
|
||||
const tags = [
|
||||
["e", normalizedEventId, "", normalizedType],
|
||||
["report", normalizedType],
|
||||
eventTag,
|
||||
["p", normalizedTarget, normalizedType],
|
||||
["t", normalizedType],
|
||||
];
|
||||
|
||||
const normalizedTarget = normalizeHex(targetPubkey);
|
||||
if (normalizedTarget) {
|
||||
tags.push(["p", normalizedTarget]);
|
||||
}
|
||||
|
||||
const event = {
|
||||
kind: 1984,
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
|
||||
Reference in new issue
Block a user