diff --git a/src/app/index.ts b/src/app/index.ts index 3dbfce5..9ec8e36 100644 --- a/src/app/index.ts +++ b/src/app/index.ts @@ -14,7 +14,6 @@ import { NIP_11_SOFTWARE_URL, SENSITIVE_KINDS } from "../const.js"; import { OWNER_PUBKEY, BAKERY_PORT } from "../env.js"; import ControlApi from "../modules/control/control-api.js"; -import ConfigActions from "../modules/control/config-actions.js"; import DirectMessageManager from "../modules/direct-message-manager.js"; import DirectMessageActions from "../modules/control/dm-actions.js"; import AddressBook from "../modules/address-book.js"; @@ -170,7 +169,6 @@ export default class App extends EventEmitter { // API for controlling the node this.control = new ControlApi(this); - this.control.registerHandler(new ConfigActions(this)); this.control.registerHandler(new DirectMessageActions(this)); this.control.registerHandler(new NotificationActions(this)); this.control.registerHandler(new RemoteAuthActions(this)); diff --git a/src/modules/async-loader.ts b/src/modules/async-loader.ts index 180d098..ece1b8d 100644 --- a/src/modules/async-loader.ts +++ b/src/modules/async-loader.ts @@ -8,7 +8,7 @@ import { } from "applesauce-core/helpers"; import { simpleTimeout } from "applesauce-core/observable"; import { ReplaceableLoader, SingleEventLoader } from "applesauce-loaders/loaders"; -import { filter, firstValueFrom, map, of, OperatorFunction } from "rxjs"; +import { filter, firstValueFrom, OperatorFunction } from "rxjs"; import { kinds } from "nostr-tools"; /** Helper class for asynchronously loading event data */ diff --git a/src/modules/control/config-actions.ts b/src/modules/control/config-actions.ts deleted file mode 100644 index e5f858d..0000000 --- a/src/modules/control/config-actions.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { WebSocket } from "ws"; -import { ConfigMessage, ConfigResponse } from "@satellite-earth/core/types/control-api/config.js"; - -import type App from "../../app/index.js"; -import { type ControlMessageHandler } from "./control-api.js"; - -/** handles ['CONTROL', 'CONFIG', ...] messages */ -export default class ConfigActions implements ControlMessageHandler { - app: App; - name = "CONFIG"; - - private subscribed = new Set(); - - constructor(app: App) { - this.app = app; - - // when config changes send it to the subscribed sockets - this.app.config.on("changed", (config) => { - for (const sock of this.subscribed) { - this.send(sock, ["CONTROL", "CONFIG", "CHANGED", config]); - } - }); - } - - handleMessage(sock: WebSocket | NodeJS.Process, message: ConfigMessage) { - const method = message[2]; - switch (method) { - case "SUBSCRIBE": - this.subscribed.add(sock); - sock.once("close", () => this.subscribed.delete(sock)); - this.send(sock, ["CONTROL", "CONFIG", "CHANGED", this.app.config.data]); - return true; - - case "SET": - const field = message[3]; - const value = message[4]; - - // @ts-expect-error - this.app.config.setField(field, value); - return true; - - default: - return false; - } - } - - send(sock: WebSocket | NodeJS.Process, response: ConfigResponse) { - sock.send?.(JSON.stringify(response)); - } -} diff --git a/src/modules/control/scrapper-actions.ts b/src/modules/control/scrapper-actions.ts deleted file mode 100644 index 42863d3..0000000 --- a/src/modules/control/scrapper-actions.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { WebSocket } from "ws"; -import { ScrapperMessage } from "@satellite-earth/core/types/control-api/scrapper.js"; - -import type App from "../../app/index.js"; -import { type ControlMessageHandler } from "./control-api.js"; - -export default class ScrapperActions implements ControlMessageHandler { - app: App; - name = "SCRAPPER"; - - constructor(app: App) { - this.app = app; - } - handleMessage(sock: WebSocket | NodeJS.Process, message: ScrapperMessage): boolean { - const action = message[2]; - switch (action) { - case "START": - this.app.scrapper.start(); - return true; - - case "STOP": - this.app.scrapper.stop(); - return true; - - case "ADD-PUBKEY": - this.app.scrapper.addPubkey(message[3]); - return true; - - case "REMOVE-PUBKEY": - this.app.scrapper.removePubkey(message[3]); - return true; - - default: - return false; - } - } -}