Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/responders/report-responders.js
Show All 23 Lines | |||||
import { newEntryQueryInputValidator } from './entry-responders.js'; | import { newEntryQueryInputValidator } from './entry-responders.js'; | ||||
import createReport from '../creators/report-creator.js'; | import createReport from '../creators/report-creator.js'; | ||||
import { | import { | ||||
fetchErrorReportInfos, | fetchErrorReportInfos, | ||||
fetchReduxToolsImport, | fetchReduxToolsImport, | ||||
} from '../fetchers/report-fetchers.js'; | } from '../fetchers/report-fetchers.js'; | ||||
import type { Viewer } from '../session/viewer.js'; | import type { Viewer } from '../session/viewer.js'; | ||||
import { validateInput } from '../utils/validation-utils.js'; | import { validateInput, validateOutput } from '../utils/validation-utils.js'; | ||||
const tActionSummary = tShape({ | const tActionSummary = tShape({ | ||||
type: t.String, | type: t.String, | ||||
time: t.Number, | time: t.Number, | ||||
summary: t.String, | summary: t.String, | ||||
}); | }); | ||||
const threadInconsistencyReportValidatorShape: TStructProps<ThreadInconsistencyReportShape> = | const threadInconsistencyReportValidatorShape: TStructProps<ThreadInconsistencyReportShape> = | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | input = { | ||||
platformDetails: { platform: deviceType, codeVersion, stateVersion }, | platformDetails: { platform: deviceType, codeVersion, stateVersion }, | ||||
}; | }; | ||||
} | } | ||||
const request: ReportCreationRequest = input; | const request: ReportCreationRequest = input; | ||||
const response = await createReport(viewer, request); | const response = await createReport(viewer, request); | ||||
if (!response) { | if (!response) { | ||||
throw new ServerError('ignored_report'); | throw new ServerError('ignored_report'); | ||||
} | } | ||||
return response; | return validateOutput(viewer, reportCreationResponseValidator, response); | ||||
} | } | ||||
const reportMultiCreationRequestInputValidator = tShape({ | const reportMultiCreationRequestInputValidator = tShape({ | ||||
reports: t.list( | reports: t.list( | ||||
t.union([ | t.union([ | ||||
tShape({ | tShape({ | ||||
type: t.irreducible('reportTypes.ERROR', x => x === reportTypes.ERROR), | type: t.irreducible('reportTypes.ERROR', x => x === reportTypes.ERROR), | ||||
platformDetails: tPlatformDetails, | platformDetails: tPlatformDetails, | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | async function errorReportFetchInfosResponder( | ||||
input: any, | input: any, | ||||
): Promise<FetchErrorReportInfosResponse> { | ): Promise<FetchErrorReportInfosResponse> { | ||||
const request: FetchErrorReportInfosRequest = input; | const request: FetchErrorReportInfosRequest = input; | ||||
await validateInput( | await validateInput( | ||||
viewer, | viewer, | ||||
fetchErrorReportInfosRequestInputValidator, | fetchErrorReportInfosRequestInputValidator, | ||||
request, | request, | ||||
); | ); | ||||
return await fetchErrorReportInfos(viewer, request); | const response = await fetchErrorReportInfos(viewer, request); | ||||
return validateOutput( | |||||
viewer, | |||||
fetchErrorReportInfosResponseValidator, | |||||
response, | |||||
); | |||||
} | } | ||||
async function errorReportDownloadResponder( | async function errorReportDownloadResponder( | ||||
viewer: Viewer, | viewer: Viewer, | ||||
req: $Request, | req: $Request, | ||||
res: $Response, | res: $Response, | ||||
): Promise<void> { | ): Promise<void> { | ||||
const id = req.params.reportID; | const id = req.params.reportID; | ||||
Show All 19 Lines |