Page MenuHomePhabricator

D13460.id44532.diff
No OneTemporary

D13460.id44532.diff

diff --git a/keyserver/src/creators/message-report-creator.js b/keyserver/src/creators/message-report-creator.js
--- a/keyserver/src/creators/message-report-creator.js
+++ b/keyserver/src/creators/message-report-creator.js
@@ -78,10 +78,13 @@
request: MessageReportCreationRequest,
): Promise<MessageReportData> {
const keyserverAdminIDPromise = fetchKeyserverAdminID();
- const reportedMessagePromise = fetchMessageInfoByID(
- viewer,
- request.messageID,
- );
+ const reportedMessagePromise = (async () => {
+ const { messageID } = request;
+ if (!messageID) {
+ return null;
+ }
+ return await fetchMessageInfoByID(viewer, messageID);
+ })();
const viewerUsernamePromise = fetchUsername(viewer.id);
const keyserverAdminID = await keyserverAdminIDPromise;
diff --git a/keyserver/src/responders/message-report-responder.js b/keyserver/src/responders/message-report-responder.js
--- a/keyserver/src/responders/message-report-responder.js
+++ b/keyserver/src/responders/message-report-responder.js
@@ -1,6 +1,6 @@
// @flow
-import type { TInterface } from 'tcomb';
+import t, { type TInterface } from 'tcomb';
import {
type MessageReportCreationRequest,
@@ -13,7 +13,7 @@
export const messageReportCreationRequestInputValidator: TInterface<MessageReportCreationRequest> =
tShape<MessageReportCreationRequest>({
- messageID: tID,
+ messageID: t.maybe(tID),
});
async function messageReportCreationResponder(
diff --git a/lib/actions/message-report-actions.js b/lib/actions/message-report-actions.js
--- a/lib/actions/message-report-actions.js
+++ b/lib/actions/message-report-actions.js
@@ -1,12 +1,13 @@
// @flow
-import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js';
+import { extractKeyserverIDFromIDOptional } from '../keyserver-conn/keyserver-call-utils.js';
import { useKeyserverCall } from '../keyserver-conn/keyserver-call.js';
import type { CallKeyserverEndpoint } from '../keyserver-conn/keyserver-conn-types.js';
import type {
MessageReportCreationRequest,
MessageReportCreationResult,
} from '../types/message-report-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
const sendMessageReportActionTypes = Object.freeze({
started: 'SEND_MESSAGE_REPORT_STARTED',
@@ -20,8 +21,13 @@
input: MessageReportCreationRequest,
) => Promise<MessageReportCreationResult>) =>
async input => {
- const keyserverID = extractKeyserverIDFromID(input.messageID);
- const requests = { [keyserverID]: input };
+ const messageKeyserverID = input.messageID
+ ? extractKeyserverIDFromIDOptional(input.messageID)
+ : null;
+ const keyserverID: string =
+ messageKeyserverID ?? authoritativeKeyserverID();
+ const messageID = messageKeyserverID ? input.messageID : null;
+ const requests = { [keyserverID]: { messageID } };
const responses = await callKeyserverEndpoint(
'create_message_report',
diff --git a/lib/types/message-report-types.js b/lib/types/message-report-types.js
--- a/lib/types/message-report-types.js
+++ b/lib/types/message-report-types.js
@@ -3,7 +3,7 @@
import type { RawMessageInfo } from './message-types.js';
export type MessageReportCreationRequest = {
- +messageID: string,
+ +messageID: ?string,
};
export type MessageReportCreationResult = {

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 2:59 PM (21 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2535106
Default Alt Text
D13460.id44532.diff (3 KB)

Event Timeline