255 lines
11 KiB
TypeScript
255 lines
11 KiB
TypeScript
// Metro module 5862 (f5863).
|
|
import DevSettingsStore from "../devtools/dev_settings/DevSettingsStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import ExplicitMediaStore from "./ExplicitMediaStore";
|
|
import { EXPLICIT_MEDIA_MIN_HEIGHT, EXPLICIT_MEDIA_MIN_WIDTH } from "./ExplicitMediaRedactionConstants";
|
|
import { AnalyticEvents } from "../../Constants";
|
|
import { ExplicitContentRedaction } from "../../_bundle/Module1306";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import AnalyticsUtils from "../../utils/AnalyticsUtils";
|
|
import { isCurrentUserTeen } from "../self_mod/SelfModUtils";
|
|
import MonitoringAgent from "../monitoring/MonitoringAgent";
|
|
import { MetricEvents } from "../../_bundle/Module5872";
|
|
import { MESSAGE_SCAN_TIMEOUT } from "./ExplicitMediaManager";
|
|
import { isFeatureAgeGated, useIsFeatureAgeGated } from "../regional_feature_config/RegionalFeatureConfigUtils";
|
|
import { AgeGatedFeature } from "../../_bundle/Module5013";
|
|
import * as _AgeVerificationUtils from "../age_assurance/AgeVerificationUtils";
|
|
import { useShouldShowTiggerPawtect, isVerifiedAdult } from "../age_assurance/AgeVerificationUtils";
|
|
import { AGE_VERIFICATION_OBSCURABLE_REASONS } from "./ObscureMediaModels";
|
|
function $mk77251() {
|
|
return (a0) => {
|
|
a0.content_scan_version = -1;
|
|
return a0;
|
|
};
|
|
}
|
|
function $mk77252() {
|
|
return (a0) => {
|
|
a0.contentScanVersion = -1;
|
|
return a0;
|
|
};
|
|
}
|
|
const r25 = {
|
|
EXPLICIT_MEDIA_LEARN_MORE_VIEWED: "explicit_media_learn_more_viewed",
|
|
EXPLICIT_MEDIA_LEARN_MORE_CLICK_SETTINGS: "explicit_media_learn_more_click_settings",
|
|
EXPLICIT_MEDIA_LEARN_MORE_CLICK_LEARN_MORE: "explicit_media_learn_more_click_learn_more",
|
|
EXPLICIT_MEDIA_LEARN_MORE_CLICK_DISMISS: "explicit_media_learn_more_click_dismiss",
|
|
EXPLICIT_MEDIA_LEARN_MORE_CLICK_FALSE_POSITIVE: "explicit_media_learn_more_click_false_positive",
|
|
EXPLICIT_MEDIA_LEARN_MORE_CLICK_AGE_VERIFY_REVERIFY: "explicit_media_learn_more_click_age_verify_reverify",
|
|
EXPLICIT_MEDIA_LEARN_MORE_CLICK_AGE_VERIFY_LEARN_MORE: "explicit_media_learn_more_click_age_verify_learn_more",
|
|
EXPLICIT_MEDIA_FALSE_POSITIVE_VIEWED: "explicit_media_false_positive_viewed",
|
|
EXPLICIT_MEDIA_FALSE_POSITIVE_CLICK_CONFIRM: "explicit_media_false_positive_click_confirm",
|
|
EXPLICIT_MEDIA_FALSE_POSITIVE_CLICK_CANCEL: "explicit_media_false_positive_click_cancel",
|
|
EXPLICIT_MEDIA_SENDER_FALSE_POSITIVE_BUTTON_CLICKED: "explicit_media_sender_false_positive_button_clicked",
|
|
EXPLICIT_MEDIA_FALSE_POSITIVE_CLYDE_MESSAGE_SENT: "explicit_media_false_positive_clyde_message_sent"
|
|
};
|
|
const r38 = {
|
|
EXPLICIT_MEDIA_OBSCURED_FALSE_POSITIVE_FLOW: "explicit_media_obscured_false_positive_flow",
|
|
EXPLICIT_MEDIA_SENDER_FALSE_POSITIVE_FLOW: "explicit_media_sender_false_positive_flow",
|
|
EXPLICIT_MEDIA_MESSAGE_SEND_BLOCKED: "explicit_media_message_send_blocked",
|
|
EXPLICIT_MEDIA_ADD_MEDIA_TO_FORUM_POST_BLOCKED: "explicit_media_add_media_to_forum_post_blocked"
|
|
};
|
|
const r43 = {
|
|
UPDATE: "update",
|
|
TIMEOUT: "timeout"
|
|
};
|
|
export function redactionSettingToRenderedString(a0) {
|
|
if (ExplicitContentRedaction.SHOW === a0) {
|
|
return () => intl.string(t["5k5OFp"]);
|
|
}
|
|
if (ExplicitContentRedaction.BLUR === a0) {
|
|
return () => intl.string(t.S49Uad);
|
|
}
|
|
if (ExplicitContentRedaction.BLOCK === a0) {
|
|
return () => intl.string(t["D/157Y"]);
|
|
}
|
|
}
|
|
export function isPendingScanVersion(a0) {
|
|
const r9 = DevSettingsStore.get("explicit_media_redaction_ignore_pending_scan");
|
|
return r9 ? !r9 : a0 !== 0 && a0 !== -1 && (a0 == null || a0 !== ExplicitMediaStore.validContentScanVersion);
|
|
}
|
|
export { r25 as TrackMediaRedactionActionType };
|
|
export { r38 as TrackMediaRedactionContext };
|
|
export function trackMediaRedactionAction({ action, channelId, messageId, context }) {
|
|
if (channelId != null && messageId != null) {
|
|
AnalyticsUtils.track(AnalyticEvents.EXPLICIT_MEDIA_ACTION, {
|
|
action,
|
|
guild_id: ChannelStore.getChannel(channelId)?.guild_id,
|
|
channel_id: channelId,
|
|
message_id: messageId,
|
|
user_is_underage: isCurrentUserTeen(),
|
|
context
|
|
});
|
|
}
|
|
}
|
|
export { r43 as TimeoutCancelSource };
|
|
export function trackScanTiming(a0, a1) {
|
|
MonitoringAgent.increment({
|
|
name: MetricEvents.EXPLICIT_MEDIA_SCAN_CLIENT_TIMING,
|
|
tags: [`timingBucket:${Math.min(Math.floor((Date.now() - a0) / 1000), 3)}`, `source:${a1}`, "metricVersion:1"]
|
|
});
|
|
}
|
|
export function trackScanningTimedOut(a0) {
|
|
L23: {
|
|
const { channelId, messageId, attachmentIds, embedIds } = a0;
|
|
if (channelId != null && messageId != null) {
|
|
let r16 = attachmentIds?.length;
|
|
if (r16 == null) {
|
|
r16 = 0;
|
|
}
|
|
if (r16 === 0) {
|
|
let r18 = embedIds?.length;
|
|
if (r18 == null) {
|
|
r18 = 0;
|
|
}
|
|
if (r18 === 0) {
|
|
break L23;
|
|
}
|
|
}
|
|
AnalyticsUtils.track(AnalyticEvents.EXPLICIT_MEDIA_SCAN_CLIENT_TIMED_OUT, {
|
|
channel_id: channelId,
|
|
guild_id: ChannelStore.getChannel(channelId)?.guild_id,
|
|
message_id: messageId,
|
|
embed_ids: embedIds,
|
|
user_is_underage: isCurrentUserTeen(),
|
|
scan_timeout_duration: MESSAGE_SCAN_TIMEOUT,
|
|
attachment_ids_v2: attachmentIds
|
|
});
|
|
MonitoringAgent.increment({
|
|
name: MetricEvents.EXPLICIT_MEDIA_SCAN_CLIENT_TIMED_OUT,
|
|
tags: ["metricVersion:1"]
|
|
});
|
|
const r52 = {
|
|
name: MetricEvents.EXPLICIT_MEDIA_SCAN_CLIENT_TIMED_OUT_DISTRIBUTION
|
|
};
|
|
let r54 = attachmentIds?.length;
|
|
if (r54 == null) {
|
|
r54 = 0;
|
|
}
|
|
let r56 = embedIds?.length;
|
|
if (r56 == null) {
|
|
r56 = 0;
|
|
}
|
|
MonitoringAgent.distribution(r52, r54 + r56);
|
|
}
|
|
}
|
|
}
|
|
export function trackExplicitMediaRedactableMessagedLoaded({ channelId, numOfAttachments, numOfAttachmentsPendingScan, numOfEmbeds, numOfEmbedsPendingScan }) {
|
|
if (channelId != null) {
|
|
AnalyticsUtils.track(AnalyticEvents.EXPLICIT_MEDIA_REDACTABLE_MESSAGES_LOADED, {
|
|
channel_id: channelId,
|
|
guild_id: ChannelStore.getChannel(channelId)?.guild_id,
|
|
num_of_attachments: numOfAttachments,
|
|
num_of_attachments_pending_scan: numOfAttachmentsPendingScan,
|
|
num_of_embeds: numOfEmbeds,
|
|
num_of_embeds_pending_scan: numOfEmbedsPendingScan
|
|
});
|
|
const r24 = numOfAttachmentsPendingScan + numOfEmbedsPendingScan;
|
|
if (r24 > 0) {
|
|
MonitoringAgent.distribution({
|
|
name: MetricEvents.EXPLICIT_MEDIA_PENDING_MESSAGE_LOADED_V2
|
|
}, r24);
|
|
}
|
|
}
|
|
}
|
|
export function trackRedactableMessageLoaded({ messageId, channelId, numOfAttachments, numOfSelfHarmAttachments, numOfEmbeds, numOfGoreAttachments, numOfExplicitAttachments, numOfSelfHarmEmbeds, numOfGoreEmbeds, numOfExplicitEmbeds }) {
|
|
const has_redactable_explicit = numOfExplicitAttachments > 0 || numOfExplicitEmbeds > 0;
|
|
const has_redactable_gore = numOfGoreAttachments > 0 || numOfGoreEmbeds > 0;
|
|
const has_redactable_self_harm = numOfSelfHarmAttachments > 0 || numOfSelfHarmEmbeds > 0;
|
|
L16: {
|
|
if (channelId != null && messageId != null) {
|
|
if (!has_redactable_explicit && !has_redactable_gore && !has_redactable_self_harm) {
|
|
break L16;
|
|
}
|
|
const channel = ChannelStore.getChannel(channelId);
|
|
AnalyticsUtils.track(AnalyticEvents.REDACTABLE_MESSAGE_LOADED, {
|
|
message_id: messageId,
|
|
channel_id: channelId,
|
|
channel_type: channel?.type,
|
|
guild_id: channel?.guild_id,
|
|
num_of_attachments: numOfAttachments,
|
|
num_of_gore_attachments: numOfGoreAttachments,
|
|
num_of_explicit_attachments: numOfExplicitAttachments,
|
|
num_of_self_harm_attachments: numOfSelfHarmAttachments,
|
|
num_of_embeds: numOfEmbeds,
|
|
num_of_gore_embeds: numOfGoreEmbeds,
|
|
num_of_explicit_embeds: numOfExplicitEmbeds,
|
|
num_of_self_harm_embeds: numOfSelfHarmEmbeds,
|
|
has_redactable_explicit,
|
|
has_redactable_gore,
|
|
has_redactable_self_harm
|
|
});
|
|
}
|
|
}
|
|
}
|
|
export function trackExplicitMediaScanComplete({ messageId, channelId, numOfAttachments, numOfExplicitAttachments, numOfEmbeds, numOfExplicitEmbeds }) {
|
|
if (channelId != null) {
|
|
const channel = ChannelStore.getChannel(channelId);
|
|
AnalyticsUtils.track(AnalyticEvents.EXPLICIT_MEDIA_RETROACTIVE_SCAN_COMPLETE, {
|
|
message_id: messageId,
|
|
channel_id: channelId,
|
|
channel_type: channel?.type,
|
|
guild_id: channel?.guild_id,
|
|
num_of_attachments: numOfAttachments,
|
|
num_of_explicit_attachments: numOfExplicitAttachments,
|
|
num_of_embeds: numOfEmbeds,
|
|
num_of_explicit_embeds: numOfExplicitEmbeds
|
|
});
|
|
}
|
|
}
|
|
export function handleExplicitMediaScanTimeoutForMessage(a0) {
|
|
const attachments = a0.attachments.map($mk77251());
|
|
const embeds = a0.embeds.map($mk77252());
|
|
const messageSnapshots = a0.messageSnapshots;
|
|
return a0.merge({
|
|
attachments,
|
|
embeds,
|
|
messageSnapshots: messageSnapshots != null ? messageSnapshots.length !== 0 ? messageSnapshots.map((messageSnapshot) => {
|
|
const message = messageSnapshot.message;
|
|
return messageSnapshot.merge({
|
|
message: message.merge({
|
|
attachments: message.attachments.map($mk77251()),
|
|
embeds: message.embeds.map($mk77252())
|
|
})
|
|
});
|
|
}) : messageSnapshots : messageSnapshots
|
|
});
|
|
}
|
|
export function isObscuredMediaBelowConstraints(a0, a1) {
|
|
return a0 != null && a1 != null && (a0 <= EXPLICIT_MEDIA_MIN_WIDTH || a1 <= EXPLICIT_MEDIA_MIN_HEIGHT);
|
|
}
|
|
export function shouldAgeVerifyForExplicitMedia() {
|
|
let r11 = isFeatureAgeGated(AgeGatedFeature.SENSITIVE_CONTENT_SHOW_SETTING);
|
|
const shouldShowTiggerPawtect = _AgeVerificationUtils.shouldShowTiggerPawtect();
|
|
if (r11) {
|
|
r11 = shouldShowTiggerPawtect;
|
|
}
|
|
return r11;
|
|
}
|
|
export function useShouldAgeVerifyForExplicitMedia() {
|
|
let r11 = useIsFeatureAgeGated(AgeGatedFeature.SENSITIVE_CONTENT_SHOW_SETTING);
|
|
const shouldShowTiggerPawtect = useShouldShowTiggerPawtect();
|
|
if (r11) {
|
|
r11 = shouldShowTiggerPawtect;
|
|
}
|
|
return r11;
|
|
}
|
|
export function useShouldAgeVerifyForReason(a0) {
|
|
let r13 = useIsFeatureAgeGated(AgeGatedFeature.SENSITIVE_CONTENT_SHOW_SETTING);
|
|
const shouldShowTiggerPawtect = useShouldShowTiggerPawtect();
|
|
if (r13) {
|
|
r13 = shouldShowTiggerPawtect;
|
|
}
|
|
const r0 = r13 ? a0 == null : !r13;
|
|
return r0 ? !r0 : AGE_VERIFICATION_OBSCURABLE_REASONS.has(a0);
|
|
}
|
|
export function trackToggleMediaObscurityV2({ obscure }) {
|
|
if (isVerifiedAdult()) {
|
|
AnalyticsUtils.track(AnalyticEvents.EXPLICIT_MEDIA_OBSCURITY_TOGGLE_V2, {
|
|
toggle_direction: obscure ? "hide" : "show"
|
|
});
|
|
}
|
|
}
|
|
export function hasMessageSnapshotsWithAttachmentsOrEmbeds({ message_snapshots }) {
|
|
return message_snapshots == null ? void 0 : message_snapshots.some((message_snapshot) => message_snapshot.message?.attachments != null && message_snapshot.message.attachments.length > 0 || message_snapshot.message?.embeds != null && message_snapshot.message.embeds.length > 0);
|
|
}
|