decord/source/modules/forwarding/ForwardDestinationUtils.tsx

223 lines
8.7 KiB
TypeScript
Raw Normal View History

2026-08-26 06:04:24 +00:00
// Module ID: 7515
// Function ID: 7516
2026-07-29 08:29:29 +00:00
// Name: useSelectedDestinationChannel
2026-08-26 06:04:24 +00:00
// Dependencies: [19, 5391, 1395, 1391, 4089, 4098, 1922, 676, 7516, 1370, 589, 692, 4804, 1955, 4683, 1236, 4802, 7358, 4288, 4638, 2]
2026-07-29 08:29:29 +00:00
// Exports: getDestinationIsUnavailable, isRatelimitedInChannel, useDestinationNamesWithSlowmode, useSelectedDestinationChannel, useSelectedDestinationNames
2026-07-20 16:05:17 +00:00
2026-08-26 06:04:24 +00:00
// Module 7515 (useSelectedDestinationChannel)
import canBypassSlowmodeHelper from "canBypassSlowmodeHelper" /* 7358 */;
2026-08-24 06:08:38 +00:00
import closure_3 from "noop" /* 19 */;
2026-08-26 06:04:24 +00:00
import closure_4 from "loadSavedGuildStickers" /* 5391 */;
2026-08-24 06:08:38 +00:00
import createChannelRecord from "createChannelRecord" /* 1395 */;
import closure_8 from "ensureGuildLoaded" /* 1391 */;
2026-08-26 06:04:24 +00:00
import closure_9 from "getUncachedChannelPermissions" /* 4089 */;
import closure_10 from "markAllUserIdListsStale" /* 4098 */;
2026-08-24 06:08:38 +00:00
import closure_11 from "mergeGuildAvatar" /* 1922 */;
import ME from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-29 08:29:29 +00:00
({ ChannelRecordBase: c5, isGuildChannelType: closure_6, createChannelRecord: error } = createChannelRecord);
({ MessageFlags: closure_12, Permissions: map1 } = ME);
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/forwarding/ForwardDestinationUtils.tsx");
2026-07-20 16:05:17 +00:00
export const useSelectedDestinationChannel = function useSelectedDestinationChannel(selectedDestinations) {
2026-08-26 06:04:24 +00:00
const mapped = selectedDestinations.map(found(7516).getChannelIdFromDestinationId);
2026-08-11 06:20:06 +00:00
found = mapped.find(found(1370).isNotNullish);
2026-08-24 06:08:38 +00:00
const items = [closure_8];
2026-07-20 16:05:17 +00:00
const items1 = [found];
2026-08-24 06:08:38 +00:00
const stateFromStores = found(589).useStateFromStores(items, () => closure_1_8.getChannel(found), items1);
2026-07-20 16:05:17 +00:00
const items2 = [stateFromStores];
return React.useMemo(() => {
2026-07-29 08:29:29 +00:00
let tmp = stateFromStores;
if (stateFromStores == null) {
const obj = { id: "1", type: null };
2026-08-24 06:08:38 +00:00
obj[1] = found(closure_1_2[11]).ChannelTypes.DM;
tmp = closure_1_7(obj);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp;
2026-07-20 16:05:17 +00:00
}, items2);
};
2026-07-29 08:29:29 +00:00
export const getDestinationIsUnavailable = function getDestinationIsUnavailable(components, channel, type) {
2026-07-23 10:11:24 +00:00
const _require = type;
2026-07-20 16:05:17 +00:00
if (null != arg3) {
const tmp2 = arg3(type);
if (null != tmp2) {
return tmp2;
}
}
2026-07-29 08:29:29 +00:00
if (null != components) {
let tmp5 = components.components.length > 0;
if (tmp5) {
2026-08-25 06:04:03 +00:00
tmp5 = components.components[0].type === _require(1955).ComponentType.CHECKPOINT_CARD;
2026-07-29 08:29:29 +00:00
}
let tmp6 = components.messageSnapshots.length > 0;
if (tmp6) {
let message = components.messageSnapshots[0].message;
let tmp7 = message.components.length > 0;
if (tmp7) {
2026-08-25 06:04:03 +00:00
tmp7 = message.components[0].type === _require(1955).ComponentType.CHECKPOINT_CARD;
2026-07-29 08:29:29 +00:00
}
tmp6 = tmp7;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null != channel) {
2026-08-26 06:04:24 +00:00
let obj = _require(4683);
2026-07-29 08:29:29 +00:00
if (obj.isChannelOrGuildNSFW(channel)) {
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-08-26 06:04:24 +00:00
let tmp11Result = tmp11(4683);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { label: null, lineClamp: 2 };
const intl = tmp11(1236).intl;
obj[0] = intl.string(tmp11(1236).t.KgPx1D);
2026-07-20 16:05:17 +00:00
return obj;
}
if (tmp) {
if (callback(type.type)) {
2026-07-29 08:29:29 +00:00
if (components.attachments.length > 0) {
2026-08-24 06:08:38 +00:00
if (!closure_9.can(constants2.ATTACH_FILES, type)) {
2026-07-29 08:29:29 +00:00
obj = { label: null };
const intl2 = tmp11(1236).intl;
obj[0] = intl2.string(tmp11(1236).t.P7yvbm);
2026-07-20 16:05:17 +00:00
return obj;
}
} else {
2026-07-29 08:29:29 +00:00
const messageSnapshots = components.messageSnapshots;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (components.embeds.length > 0) {
2026-08-26 06:04:24 +00:00
tmp11Result = tmp11(4802);
2026-08-24 06:08:38 +00:00
if (!tmp11Result.canEmbedLinks(type, closure_9)) {
2026-07-29 08:29:29 +00:00
if (!tmp11Result1.shouldStripEmbeds(components)) {
2026-08-24 06:08:38 +00:00
obj1 = { label: null };
2026-07-29 08:29:29 +00:00
const intl3 = tmp11(1236).intl;
obj1[0] = intl3.string(tmp11(1236).t.Wr4RIX);
2026-07-20 16:05:17 +00:00
return obj1;
}
2026-08-26 06:04:24 +00:00
tmp11Result1 = tmp11(4802);
2026-07-20 16:05:17 +00:00
}
} else {
2026-07-29 08:29:29 +00:00
const messageSnapshots2 = components.messageSnapshots;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-08-24 06:08:38 +00:00
if (!tmp11Result2.canEmbedLinks(type, closure_9)) {
2026-07-29 08:29:29 +00:00
const obj2 = { label: null };
const intl4 = tmp11(1236).intl;
obj2[0] = intl4.string(tmp11(1236).t.Wr4RIX);
2026-07-20 16:05:17 +00:00
return obj2;
}
2026-08-26 06:04:24 +00:00
tmp11Result2 = tmp11(4802);
2026-07-20 16:05:17 +00:00
}
const items = [];
2026-07-29 08:29:29 +00:00
const messageSnapshots3 = components.messageSnapshots;
2026-08-26 06:04:24 +00:00
let arraySpreadResult = HermesBuiltin.arraySpread(tmp11(4804).getMessageStickers(components), 0);
2026-07-29 08:29:29 +00:00
arraySpreadResult = HermesBuiltin.arraySpread(messageSnapshots3.flatMap((message) => type(table[12]).getMessageStickers(message.message)), arraySpreadResult);
2026-07-20 16:05:17 +00:00
if (items.length > 0) {
2026-08-24 06:08:38 +00:00
if (!closure_9.can(constants2.USE_EXTERNAL_STICKERS, type)) {
2026-07-20 16:05:17 +00:00
if (items.some((id) => {
2026-08-24 06:08:38 +00:00
const stickerById = closure_1_4.getStickerById(id.id);
2026-07-20 16:05:17 +00:00
let isGuildStickerResult = null != stickerById;
if (isGuildStickerResult) {
2026-08-24 06:08:38 +00:00
isGuildStickerResult = type(closure_1_2[12]).isGuildSticker(stickerById);
const obj = type(closure_1_2[12]);
2026-07-20 16:05:17 +00:00
}
if (isGuildStickerResult) {
2026-07-23 10:11:24 +00:00
isGuildStickerResult = stickerById.guild_id !== type.guild_id || undefined;
const tmp6 = stickerById.guild_id !== type.guild_id || undefined;
2026-07-20 16:05:17 +00:00
}
return isGuildStickerResult;
})) {
2026-07-29 08:29:29 +00:00
const obj3 = { label: null };
const intl5 = tmp11(1236).intl;
obj3[0] = intl5.string(tmp11(1236).t["0Yyrua"]);
2026-07-20 16:05:17 +00:00
return obj3;
}
}
}
2026-07-29 08:29:29 +00:00
if (components.hasFlag(constants.IS_VOICE_MESSAGE)) {
2026-08-24 06:08:38 +00:00
if (!closure_9.can(constants2.SEND_VOICE_MESSAGES, type)) {
2026-07-29 08:29:29 +00:00
const obj4 = { label: null };
const intl6 = tmp11(1236).intl;
obj4[0] = intl6.string(tmp11(1236).t.quj4DY);
2026-07-20 16:05:17 +00:00
return obj4;
}
} else {
2026-07-29 08:29:29 +00:00
const messageSnapshots4 = components.messageSnapshots;
2026-07-20 16:05:17 +00:00
}
2026-08-26 06:04:24 +00:00
const tmp11Result3 = tmp11(4804);
2026-07-20 16:05:17 +00:00
}
}
}
}
};
2026-08-24 06:08:38 +00:00
export const isRatelimitedInChannel = function isRatelimitedInChannel(channel, closure_1_6) {
2026-07-29 08:29:29 +00:00
let tmp = null != channel.rateLimitPerUser;
if (tmp) {
tmp = channel.rateLimitPerUser > 0;
}
if (tmp) {
2026-08-24 06:08:38 +00:00
tmp = !canBypassSlowmodeHelper.canBypassSlowmodeHelper(channel, closure_1_6);
const obj = canBypassSlowmodeHelper;
2026-07-29 08:29:29 +00:00
}
return tmp;
};
2026-07-20 16:05:17 +00:00
export const useSelectedDestinationNames = function useSelectedDestinationNames(arg0) {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-08-24 06:08:38 +00:00
const items = [closure_11, closure_8, closure_10];
2026-07-20 16:05:17 +00:00
const items1 = [arg0];
2026-07-29 08:29:29 +00:00
return _require(589).useStateFromStoresArray(items, () => {
2026-07-23 10:11:24 +00:00
const mapped = lib.map((id) => {
2026-07-20 16:05:17 +00:00
id = id.id;
if ("user" === id.type) {
2026-07-29 08:29:29 +00:00
user = user.getUser(id);
2026-07-20 16:05:17 +00:00
let tmp13 = null;
if (null != user) {
2026-07-29 08:29:29 +00:00
nickname = nickname.getNickname(user.id);
if (nickname == null) {
2026-08-26 06:04:24 +00:00
nickname = callback2(4288).getName(user);
const obj2 = callback2(4288);
2026-07-20 16:05:17 +00:00
}
tmp13 = nickname;
}
return tmp13;
} else {
2026-07-29 08:29:29 +00:00
channel = channel.getChannel(id);
2026-07-20 16:05:17 +00:00
let channelName = null;
if (null != channel) {
2026-08-26 06:04:24 +00:00
const obj = callback(4638);
2026-07-29 08:29:29 +00:00
channelName = obj.computeChannelName(channel, user, nickname, true);
2026-07-20 16:05:17 +00:00
}
return channelName;
}
});
2026-08-24 06:08:38 +00:00
return mapped.filter(lib(closure_1_2[9]).isNotNullish);
2026-07-20 16:05:17 +00:00
}, items1);
};
export const useDestinationNamesWithSlowmode = function useDestinationNamesWithSlowmode(selectedDestinations) {
2026-07-23 10:11:24 +00:00
const _require = selectedDestinations;
2026-08-24 06:08:38 +00:00
const items = [closure_8, closure_9];
2026-07-20 16:05:17 +00:00
const items1 = [selectedDestinations];
2026-07-29 08:29:29 +00:00
const stateFromStoresArray = _require(589).useStateFromStoresArray(items, () => {
2026-07-23 10:11:24 +00:00
const mapped = selectedDestinations.map((type) => {
2026-07-20 16:05:17 +00:00
let channel = null;
if ("channel" === type.type) {
2026-07-29 08:29:29 +00:00
channel = channel.getChannel(tmp);
2026-07-20 16:05:17 +00:00
}
return channel;
});
2026-08-24 06:08:38 +00:00
const found = mapped.filter(selectedDestinations(closure_1_2[9]).isNotNullish);
2026-07-29 08:29:29 +00:00
return found.filter((rateLimitPerUser) => {
let tmp2 = null != rateLimitPerUser.rateLimitPerUser;
if (tmp2) {
tmp2 = rateLimitPerUser.rateLimitPerUser > 0;
}
if (tmp2) {
2026-08-24 06:08:38 +00:00
tmp2 = !callback(table[17]).canBypassSlowmodeHelper(rateLimitPerUser, closure_9);
2026-07-29 08:29:29 +00:00
const obj = callback(table[17]);
}
return tmp2;
});
2026-07-20 16:05:17 +00:00
}, items1);
2026-07-29 08:29:29 +00:00
let obj = _require(589);
2026-08-24 06:08:38 +00:00
const items2 = [closure_11, closure_10];
2026-07-20 16:05:17 +00:00
const items3 = [stateFromStoresArray];
2026-08-24 06:08:38 +00:00
return _require(589).useStateFromStoresArray(items2, () => stateFromStoresArray.map((channel) => callback(table[19]).computeChannelName(channel, closure_11, closure_10, true)), items3);
2026-07-20 16:05:17 +00:00
};