NAME
Net::Nostr::Report - NIP-56 Reporting
SYNOPSIS
use Net::Nostr::Report;
# Report a profile for spam
my $event = Net::Nostr::Report->report(
pubkey => $my_pubkey,
reported_pk => $spammer_pk,
report_type => 'spam',
);
# Report a note as illegal
my $event = Net::Nostr::Report->report(
pubkey => $my_pubkey,
reported_pk => $author_pk,
event_id => $note_id,
report_type => 'illegal',
content => 'Violates local law',
);
# Report a blob as malware
my $event = Net::Nostr::Report->report(
pubkey => $my_pubkey,
reported_pk => $author_pk,
report_type => 'malware',
blob_hash => $hash,
event_id => $containing_event_id,
server => 'https://example.com/file.ext',
);
# Parse a report event
my $info = Net::Nostr::Report->from_event($event);
say $info->reported_pubkey;
say $info->report_type; # nudity, malware, profanity, etc.
# Build a subscription filter
my $filter = Net::Nostr::Report->report_filter(
reported_pk => $target_pk,
);
CONSTRUCTOR
new
my $report = Net::Nostr::Report->new(
reported_pubkey => $pubkey_hex,
report_type => 'spam',
event_id => $event_id_hex,
);
Creates a new report object. All fields are optional. Croaks on unknown arguments. This is the raw constructor; use "report" to build a complete kind 1984 event.
DESCRIPTION
Implements NIP-56 (Reporting). Provides methods to create kind 1984 report events, parse existing reports, and build subscription filters.
Valid report types: nudity, malware, profanity, illegal, spam, impersonation, other.
report
my $event = Net::Nostr::Report->report(
pubkey => $my_pubkey,
reported_pk => $target_pk,
report_type => 'spam',
event_id => $note_id, # optional, for note reports
blob_hash => $hash, # optional, for blob reports
server => $url, # optional, for blob reports
content => 'reason', # optional
labels => [ # optional, NIP-32
['L', 'namespace'],
['l', 'value', 'namespace'],
],
);
Creates a kind 1984 report event. For profile-only reports, the report type is placed on the p tag. For note reports (event_id provided), the type is placed on the e tag. For blob reports (blob_hash provided), the type is placed on the x tag and event_id is required.
from_event
my $info = Net::Nostr::Report->from_event($event);
say $info->reported_pubkey;
say $info->report_type;
say $info->event_id; # undef for profile-only reports
say $info->blob_hash; # undef unless blob report
say $info->server; # undef unless provided
Parses a kind 1984 report event and returns a Net::Nostr::Report object.
validate
Net::Nostr::Report->validate($event);
Validates a kind 1984 report event. Croaks if the event is not kind 1984, has no p tag, or has an x tag without a corresponding e tag.
report_filter
my $filter = Net::Nostr::Report->report_filter(
reported_pk => $target_pk,
event_id => $note_id,
authors => [$reporter_pk],
);
Returns a subscription filter hashref for querying report events. All parameters are optional.
ACCESSORS
reported_pubkey
Hex pubkey of the reported user.
report_type
Report type string: nudity, malware, profanity, illegal, spam, impersonation, or other.
event_id
Reported event ID (64-char lowercase hex), or undef for profile-only reports.
blob_hash
Blob SHA-256 hash, or undef.
server
Server URL for blob reports, or undef.