BUGFIX: fix double stringify on server array (#1100)

The server array that the RFA currently sends is stringified twice. I fixed that and also added a proper ResultType for the new data
This commit is contained in:
Shy
2024-02-16 01:27:03 +01:00
committed by GitHub
parent ddb10f833c
commit c894aba8f5
2 changed files with 9 additions and 5 deletions
+5 -1
View File
@@ -1,3 +1,5 @@
import type { BaseServer } from "src/Server/BaseServer";
export class RFAMessage {
jsonrpc = "2.0"; // Transmits version of JSON-RPC. Compliance maybe allows some funky interaction with external tools?
public method?: string; // Is defined when it's a request/notification, otherwise undefined
@@ -15,7 +17,7 @@ export class RFAMessage {
}
}
type ResultType = string | number | string[] | FileContent[];
type ResultType = string | number | string[] | FileContent[] | RFAServerData[];
type FileMetadata = FileData | FileContent | FileLocation | FileServer;
export interface FileData {
@@ -38,6 +40,8 @@ export interface FileServer {
server: string;
}
export type RFAServerData = Pick<BaseServer, "hostname" | "hasAdminRights">;
export function isFileData(p: unknown): p is FileData {
const pf = p as FileData;
return typeof pf.server === "string" && typeof pf.filename === "string" && typeof pf.content === "string";