implement NIP-70, protected events.

This commit is contained in:
fiatjaf
2024-02-12 16:35:26 -03:00
parent c0dec7c53f
commit 42b28b9482

View File

@ -92,6 +92,17 @@ void RelayServer::ingesterProcessEvent(lmdb::txn &txn, uint64_t connId, std::str
auto *flat = flatbuffers::GetRoot<NostrIndex::Event>(flatStr.data());
{
for (const auto &tagArr : origJson.at("tags").get_array()) {
auto tag = tagArr.get_array();
if (tag.size() == 1 && tag.at(0).get_string() == "-") {
LI << "Protected event, skipping";
sendOKResponse(connId, to_hex(sv(flat->id())), false, "blocked: event marked as protected");
return;
}
}
}
{
auto existing = lookupEventById(txn, sv(flat->id()));
if (existing) {