decord/source/modules/safety_hub/SafetyHubUtils.tsx
2026-08-05 07:35:12 +00:00

172 lines
6.4 KiB
TypeScript

// Module ID: 7699
// Function ID: 7700
// Name: parseMessageEmbedForProps
// Dependencies: [1218, 7700, 676, 3837, 4442, 1236, 7701, 589, 2]
// Exports: capitalizeText, getAppealSignalDisplayText, getClassificationExpiration, getClassificationRelativeIncidentTime, getRequestReviewErrorFromCode, getSpoilerFlagsForAttachment, isCurrentUserSuspended, isFlaggedContentEmpty, isGuildClassification, mapCtaToNativeData, parseMessageForProps, useIsSuspendedUser
// Module 7699 (parseMessageEmbedForProps)
import fetchFingerprint from "fetchFingerprint";
import SafetyHubView from "SafetyHubView";
import ME from "ME";
let c4;
let c5;
let closure_6;
let error;
let metroImportAll;
const require = arg1;
function parseMessageEmbedForProps(fields) {
if (null != fields.fields) {
fields = fields.fields;
const reduced = fields.reduce((arg0, rawName) => {
arg0[rawName.rawName] = rawName.rawValue;
return arg0;
}, {});
let str = reduced[constants3.HEADER];
if (str == null) {
str = "";
}
const obj = { header: null, icon: null, body: null, ctas: null, timestamp: null, theme: null, learn_more_link: null, classification_id: null };
obj[0] = str;
obj[1] = reduced[constants3.ICON_TYPE];
let str2 = reduced[tmp2.BODY];
if (str2 == null) {
str2 = "";
}
obj[2] = str2;
let str3 = reduced[tmp2.CTAS];
if (str3 == null) {
str3 = "";
}
const parts = str3.split(",");
obj[3] = parts.filter((arg0) => "" !== arg0);
let num = reduced[tmp2.TIMESTAMP];
if (num == null) {
num = 0;
}
obj[4] = parseFloat(num);
obj[5] = reduced[constants3.THEME];
obj[6] = reduced[constants3.LEARN_MORE_LINK];
obj[7] = reduced[constants3.CLASSIFICATION_ID];
return obj;
}
}
({ AppealIngestionSignal: c4, SafetySystemNotificationCtaType: c5, SafetySystemNotificationEmbedKeys: closure_6 } = SafetyHubView);
({ AbortCodes: error, MessageAttachmentFlags: metroImportAll } = ME);
const result = require("ME").fileFinishedImporting("modules/safety_hub/SafetyHubUtils.tsx");
export const getClassificationRelativeIncidentTime = function getClassificationRelativeIncidentTime(timestamp) {
return importDefault(3837)().to(importDefault(3837)(timestamp));
};
export const getSpoilerFlagsForAttachment = function getSpoilerFlagsForAttachment(filename) {
if (obj.isImageFile(filename.filename)) {
let num = constants5.IS_SPOILER;
} else {
num = 0;
const tmpResult = require(4442) /* urlMatchesFileExtension */;
}
return num;
};
export const parseMessageForProps = function parseMessageForProps(message) {
return parseMessageEmbedForProps(message.embeds[0]);
};
export { parseMessageEmbedForProps };
export const mapCtaToNativeData = function mapCtaToNativeData(arg0, learn_more_link, classification_id) {
if (constants2.LEARN_MORE_LINK === arg0) {
let str2 = learn_more_link;
let obj = { text: null, type: null, key: null };
const intl2 = require(1236) /* getSystemLocale */.intl;
obj[0] = intl2.string(require(1236) /* getSystemLocale */.t["8/GdRB"]);
obj[1] = tmp.LEARN_MORE_LINK;
if (learn_more_link == null) {
str2 = "";
}
obj[2] = str2;
return obj;
} else if (tmp.POLICY_VIOLATION_DETAIL === arg0) {
let str = classification_id;
obj = { text: null, type: null, key: null };
const intl = require(1236) /* getSystemLocale */.intl;
obj[0] = intl.string(require(1236) /* getSystemLocale */.t.QsqdXC);
obj[1] = tmp.POLICY_VIOLATION_DETAIL;
if (classification_id == null) {
str = "";
}
obj[2] = str;
return obj;
}
};
export const isFlaggedContentEmpty = function isFlaggedContentEmpty(first) {
let tmp = first.type !== require(7701) /* ContentIdType */.ContentIdType.MESSAGE;
if (!tmp) {
let tmp2 = "" === first.content;
if (tmp2) {
tmp2 = 0 === first.attachments.length;
}
tmp = tmp2;
}
return tmp;
};
export const getAppealSignalDisplayText = function getAppealSignalDisplayText(signal) {
const obj = {};
const intl = require(1236) /* getSystemLocale */.intl;
obj[constants.DIDNT_VIOLATE_POLICY] = intl.string(require(1236) /* getSystemLocale */.t.mZffAi);
const intl2 = require(1236) /* getSystemLocale */.intl;
obj[constants.TOO_STRICT_UNFAIR] = intl2.string(require(1236) /* getSystemLocale */.t.wgZVAn);
const intl3 = require(1236) /* getSystemLocale */.intl;
obj[constants.DONT_AGREE_PENALTY] = intl3.string(require(1236) /* getSystemLocale */.t.eu8G4k);
const intl4 = require(1236) /* getSystemLocale */.intl;
obj[constants.SOMETHING_ELSE] = intl4.string(require(1236) /* getSystemLocale */.t.XU3s6r);
return obj[signal];
};
export const capitalizeText = function capitalizeText(description) {
let str = "";
if (null != description) {
str = "";
if (0 !== description.length) {
if (1 === description.length) {
let formatted = description.toUpperCase();
} else {
const formatted1 = description.charAt(0).toUpperCase();
const _HermesInternal = HermesInternal;
formatted = "" + formatted1 + description.slice(1);
const str2 = description.charAt(0);
}
}
}
return str;
};
export const isGuildClassification = function isGuildClassification(stateFromStores) {
return null != stateFromStores && null != stateFromStores.guild_metadata;
};
export const getRequestReviewErrorFromCode = function getRequestReviewErrorFromCode(code) {
if (code === constants4.DSA_APPEAL_REQUEST_DEFLECTION) {
const intl2 = require(1236) /* getSystemLocale */.intl;
let stringResult = intl2.string(require(1236) /* getSystemLocale */.t["0qyXXH"]);
} else {
const intl = require(1236) /* getSystemLocale */.intl;
stringResult = intl.string(require(1236) /* getSystemLocale */.t.aPmsx3);
}
return stringResult;
};
export const getClassificationExpiration = function getClassificationExpiration(classification) {
const max_expiration_time = classification.max_expiration_time;
if (null == max_expiration_time) {
return null;
} else {
try {
const _Date = Date;
const date = new Date(max_expiration_time);
return date;
} catch (err) {
return tmp;
}
}
};
export const useIsSuspendedUser = function useIsSuspendedUser() {
const items = [fetchFingerprint];
return null != require(589) /* initialize */.useStateFromStores(items, () => suspendedUserToken.getSuspendedUserToken());
};
export const isCurrentUserSuspended = function isCurrentUserSuspended() {
return null != suspendedUserToken.getSuspendedUserToken();
};