feat: crash reporting enabled query/subscription endpoint

This commit is contained in:
Alexis Tyler
2021-04-14 22:12:31 +09:30
parent e0af94d3ca
commit dc463d11ac
3 changed files with 31 additions and 0 deletions

View File

@@ -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';
};

View File

@@ -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,

View File

@@ -0,0 +1,7 @@
type Query {
crashReportingEnabled: Boolean
}
type Subscription {
crashReportingEnabled: Boolean!
}