From 501fe0d443407f45fdc1b5521448431a9bfd4587 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Mon, 6 Apr 2026 21:55:40 +0200 Subject: [PATCH] change some plugin stuff and allow to hook into tx_search --- server/index.js | 2 +- server/plugins.js | 8 +++++++- server/storage.js | 3 ++- server/tx_search.js | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/server/index.js b/server/index.js index 9f4a104..8472d4f 100644 --- a/server/index.js +++ b/server/index.js @@ -14,7 +14,7 @@ require("./device"); { const helpers = require('./helpers'); const plugins = helpers.findServerFiles(serverConfig.plugins); - if (plugins.length > 0) setTimeout(helpers.startPluginsWithDelay, 4000, plugins, 3000); + if (plugins.length > 0) setTimeout(helpers.startPluginsWithDelay, 3000, plugins, 3000); } require('./stream/index'); diff --git a/server/plugins.js b/server/plugins.js index ebfdd48..f9c39ae 100644 --- a/server/plugins.js +++ b/server/plugins.js @@ -14,7 +14,13 @@ function parsePluginConfig(filePath) { const pluginExports = require(filePath); Object.assign(pluginConfig, pluginExports.pluginConfig); - // Check if pluginConfig has frontEndPath defined + if(pluginConfig.server_embedded) { + setTimeout(function() { + consoleCmd.logInfo(`Server plugin ${pluginConfig.name} ${pluginConfig.version} initialized successfully.`); + }, 500) + return pluginConfig; + } + if (pluginConfig.frontEndPath) { const sourcePath = path.join(path.dirname(filePath), pluginConfig.frontEndPath); const destinationDir = path.join(__dirname, '../web/js/plugins', path.dirname(pluginConfig.frontEndPath)); diff --git a/server/storage.js b/server/storage.js index 5eb7149..fe359d0 100644 --- a/server/storage.js +++ b/server/storage.js @@ -2,5 +2,6 @@ let connectedUsers = []; let chatHistory = []; let websocket_delegation = new Map(); var ctl_output; +var tx_search_hook = {}; -module.exports = { connectedUsers, chatHistory, websocket_delegation, ctl_output }; \ No newline at end of file +module.exports = { connectedUsers, chatHistory, websocket_delegation, ctl_output, tx_search_hook }; \ No newline at end of file diff --git a/server/tx_search.js b/server/tx_search.js index bf2a1b3..aa59db8 100644 --- a/server/tx_search.js +++ b/server/tx_search.js @@ -3,6 +3,7 @@ if(!configExists()) return; const fetch = require('node-fetch'); const consoleCmd = require('./console'); +const storage = require('./storage'); let localDb = {}; let nextLocalDbUpdate = 0; @@ -217,7 +218,8 @@ async function fetchTx(freq, piCode, rdsPs) { if (serverConfig.webserver.rdsMode === true) await loadUsStatesGeoJson(); const key = `${freq}|${piCode.toUpperCase()}`; - let rawMatches = piFreqIndex[key] || []; + var rawMatches = piFreqIndex[key] || []; + rawMatches = [...storage.tx_search_hook[key], ...rawMatches]; // Format the results into the same structure as before let filteredLocations = rawMatches.map(({ station, ...locData }) => ({