diff --git a/src/components/common/messaging/Message.tsx b/src/components/common/messaging/Message.tsx
index 2b6d59d..efa0228 100644
--- a/src/components/common/messaging/Message.tsx
+++ b/src/components/common/messaging/Message.tsx
@@ -9,13 +9,13 @@ import {enGB, enUS} from 'date-fns/locale';
import {Message as RevoltMessage} from 'revolt.js';
import {decodeTime} from 'ulid';
-import {InviteEmbed, MessageEmbed, MessageReactions, ReplyMessage} from './';
+import {InviteEmbed, MessageEmbed, MessageReactions, PlatformModerationMessage, ReplyMessage} from './';
import {app, client, openUrl} from '../../../Generic';
import {Avatar} from '../../../Profile';
import {currentTheme, styles} from '../../../Theme';
import {Text, Username} from '../atoms';
import {MarkdownView} from '../MarkdownView';
-import {RE_INVITE} from '../../../lib/consts';
+import {RE_INVITE, USER_IDS} from '../../../lib/consts';
import {getReadableFileSize, parseRevoltNodes} from '../../../lib/utils';
const Image = FastImage;
@@ -195,6 +195,24 @@ export const Message = observer((props: MessageProps) => {
//
// );
// }
+ if (props.message.channel?.recipient?._id === USER_IDS.platformModeration) {
+ return (
+
+
+
+
+ );
+ }
return (
{
+ const REPORT_ID_REGEX = /[A-Z0-9]{6}/;
+ const REPORT_TARGET_REGEX = /(@)?[^,]*/;
+ const REPORT_REASON_REGEX = /[^,]*/;
+
+ const reportResponses = [
+ {response: 'invalid', match: 'marked as invalid.'},
+ {
+ response: 'falseReport',
+ match: 'False reports may lead to additional action',
+ },
+ {
+ response: 'insufficientEvidence',
+ match: 'you have additional information to support your report',
+ },
+ {response: 'duplicate', match: 'as a duplicate.'},
+ {response: 'actionTaken', match: 'appropriate action has been taken.'},
+ ] as Response[];
+
+ const isReport = message.content?.match('Your report');
+ const isStrike = message.content?.match('received an account strike');
+
+ let filteredContent;
+
+ try {
+ filteredContent = message.content
+ ?.replace('Your report (', '')
+ .replace('Report (', '');
+ } catch (error) {
+ console.log(
+ `[PLATFORMMODERATIONMESSAGE] Something went wrong filtering message ${message._id}: ${error}`,
+ );
+ }
+
+ let response = 'UNKNOWN';
+ let responseText: string;
+ let responseType: 'POSITIVE' | 'MIXED' | 'NEGATIVE' | 'UNKNOWN';
+
+ for (const r of reportResponses) {
+ if (filteredContent?.match(r.match)) {
+ response = r.response;
+ }
+ }
+
+ switch (response) {
+ case 'invalid':
+ responseText = 'Invalid report';
+ responseType = 'NEGATIVE';
+ break;
+ case 'falseReport':
+ responseText = 'False report';
+ responseType = 'NEGATIVE';
+ break;
+ case 'insufficientEvidence':
+ responseText = 'Insufficient report';
+ responseType = 'MIXED';
+ break;
+ case 'duplicate':
+ responseText = 'Duplicate report';
+ responseType = 'NEGATIVE';
+ break;
+ case 'actionTaken':
+ responseText = 'Action taken';
+ responseType = 'POSITIVE';
+ break;
+ default:
+ responseText = 'Unknown response';
+ responseType = 'UNKNOWN';
+ }
+
+ const rawReportID = isReport
+ ? filteredContent?.match(REPORT_ID_REGEX)
+ : undefined;
+
+ try {
+ filteredContent = filteredContent
+ ?.replace(REPORT_ID_REGEX, '')
+ .replace(', ', '');
+ } catch (error) {
+ console.log(
+ `[PLATFORMMODERATIONMESSAGE] Something went wrong 2-filtering message ${message._id}: ${error}`,
+ );
+ }
+
+ const rawReportTarget = isReport
+ ? filteredContent?.match(REPORT_TARGET_REGEX)
+ : undefined;
+
+ try {
+ filteredContent = filteredContent
+ ?.replace(REPORT_TARGET_REGEX, '')
+ .replace(', ', '');
+ } catch (error) {
+ console.log(
+ `[PLATFORMMODERATIONMESSAGE] Something went wrong 3-filtering message ${message._id}: ${error}`,
+ );
+ }
+
+ const rawReportReason =
+ isReport && filteredContent
+ ? filteredContent.match(REPORT_REASON_REGEX)
+ : undefined;
+
+ console.log(filteredContent);
+
+ try {
+ filteredContent = filteredContent
+ ?.replace(REPORT_REASON_REGEX, '')
+ .replace(', ', '');
+ // .replace(/".*"/, '');
+ } catch (error) {
+ console.log(
+ `[PLATFORMMODERATIONMESSAGE] Something went wrong 4-filtering message ${message._id}: ${error}`,
+ );
+ }
+
+ console.log(filteredContent);
+
+ let reportID: string;
+
+ let reportTarget: string;
+
+ let reportReason: string;
+
+ try {
+ reportID = rawReportID ? rawReportID[0] : 'UNKNOWN';
+ } catch (error) {
+ console.log(
+ `[PLATFORMMODERATIONMESSAGE] Something went wrong getting report ID from message ${message._id}: ${error}`,
+ );
+ reportID = 'UNKNOWN';
+ }
+
+ try {
+ reportTarget = rawReportTarget ? rawReportTarget[0] : 'UNKNOWN';
+ } catch (error) {
+ console.log(
+ `[PLATFORMMODERATIONMESSAGE] Something went wrong getting report target from message ${message._id}: ${error}`,
+ );
+ reportTarget = 'UNKNOWN';
+ }
+
+ try {
+ reportReason = rawReportReason
+ ? rawReportReason[0] ?? 'UNKNOWN'
+ : 'UNKNOWN';
+ } catch (error) {
+ console.log(
+ `[PLATFORMMODERATIONMESSAGE] Something went wrong getting report reason from message ${message._id}: ${error}`,
+ );
+ reportReason = 'UNKNOWN';
+ }
+
+ return (
+
+
+ {isReport ? 'Report update' : isStrike ? 'Strike' : 'Alert'}
+
+ {isReport ? (
+ <>
+
+ {reportID !== 'UNKNOWN'
+ ? `Report ${reportID}`
+ : 'Unknown report ID'}
+ {' | '}
+ {reportTarget !== 'UNKNOWN'
+ ? `${reportTarget}`
+ : 'Unknown subject'}
+ {' | '}
+ {reportReason !== 'UNKNOWN'
+ ? `${reportReason}`
+ : 'Unknown reason'}
+
+ Response
+
+
+
+
+ {responseText}
+
+ >
+ ) : (
+ {message.content}
+ )}
+
+ );
+ },
+);
diff --git a/src/components/common/messaging/index.ts b/src/components/common/messaging/index.ts
index 4c4d183..02d32eb 100644
--- a/src/components/common/messaging/index.ts
+++ b/src/components/common/messaging/index.ts
@@ -2,4 +2,5 @@ export {InviteEmbed} from './InviteEmbed';
export {Message} from './Message';
export {MessageEmbed} from './MessageEmbed';
export {MessageReactions} from './MessageReactions';
+export {PlatformModerationMessage} from './PlatformModerationMessage';
export {ReplyMessage} from './ReplyMessage';