mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 13:43:49 +01:00
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:
parent
ddb10f833c
commit
c894aba8f5
@ -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";
|
||||
|
@ -113,11 +113,11 @@ export const RFARequestHandler: Record<string, (message: RFAMessage) => void | R
|
||||
},
|
||||
|
||||
getAllServers: function (msg: RFAMessage): RFAMessage {
|
||||
const servers = GetAllServers().map((server) => ({
|
||||
hostname: server.hostname,
|
||||
hasAdminRights: server.hasAdminRights,
|
||||
const servers = GetAllServers().map(({ hostname, hasAdminRights }) => ({
|
||||
hostname,
|
||||
hasAdminRights,
|
||||
}));
|
||||
|
||||
return new RFAMessage({ result: JSON.stringify(servers), id: msg.id });
|
||||
return new RFAMessage({ result: servers, id: msg.id });
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user