Why Nostr? What is Njump?
2024-09-17 20:41:21
in reply to

Rif'at Ahdi R on Nostr: Just suggestion, maybe you can add policy rule like this Policy that request external ...

Just suggestion, maybe you can add policy rule like this

https://github.com/atrifat/strfry-policies/pull/1

Policy that request external API that you can freely implement later to process the event. I have done this nfrelay.app to filter RplyFamily and impersonator by reading metadata profile.

Simple Policy API server example can be made like this:
```
const express = require('express');
const bodyParser = require('body-parser');

const app = express();
const PORT = 3000;

// Middleware to parse JSON bodies
app.use(bodyParser.json());

// POST route for /spamfilter
app.post('/spamfilter', (req, res) => {
const { input } = req.body; // Destructure input from the request body
const content = input.content; // Assuming content is a property of input

// Simple spam detection logic (for demonstration purposes)
const spamKeywords = ['spam', 'buy now', 'click here'];
const isSpam = spamKeywords.some(keyword => content.includes(keyword));

// Respond with { accept: true } or { accept: false }
if (isSpam) {
return res.status(200).json({ accept: false });
}

res.status(200).json({ accept: true });
});

// Start the server
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});

```
Author Public Key
npub19dn7fq9hlxwjsdtgf28hyakcdmd73cccaf2u7a7vl42echey7ezs2hwja7