Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3299713
D13460.id44532.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13460.id44532.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D13460: [keyserver][lib] Allow not specifying messageID in message report responder
Attached
Detach File
Event Timeline
Log In to Comment