Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3378002
D13459.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
D13459.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
@@ -36,6 +36,7 @@
viewer: Viewer,
request: MessageReportCreationRequest,
): Promise<RawMessageInfo[]> {
+ const keyserverAdminIDPromise = fetchKeyserverAdminID();
const {
reportedMessageText,
reporterUsername,
@@ -51,19 +52,25 @@
reportedMessageText,
);
const time = Date.now();
- const result = await createMessages(viewer, [
- {
- type: messageTypes.TEXT,
- threadID: commbotThreadID,
- creatorID: commbot.userID,
- time,
- text: reportMessage,
- },
+ const [messageResult, keyserverAdminID] = await Promise.all([
+ createMessages(viewer, [
+ {
+ type: messageTypes.TEXT,
+ threadID: commbotThreadID,
+ creatorID: commbot.userID,
+ time,
+ text: reportMessage,
+ },
+ ]),
+ keyserverAdminIDPromise,
]);
- if (result.length === 0) {
+ if (messageResult.length === 0) {
throw new ServerError('message_report_failed');
}
- return result;
+ if (viewer.userID === keyserverAdminID) {
+ return messageResult;
+ }
+ return [];
}
async function fetchMessageReportData(
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -1004,15 +1004,17 @@
newThreadInfos,
);
} else if (action.type === sendMessageReportActionTypes.success) {
- return mergeNewMessages(
- messageStore,
- [action.payload.messageInfo],
- {
- [(action.payload.messageInfo.threadID: string)]:
- messageTruncationStatus.UNCHANGED,
- },
- newThreadInfos,
- );
+ const { messageInfo } = action.payload;
+ if (messageInfo) {
+ return mergeNewMessages(
+ messageStore,
+ [messageInfo],
+ {
+ [(messageInfo.threadID: string)]: messageTruncationStatus.UNCHANGED,
+ },
+ newThreadInfos,
+ );
+ }
} else if (action.type === legacyKeyserverRegisterActionTypes.success) {
const truncationStatuses: { [string]: MessageTruncationStatus } = {};
for (const messageInfo of action.payload.rawMessageInfos) {
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
@@ -7,5 +7,5 @@
};
export type MessageReportCreationResult = {
- +messageInfo: RawMessageInfo,
+ +messageInfo: ?RawMessageInfo,
};
diff --git a/lib/types/validators/message-report-validators.js b/lib/types/validators/message-report-validators.js
--- a/lib/types/validators/message-report-validators.js
+++ b/lib/types/validators/message-report-validators.js
@@ -1,10 +1,12 @@
// @flow
-import type { TInterface } from 'tcomb';
+import t, { type TInterface } from 'tcomb';
import { tShape } from '../../utils/validation-utils.js';
import { type MessageReportCreationResult } from '../message-report-types.js';
import { rawMessageInfoValidator } from '../message-types.js';
export const messageReportCreationResultValidator: TInterface<MessageReportCreationResult> =
- tShape<MessageReportCreationResult>({ messageInfo: rawMessageInfoValidator });
+ tShape<MessageReportCreationResult>({
+ messageInfo: t.maybe(rawMessageInfoValidator),
+ });
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 8:33 AM (18 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2593417
Default Alt Text
D13459.diff (3 KB)
Attached To
Mode
D13459: [keyserver][lib] Don't return commbot -> admin report message from message report creator
Attached
Detach File
Event Timeline
Log In to Comment