88 lines
3.5 KiB
TypeScript
88 lines
3.5 KiB
TypeScript
// Metro module 7904 (f7905).
|
|
import { MessageAttachmentFlags } from "../../../../Constants";
|
|
import * as _Module1384 from "../../../../_bundle/Module1384";
|
|
import * as _ObscuredMediaUtils from "../../../explicit_media_redaction/ObscuredMediaUtils";
|
|
import { getMediaObscuredReasonFromBitmask } from "../../../explicit_media_redaction/ObscuredMediaUtils";
|
|
import { ObscuredMediaTypes } from "../../../explicit_media_redaction/ExplicitMediaRedactionModels";
|
|
import { isVerifiedTeen } from "../../../age_assurance/AgeVerificationUtils";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
export function getAttachmentObscurityProps({ attachment, shouldObscureSpoiler, enabledContentHarmTypeFlags, shouldAgeVerify }) {
|
|
let flags = attachment.flags;
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
const hasFlag = _Module1384.hasFlag(flags, MessageAttachmentFlags.IS_SPOILER);
|
|
let contentScanVersion = attachment.content_scan_version !== void 0 ? attachment.content_scan_version : attachment.contentScanVersion !== void 0 ? attachment.contentScanVersion : void 0;
|
|
if (contentScanVersion == null) {
|
|
contentScanVersion = 0;
|
|
}
|
|
let flags2 = attachment.flags;
|
|
if (flags2 == null) {
|
|
flags2 = 0;
|
|
}
|
|
const media = {
|
|
contentScanVersion,
|
|
flags: flags2
|
|
};
|
|
const mediaObscuredReasonFromBitmask = getMediaObscuredReasonFromBitmask({
|
|
type: ObscuredMediaTypes.Attachment,
|
|
media
|
|
}, enabledContentHarmTypeFlags);
|
|
const isMediaScanPending = _ObscuredMediaUtils.isMediaScanPending({
|
|
type: ObscuredMediaTypes.Attachment,
|
|
media
|
|
}, enabledContentHarmTypeFlags);
|
|
const obscure = mediaObscuredReasonFromBitmask.length > 0;
|
|
const obscureHideControls = obscure ? isVerifiedTeen() : obscure;
|
|
const isSpoiler = shouldObscureSpoiler && hasFlag;
|
|
let obscureDescription = "";
|
|
const spoiler = shouldObscureSpoiler ? hasFlag ? intl.string(t["F+x38C"]).toUpperCase() : "" : "";
|
|
if (obscure) {
|
|
obscureDescription = intl.string(t.SpxcUR);
|
|
}
|
|
return {
|
|
isSpoiler,
|
|
spoiler,
|
|
obscure,
|
|
obscureDescription,
|
|
obscureAwaitingScan: isMediaScanPending,
|
|
verifyAge: obscure && shouldAgeVerify,
|
|
obscureHideControls,
|
|
obscureIsOpaque: obscure
|
|
};
|
|
}
|
|
export function getUnfurledMediaItemObscurityProps(a0) {
|
|
const { type, mediaItem } = a0;
|
|
let isSpoilered = a0.isSpoilered;
|
|
const { isAuthorBot, shouldObscureSpoiler, enabledContentHarmTypeFlags, shouldAgeVerify } = a0;
|
|
const mediaObscuredReasonFromBitmask = getMediaObscuredReasonFromBitmask({
|
|
type: ObscuredMediaTypes.GenericMedia,
|
|
media: mediaItem
|
|
}, enabledContentHarmTypeFlags);
|
|
const obscureAwaitingScan = isAuthorBot ? !isAuthorBot : _ObscuredMediaUtils.isMediaScanPending({
|
|
type: ObscuredMediaTypes.GenericMedia,
|
|
media: mediaItem
|
|
}, enabledContentHarmTypeFlags);
|
|
if (isSpoilered) {
|
|
isSpoilered = shouldObscureSpoiler;
|
|
}
|
|
const isObscured = mediaObscuredReasonFromBitmask.length > 0;
|
|
const obscureHideControls = isObscured ? isVerifiedTeen() : isObscured;
|
|
return {
|
|
isSpoiler: isSpoilered,
|
|
spoilerDescription: isSpoilered ? type === "image" ? intl.string(t.sb2W2J) : type === "video" ? intl.string(t.ehBaMc) : type === "file" ? intl.string(t["3Gc2XP"]) : type === "generic" ? intl.string(t.G71b77) : void 0 : null,
|
|
isObscured,
|
|
obscureDescription: isObscured ? intl.string(t.SpxcUR) : null,
|
|
obscureAwaitingScan,
|
|
verifyAge: isObscured && shouldAgeVerify,
|
|
obscureHideControls,
|
|
obscureIsOpaque: isObscured
|
|
};
|
|
}
|
|
export function getAttachmentObscurityDefaults() {
|
|
return {
|
|
isSpoiler: false,
|
|
spoiler: ""
|
|
};
|
|
}
|