mirror of
https://github.com/unraid/api.git
synced 2026-01-24 17:38:37 -06:00
feat: crash reporting enabled query/subscription endpoint
This commit is contained in:
22
app/graphql/resolvers/query/crash-reporting-enabled.ts
Normal file
22
app/graphql/resolvers/query/crash-reporting-enabled.ts
Normal 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';
|
||||
};
|
||||
@@ -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,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
type Query {
|
||||
crashReportingEnabled: Boolean
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
crashReportingEnabled: Boolean!
|
||||
}
|
||||
Reference in New Issue
Block a user