126 lines
4.3 KiB
TypeScript
126 lines
4.3 KiB
TypeScript
// Metro module 6755 (f6756).
|
|
import AuthenticationStore from "../../stores/AuthenticationStore";
|
|
import { AppealIngestionSignal, SafetySystemNotificationCtaType, SafetySystemNotificationEmbedKeys } from "./SafetyHubConstants";
|
|
import { AbortCodes, MessageAttachmentFlags } from "../../Constants";
|
|
import Module3771 from "../../_bundle/Module3771";
|
|
import { isImageFile, isVideoFile } from "../messages/MediaFormatTesters";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import { ContentIdType } from "./SafetyHubModels";
|
|
import { useStateFromStores } from "../../_bundle/Module589";
|
|
const parseMessageEmbedForProps = function parseMessageEmbedForProps(a0) {
|
|
if (a0.fields != null) {
|
|
const r12 = a0.fields.reduce((acc, field) => {
|
|
acc[field.rawName] = field.rawValue;
|
|
return acc;
|
|
}, {});
|
|
let header = r12[SafetySystemNotificationEmbedKeys.HEADER];
|
|
if (header == null) {
|
|
header = "";
|
|
}
|
|
let body = r12[SafetySystemNotificationEmbedKeys.BODY];
|
|
if (body == null) {
|
|
body = "";
|
|
}
|
|
let r8 = r12[SafetySystemNotificationEmbedKeys.CTAS];
|
|
if (r8 == null) {
|
|
r8 = "";
|
|
}
|
|
const r16 = {
|
|
header,
|
|
icon: r12[SafetySystemNotificationEmbedKeys.ICON_TYPE],
|
|
body,
|
|
ctas: r8.split(",").filter((item) => item !== ""),
|
|
timestamp: null,
|
|
theme: null,
|
|
learn_more_link: null,
|
|
classification_id: null
|
|
};
|
|
const r29 = parseFloat;
|
|
let r31 = r12[SafetySystemNotificationEmbedKeys.TIMESTAMP];
|
|
if (r31 == null) {
|
|
r31 = 0;
|
|
}
|
|
r16.timestamp = r29(r31);
|
|
r16.theme = r12[SafetySystemNotificationEmbedKeys.THEME];
|
|
r16.learn_more_link = r12[SafetySystemNotificationEmbedKeys.LEARN_MORE_LINK];
|
|
r16.classification_id = r12[SafetySystemNotificationEmbedKeys.CLASSIFICATION_ID];
|
|
return r16;
|
|
}
|
|
};
|
|
export function getClassificationRelativeIncidentTime(a0) {
|
|
return Module3771().to(Module3771(a0));
|
|
}
|
|
export function getSpoilerFlagsForAttachment(a0) {
|
|
return isImageFile(a0.filename) ? MessageAttachmentFlags.IS_SPOILER : isVideoFile(a0.filename) ? MessageAttachmentFlags.IS_SPOILER : 0;
|
|
}
|
|
export function parseMessageForProps(a0) {
|
|
return parseMessageEmbedForProps(a0.embeds[0]);
|
|
}
|
|
export { parseMessageEmbedForProps };
|
|
export function mapCtaToNativeData(a0, a1, a2) {
|
|
if (SafetySystemNotificationCtaType.LEARN_MORE_LINK === a0) {
|
|
let key2 = a1;
|
|
const r36 = {
|
|
text: intl.string(t["8/GdRB"]),
|
|
type: SafetySystemNotificationCtaType.LEARN_MORE_LINK,
|
|
key: null
|
|
};
|
|
if (a1 == null) {
|
|
key2 = "";
|
|
}
|
|
r36.key = key2;
|
|
return r36;
|
|
}
|
|
if (SafetySystemNotificationCtaType.POLICY_VIOLATION_DETAIL === a0) {
|
|
let key = a2;
|
|
const r19 = {
|
|
text: intl.string(t.QsqdXC),
|
|
type: SafetySystemNotificationCtaType.POLICY_VIOLATION_DETAIL,
|
|
key: null
|
|
};
|
|
if (a2 == null) {
|
|
key = "";
|
|
}
|
|
r19.key = key;
|
|
return r19;
|
|
}
|
|
}
|
|
export function isFlaggedContentEmpty(a0) {
|
|
return a0.type !== ContentIdType.MESSAGE || a0.content === "" && a0.attachments.length === 0;
|
|
}
|
|
export function getAppealSignalDisplayText(a0) {
|
|
const r2 = {};
|
|
r2[AppealIngestionSignal.DIDNT_VIOLATE_POLICY] = intl.string(t.mZffAi);
|
|
r2[AppealIngestionSignal.TOO_STRICT_UNFAIR] = intl.string(t.wgZVAn);
|
|
r2[AppealIngestionSignal.DONT_AGREE_PENALTY] = intl.string(t.eu8G4k);
|
|
r2[AppealIngestionSignal.SOMETHING_ELSE] = intl.string(t.XU3s6r);
|
|
return r2[a0];
|
|
}
|
|
export function capitalizeText(a0) {
|
|
return a0 == null ? "" : a0.length !== 0 ? a0.length === 1 ? a0.toUpperCase() : `${a0.charAt(0).toUpperCase()}${a0.slice(1)}` : "";
|
|
}
|
|
export function isGuildClassification(a0) {
|
|
return a0 != null && a0.guild_metadata != null;
|
|
}
|
|
export function getRequestReviewErrorFromCode(a0) {
|
|
return a0 === AbortCodes.DSA_APPEAL_REQUEST_DEFLECTION ? intl.string(t["0qyXXH"]) : intl.string(t.aPmsx3);
|
|
}
|
|
export function getClassificationExpiration({ max_expiration_time }) {
|
|
let date;
|
|
if (max_expiration_time == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
date = new Date(max_expiration_time);
|
|
} catch ($e) {
|
|
return null;
|
|
}
|
|
return date;
|
|
}
|
|
export function useIsSuspendedUser() {
|
|
return useStateFromStores([AuthenticationStore], () => AuthenticationStore.getSuspendedUserToken()) != null;
|
|
}
|
|
export function isCurrentUserSuspended() {
|
|
return AuthenticationStore.getSuspendedUserToken() != null;
|
|
}
|