Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/admin-ui/src/__mock-backend__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export const otherCalls: Omit<Routes, keyof typeof namedSpacedCalls> = {
getIsConnectedToInternet: async () => false,
getCoreVersion: async () => "0.2.92",
notificationsGetEndpoints: async () => {
return { "geth.dnp.dappnode.eth": { endpoints: [], customEndpoints: [] } };
return { "geth.dnp.dappnode.eth": { endpoints: [], customEndpoints: [], isCore: false } };
},
notificationsUpdateEndpoints: async () => {},
notificationsGetAll: async () => []
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function notificationsGetAll(): Promise<Notification[]> {
* Get gatus and custom endpoints indexed by dnpName
*/
export async function notificationsGetEndpoints(): Promise<{
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[] };
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[]; isCore: boolean };
}> {
return await notifications.getEndpoints();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/notifications/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Notifications {
* Get gatus and custom endpoints indexed by dnpName
*/
async getEndpoints(): Promise<{
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[] };
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[]; isCore: boolean };
}> {
return await this.manifest.getEndpoints();
}
Expand Down
18 changes: 12 additions & 6 deletions packages/notifications/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ export class NotificationsManifest {
* Get gatus and custom endpoints indexed by dnpName from filesystem
*/
async getEndpoints(): Promise<{
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[] };
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[]; isCore: boolean };
}> {
const packages = await listPackages();

const endpoints: { [dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[] } } = {};
const notificationsEndpoints: {
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[]; isCore: boolean };
} = {};
for (const pkg of packages) {
const manifestPath = getManifestPath(pkg.dnpName, pkg.isCore);
const manifest: Manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
if (manifest.notifications?.endpoints) endpoints[pkg.dnpName].endpoints = manifest.notifications.endpoints;
if (manifest.notifications?.customEndpoints)
endpoints[pkg.dnpName].customEndpoints = manifest.notifications.customEndpoints;

if (!manifest.notifications) continue;

const { endpoints, customEndpoints } = manifest.notifications;
if (endpoints) notificationsEndpoints[pkg.dnpName].endpoints = endpoints;
if (customEndpoints) notificationsEndpoints[pkg.dnpName].customEndpoints = customEndpoints;
if (notificationsEndpoints[pkg.dnpName]) notificationsEndpoints[pkg.dnpName].isCore = pkg.isCore;
}

return endpoints;
return notificationsEndpoints;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export interface Routes {
* Gatus get endpoints
*/
notificationsGetEndpoints(): Promise<{
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[] };
[dnpName: string]: { endpoints: GatusEndpoint[]; customEndpoints: CustomEndpoint[]; isCore: boolean };
}>;

/**
Expand Down
Loading