Merge pull request #100 from fiatjaf/nip70

implement NIP-70: protected events
This commit is contained in:
Doug Hoyte
2024-07-18 23:38:44 -04:00
committed by GitHub
2 changed files with 12 additions and 1 deletions

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()); 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())); auto existing = lookupEventById(txn, sv(flat->id()));
if (existing) { if (existing) {

View File

@ -48,7 +48,7 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
tempBuf.reserve(cfg().events__maxEventSize + MAX_SUBID_SIZE + 100); tempBuf.reserve(cfg().events__maxEventSize + MAX_SUBID_SIZE + 100);
tao::json::value supportedNips = tao::json::value::array({ 1, 2, 4, 9, 11, 12, 16, 20, 22, 28, 33, 40 }); tao::json::value supportedNips = tao::json::value::array({ 1, 2, 4, 9, 11, 20, 22, 28, 40, 70 });
auto getServerInfoHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable { auto getServerInfoHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable {
if (ver != cfg().version()) { if (ver != cfg().version()) {