antiDuplicationPolicy
import { antiDuplicationPolicy } from "https://gitlab.com/soapbox-pub/strfry-policies/-/raw/develop/mod.ts";
Prevent messages with the exact same content from being submitted repeatedly.
It stores a hashcode for each content in an SQLite database and rate-limits them. Only messages that meet the minimum length criteria are selected. Each time a matching message is submitted, the timer will reset, so spammers sending the same message will only ever get the first one through.
@example
// Prevent the same message from being posted within 60 seconds.
antiDuplicationPolicy(msg, { ttl: 60000 });
// Only enforce the policy on messages with at least 50 characters.
antiDuplicationPolicy(msg, { ttl: 60000, minLength: 50 });
// Use a custom SQLite path.
antiDuplicationPolicy(msg, { databaseUrl: 'sqlite:///media/ramdisk/nostr-contenthash.sqlite3' });
const antiDuplicationPolicy: Policy<AntiDuplication>;