*Simplify clear_cached_item so it just needs to use broadcast_request as a proxy
This commit is contained in:
parent
86ce21a4b4
commit
364e628c7a
|
@ -56,38 +56,12 @@ const plugin: Plugin = {
|
||||||
});
|
});
|
||||||
api.registerMethod("clear_cached_item", {
|
api.registerMethod("clear_cached_item", {
|
||||||
cacheable: false,
|
cacheable: false,
|
||||||
async handler(req: RPCClearCacheRequest): Promise<RPCClearCacheResponse> {
|
async handler(req: string): Promise<RPCClearCacheResponse> {
|
||||||
if (req?.relays?.length) {
|
if (typeof req !== "string") {
|
||||||
let resp = await broadcastRequest(
|
throw new Error("item must be a string");
|
||||||
{
|
}
|
||||||
module: "rpc",
|
|
||||||
method: "clear_cached_item",
|
|
||||||
data: req.request,
|
|
||||||
},
|
|
||||||
req?.relays
|
|
||||||
);
|
|
||||||
let results: RPCClearCacheResponse = {
|
|
||||||
relays: {},
|
|
||||||
data: true,
|
|
||||||
signedField: "relays",
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const relay in resp) {
|
|
||||||
let ret: RPCClearCacheResponse;
|
|
||||||
try {
|
try {
|
||||||
ret = await resp.get(relay);
|
api.getRpcServer().cache.deleteItem(req);
|
||||||
} catch (e: any) {
|
|
||||||
(results.relays as RPCClearCacheResponseRelayList)[relay] = {
|
|
||||||
error: e.message,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
api.getRpcServer().cache.deleteItem(req.request);
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue