Remove Redis mute plumbing; expose mute list in /status JSON
Dashboard will write mutes directly to the PTY rather than Redis; the Redis addTrunkMute/removeTrunkMute/loadTrunkMutes methods and the PTY write-through were unused. Mute state is now reflected in the /status JSON as a per-trunk 'muted' array so operators and dashboards can see current state without polling Redis.
This commit is contained in:
1 parent
aed5566956
commit
bc412e1847
6 files changed
+10
-98
No files matched your search
@@ -194,38 +194,6 @@ std::map<uint32_t, uint32_t> RedisStore::loadTrunkTgMap(const std::string& secti
|
||||
return out;
|
||||
}
|
||||
|
||||
std::set<std::string> RedisStore::loadTrunkMutes(const std::string& section) {
|
||||
std::set<std::string> out;
|
||||
if (!m_sync) return out;
|
||||
std::string k = keyFor("trunk:" + section + ":mutes");
|
||||
redisReply* r = (redisReply*)redisCommand(m_sync, "SMEMBERS %s", k.c_str());
|
||||
if (r && r->type == REDIS_REPLY_ARRAY) {
|
||||
for (size_t i = 0; i < r->elements; ++i) {
|
||||
if (r->element[i]->type == REDIS_REPLY_STRING) {
|
||||
out.emplace(r->element[i]->str, r->element[i]->len);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r) freeReplyObject(r);
|
||||
return out;
|
||||
}
|
||||
|
||||
void RedisStore::addTrunkMute(const std::string& section, const std::string& callsign) {
|
||||
if (!m_sync) return;
|
||||
std::string k = keyFor("trunk:" + section + ":mutes");
|
||||
redisReply* r = (redisReply*)redisCommand(m_sync, "SADD %s %s",
|
||||
k.c_str(), callsign.c_str());
|
||||
if (r) freeReplyObject(r);
|
||||
}
|
||||
|
||||
void RedisStore::removeTrunkMute(const std::string& section, const std::string& callsign) {
|
||||
if (!m_sync) return;
|
||||
std::string k = keyFor("trunk:" + section + ":mutes");
|
||||
redisReply* r = (redisReply*)redisCommand(m_sync, "SREM %s %s",
|
||||
k.c_str(), callsign.c_str());
|
||||
if (r) freeReplyObject(r);
|
||||
}
|
||||
|
||||
void RedisStore::publishConfigChanged(const std::string& scope) {
|
||||
if (!m_sync) return;
|
||||
std::string ch = channelName();
|
||||
|
||||
@@ -56,12 +56,6 @@ class RedisStore : public sigc::trackable
|
||||
std::string loadTrunkFilter(const std::string& section,
|
||||
const std::string& field); // "blacklist"|"allow"
|
||||
std::map<uint32_t, uint32_t> loadTrunkTgMap(const std::string& section);
|
||||
std::set<std::string> loadTrunkMutes(const std::string& section);
|
||||
|
||||
// Mute set ops (sync, used by PTY persistence).
|
||||
void addTrunkMute(const std::string& section, const std::string& callsign);
|
||||
void removeTrunkMute(const std::string& section, const std::string& callsign);
|
||||
|
||||
// Publish a config.changed scope token (sync).
|
||||
void publishConfigChanged(const std::string& scope);
|
||||
|
||||
|
||||
@@ -2036,12 +2036,6 @@ void Reflector::ctrlPtyDataReceived(const void *buf, size_t count)
|
||||
if (subcmd == "MUTE") link->muteCallsign(callsign);
|
||||
else link->unmuteCallsign(callsign);
|
||||
|
||||
if (m_redis) {
|
||||
if (subcmd == "MUTE") m_redis->addTrunkMute(section, callsign);
|
||||
else m_redis->removeTrunkMute(section, callsign);
|
||||
m_redis->publishConfigChanged("trunk:" + section);
|
||||
}
|
||||
|
||||
m_cmd_pty->write(section + ": " + subcmd + " " + callsign + "\n");
|
||||
}
|
||||
else if (subcmd == "RELOAD")
|
||||
|
||||
@@ -384,6 +384,10 @@ Json::Value TrunkLink::statusJson(void) const
|
||||
}
|
||||
obj["active_talkers"] = talkers;
|
||||
|
||||
Json::Value muted_arr(Json::arrayValue);
|
||||
for (const auto& cs : m_muted_callsigns) muted_arr.append(cs);
|
||||
obj["muted"] = muted_arr;
|
||||
|
||||
return obj;
|
||||
} /* TrunkLink::statusJson */
|
||||
|
||||
@@ -1149,18 +1153,13 @@ void TrunkLink::reloadConfig(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (rs) {
|
||||
m_muted_callsigns = rs->loadTrunkMutes(m_section);
|
||||
}
|
||||
|
||||
cout << m_section << ": Reloaded filters"
|
||||
<< (m_blacklist_filter.empty() ? "" :
|
||||
" blacklist=" + m_blacklist_filter.toString())
|
||||
<< (m_allow_filter.empty() ? "" :
|
||||
" allow=" + m_allow_filter.toString())
|
||||
<< " tg_map_entries=" << m_tg_map_in.size();
|
||||
if (rs) cout << " mutes=" << m_muted_callsigns.size();
|
||||
cout << endl;
|
||||
<< " tg_map_entries=" << m_tg_map_in.size()
|
||||
<< endl;
|
||||
} /* TrunkLink::reloadConfig */
|
||||
|
||||
|
||||
|
||||
@@ -154,6 +154,10 @@ class TrunkLink : public sigc::trackable
|
||||
{
|
||||
return m_muted_callsigns.count(callsign) > 0;
|
||||
}
|
||||
const std::set<std::string>& mutedCallsigns(void) const
|
||||
{
|
||||
return m_muted_callsigns;
|
||||
}
|
||||
// Re-parse BLACKLIST_TGS, ALLOW_TGS and TG_MAP from current config
|
||||
void reloadConfig(void);
|
||||
// One-line summary for TRUNK STATUS
|
||||
|
||||
Reference in new issue
Block a user