-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from planetary-social/giftwrap-allowed
Giftwrap allowed
- Loading branch information
Showing
6 changed files
with
48 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env node | ||
|
||
const ALLOWED = { | ||
pubs: { | ||
add5190be4673768546c18b565da3a699241f0e06a75e2dbc03f18663d1b7b27: true, // Reportinator | ||
}, | ||
eventKinds: [ | ||
0, // Metadata | ||
3, // Contacts | ||
1059, // Gift wrap messages | ||
10002, // Relay list metadata | ||
], | ||
}; | ||
|
||
const rl = require("readline").createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
terminal: false, | ||
}); | ||
|
||
rl.on("line", (line) => { | ||
let req = JSON.parse(line); | ||
|
||
if (req.type === "lookback" || req.type !== "new") { | ||
return; | ||
} | ||
|
||
let res = { id: req.event.id }; // must echo the event's id | ||
|
||
const isAllowedPub = ALLOWED.pubs.hasOwnProperty(req.event.pubkey); | ||
const isAllowedEventKind = ALLOWED.eventKinds.includes(req.event.kind); | ||
|
||
if (isAllowedPub || isAllowedEventKind) { | ||
res.action = "accept"; | ||
} else { | ||
res.action = "reject"; | ||
res.msg = "blocked: pubkey not on white-list or event kind not allowed"; | ||
} | ||
|
||
console.log(JSON.stringify(res)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters