diff --git a/app/graphql/resolvers/query/crash-reporting-enabled.ts b/app/graphql/resolvers/query/crash-reporting-enabled.ts new file mode 100644 index 000000000..a72e16f99 --- /dev/null +++ b/app/graphql/resolvers/query/crash-reporting-enabled.ts @@ -0,0 +1,22 @@ +/*! + * Copyright 2021 Lime Technology Inc. All rights reserved. + * Written by: Alexis Tyler + */ + +import { paths } from '../../../core'; +import { varState } from '../../../core/states'; +import { ensurePermission, loadState } from '../../../core/utils'; +import { Context, getServers } from '../../schema/utils'; + +export default async (_: unknown, __: unknown, context: Context) => { + ensurePermission(context.user, { + resource: 'owner', + action: 'read', + possession: 'any' + }); + + // Check if crash reporting is enabled + const configPath = paths.get('myservers-config')!; + const file = loadState<{ remote: { sendCrashInfo: string } }>(configPath); + return (file.remote.sendCrashInfo ?? 'no').trim() === 'yes'; +}; diff --git a/app/graphql/resolvers/query/index.ts b/app/graphql/resolvers/query/index.ts index ef45efca7..312d09df3 100644 --- a/app/graphql/resolvers/query/index.ts +++ b/app/graphql/resolvers/query/index.ts @@ -2,6 +2,7 @@ * Copyright 2019-2020 Lime Technology Inc. All rights reserved. * Written by: Alexis Tyler */ +import crashReportingEnabled from './crash-reporting-enabled'; import display from './display'; import flash from './flash'; import info from './info'; @@ -13,6 +14,7 @@ import servers from './servers'; import vms from './vms'; export const Query = { + crashReportingEnabled, display, flash, info, diff --git a/app/graphql/schema/types/crash-reporting-enabled/crash-reporting-enabled.graphql b/app/graphql/schema/types/crash-reporting-enabled/crash-reporting-enabled.graphql new file mode 100644 index 000000000..365c86e46 --- /dev/null +++ b/app/graphql/schema/types/crash-reporting-enabled/crash-reporting-enabled.graphql @@ -0,0 +1,7 @@ +type Query { + crashReportingEnabled: Boolean +} + +type Subscription { + crashReportingEnabled: Boolean! +}