diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js --- a/keyserver/src/endpoints.js +++ b/keyserver/src/endpoints.js @@ -18,6 +18,7 @@ } from './responders/entry-responders'; import type { JSONResponder } from './responders/handlers'; import { getSessionPublicKeysResponder } from './responders/keys-responders'; +import { messageReportCreationResponder } from './responders/message-report-responder'; import { textMessageCreationResponder, messageFetchResponder, @@ -58,6 +59,7 @@ create_account: accountCreationResponder, create_entry: entryCreationResponder, create_error_report: reportCreationResponder, + create_message_report: messageReportCreationResponder, create_multimedia_message: multimediaMessageCreationResponder, create_report: reportCreationResponder, create_reports: reportMultiCreationResponder, diff --git a/keyserver/src/responders/message-report-responder.js b/keyserver/src/responders/message-report-responder.js new file mode 100644 --- /dev/null +++ b/keyserver/src/responders/message-report-responder.js @@ -0,0 +1,27 @@ +// @flow + +import t from 'tcomb'; + +import { type MessageReportCreationRequest } from 'lib/types/message-report-types'; +import { tShape } from 'lib/utils/validation-utils'; + +import createMessageReport from '../creators/message-report-creator'; +import type { Viewer } from '../session/viewer'; +import { validateInput } from '../utils/validation-utils'; + +const messageReportCreationRequestInputValidator = tShape({ + messageID: t.String, +}); + +async function messageReportCreationResponder(viewer: Viewer, input: any) { + await validateInput( + viewer, + messageReportCreationRequestInputValidator, + input, + ); + const request: MessageReportCreationRequest = input; + + await createMessageReport(viewer, request); +} + +export { messageReportCreationResponder }; diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js --- a/lib/types/endpoints.js +++ b/lib/types/endpoints.js @@ -48,6 +48,7 @@ const socketPreferredEndpoints = Object.freeze({ CREATE_ENTRY: 'create_entry', CREATE_ERROR_REPORT: 'create_error_report', + CREATE_MESSAGE_REPORT: 'create_message_report', CREATE_MULTIMEDIA_MESSAGE: 'create_multimedia_message', CREATE_TEXT_MESSAGE: 'create_text_message', CREATE_THREAD: 'create_thread',