mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-17 16:58:50 +00:00
Normally when a plugin blocks an event, it will log a message. Especially when using plugins in stream
, router
, etc, this might be too verbose. In order to silence these logs, return an empty string for msg
(or no msg
at all).
This commit is contained in:
@ -77,4 +77,5 @@ To install:
|
||||
|
||||
* If applicable, you should ensure stdout is *line buffered* (for example, in perl use `$|++`).
|
||||
* If events are being rejected with `error: internal error`, then check the strfry logs. The plugin is misconfigured or failing.
|
||||
* Normally when a plugin blocks an event, it will log a message. Especially when using plugins in `stream`, `router`, etc, this might be too verbose. In order to silence these logs, return an empty string for `msg` (or no `msg` at all).
|
||||
* When returning an action of `accept`, it doesn't necessarily guarantee that the event will be accepted. The regular strfry checks are still subsequently applied, such as expiration, deletion, etc.
|
||||
|
@ -187,7 +187,7 @@ struct Router {
|
||||
if (res == PluginEventSifterResult::Accept) {
|
||||
router->writer.write({ std::move(evJson), EventSourceType::Stream, url });
|
||||
} else {
|
||||
LI << groupName << " / " << url << " : pluginDown blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
if (okMsg.size()) LI << groupName << " / " << url << " : pluginDown blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ struct Router {
|
||||
if (c.ws) c.ws->send(responseStr.data(), responseStr.size(), uWS::OpCode::TEXT, nullptr, nullptr, true);
|
||||
}
|
||||
} else {
|
||||
LI << groupName << " : pluginUp blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
if (okMsg.size()) LI << groupName << " : pluginUp blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ void cmd_stream(const std::vector<std::string> &subArgs) {
|
||||
downloadedIds.emplace(from_hex(evJson.at("id").get_string()));
|
||||
writer.write({ std::move(evJson), EventSourceType::Stream, url });
|
||||
} else {
|
||||
LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
if (okMsg.size()) LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
}
|
||||
} else {
|
||||
LW << "Unexpected EVENT";
|
||||
|
@ -164,7 +164,7 @@ void cmd_sync(const std::vector<std::string> &subArgs) {
|
||||
if (res == PluginEventSifterResult::Accept) {
|
||||
writer.write({ std::move(evJson), EventSourceType::Sync, url });
|
||||
} else {
|
||||
LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
if (okMsg.size()) LI << "[" << ws.remoteAddr << "] write policy blocked event " << evJson.at("id").get_string() << ": " << okMsg;
|
||||
}
|
||||
} else if (msg.at(0) == "EOSE") {
|
||||
inFlightDown = false;
|
||||
|
@ -48,7 +48,7 @@ void RelayServer::runWriter(ThreadPool<MsgWriter>::Thread &thr) {
|
||||
auto *flat = flatbuffers::GetRoot<NostrIndex::Event>(msg->flatStr.data());
|
||||
auto eventIdHex = to_hex(sv(flat->id()));
|
||||
|
||||
LI << "[" << msg->connId << "] write policy blocked event " << eventIdHex << ": " << okMsg;
|
||||
if (okMsg.size()) LI << "[" << msg->connId << "] write policy blocked event " << eventIdHex << ": " << okMsg;
|
||||
|
||||
sendOKResponse(msg->connId, eventIdHex, res == PluginEventSifterResult::ShadowReject, okMsg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user