717 lines
22 KiB
TypeScript
717 lines
22 KiB
TypeScript
// Metro module 6167 (f6168).
|
|
import { isPrivate } from "../../records/ChannelRecord";
|
|
import UserRecord from "../../records/UserRecord";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import GuildMemberStore from "../../stores/GuildMemberStore";
|
|
import RelationshipStore from "../../stores/RelationshipStore";
|
|
import UserStore from "../../stores/UserStore";
|
|
import { UserFlags } from "../../Constants";
|
|
import UserUtils from "../../utils/UserUtils";
|
|
import { hasFlag } from "../../_bundle/Module1384";
|
|
import { v4 } from "../../_bundle/Module514";
|
|
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
|
|
import * as _UserSearch_worker from "./native/UserSearch.worker";
|
|
import { isNotNullish } from "../../utils/GlobalUtils";
|
|
import SentryUtils_native from "../../utils/SentryUtils.native";
|
|
import Module12 from "../../_bundle/Module12";
|
|
import SnowflakeUtils from "../../utils/SnowflakeUtils";
|
|
function $mk77900($env) {
|
|
return (a0) => {
|
|
const r2 = $env;
|
|
const r3 = $env.$parent;
|
|
const r9 = (0, r3[12])(r3[9].getUser(a0));
|
|
const r10 = r2[0];
|
|
if (r10 != null) {
|
|
const id2 = r10.id;
|
|
if (r9 != null) {
|
|
r9.nicknames[id2] = null;
|
|
}
|
|
}
|
|
r2[1].push(r9);
|
|
};
|
|
}
|
|
function $mk77901($env) {
|
|
return (a0) => {
|
|
const r11 = (0, $env.$parent[12])(a0.user);
|
|
if (r11 != null) {
|
|
const r12 = $env;
|
|
const r7 = r12[0];
|
|
const nick = a0.nick;
|
|
if (r11 != null) {
|
|
r11.nicknames[r7] = nick != null ? nick !== "" ? nick : null : null;
|
|
}
|
|
r12[1].push(r11);
|
|
}
|
|
};
|
|
}
|
|
function $mk77903($env) {
|
|
return ({ data }) => {
|
|
let r0 = data != null && data.type === $env.$parent[11].USER_RESULTS;
|
|
const r10 = $env;
|
|
if (r0) {
|
|
r0 = data.uuid === r10[0]._uuid;
|
|
}
|
|
if (r0) {
|
|
const r13 = r10[0];
|
|
if (r13._currentQuery !== false) {
|
|
r13._callback(data.payload);
|
|
}
|
|
if (r13._currentQuery != null) {
|
|
r13._currentQuery = null;
|
|
}
|
|
r13._setNextQuery();
|
|
}
|
|
};
|
|
}
|
|
let setNick, getDMUpdates, updateMembersList, getUsersFromMessage, c3907_11, c3907_18;
|
|
let env3907 = {};
|
|
const getTransformedUser = function getTransformedUser(a0) {
|
|
let isProvisional, isStaff;
|
|
if (a0 != null) {
|
|
if (!RelationshipStore.isBlockedOrIgnored(a0.id)) {
|
|
const r17 = {
|
|
id: a0.id,
|
|
username: a0.discriminator !== "0" ? `${a0.username}#${a0.discriminator}` : a0.username,
|
|
nicknames: {}
|
|
};
|
|
if (UserUtils.getGlobalName(a0) != null) {
|
|
r17.globalName = a0.globalName;
|
|
}
|
|
if (a0.bot) {
|
|
r17.isBot = true;
|
|
}
|
|
if (a0 instanceof UserRecord) {
|
|
isProvisional = a0.isProvisional;
|
|
} else {
|
|
isProvisional = "flags" in a0;
|
|
if (isProvisional) {
|
|
let flags = a0.flags;
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
isProvisional = hasFlag(flags, UserFlags.PROVISIONAL_ACCOUNT);
|
|
}
|
|
}
|
|
r17.isProvisional = isProvisional;
|
|
if (RelationshipStore.isFriend(a0.id)) {
|
|
r17.isFriend = true;
|
|
r17.friendNickname = RelationshipStore.getNickname(a0.id);
|
|
}
|
|
if (a0 instanceof UserRecord) {
|
|
isStaff = a0.isStaff();
|
|
} else {
|
|
isStaff = "flags" in a0;
|
|
if (isStaff) {
|
|
let flags2 = a0.flags;
|
|
if (flags2 == null) {
|
|
flags2 = 0;
|
|
}
|
|
isStaff = hasFlag(flags2, UserFlags.STAFF);
|
|
}
|
|
}
|
|
r17.isStaff = isStaff;
|
|
return r17;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
setNick = function setNick(a0, a1, a2) {
|
|
if (a0 != null) {
|
|
a0.nicknames[a1] = a2 != null ? a2 !== "" ? a2 : null : null;
|
|
}
|
|
};
|
|
getDMUpdates = function getDMUpdates(a0) {
|
|
let env15550;
|
|
const r2 = env15550 = {
|
|
$parent: env3907
|
|
};
|
|
env15550[0] = a0;
|
|
const r1 = [];
|
|
env15550[1] = r1;
|
|
if (a0 != null && (0, isPrivate)(a0.type)) {
|
|
let recipients = a0.recipients;
|
|
if (recipients === void 0) {
|
|
recipients = [];
|
|
}
|
|
recipients.forEach($mk77900(r2));
|
|
return r1;
|
|
}
|
|
return r1;
|
|
};
|
|
updateMembersList = function updateMembersList(a0, a1) {
|
|
let env15551;
|
|
const r1 = env15551 = {
|
|
$parent: env3907
|
|
};
|
|
env15551[0] = a1;
|
|
const r4 = [];
|
|
env15551[1] = r4;
|
|
a0.forEach($mk77901(r1));
|
|
return r4;
|
|
};
|
|
getUsersFromMessage = function getUsersFromMessage(a0) {
|
|
const message = a0.message;
|
|
let nicknameContextId = a0.nicknameContextId;
|
|
const channel = ChannelStore.getChannel(message.channel_id);
|
|
if (nicknameContextId == null) {
|
|
nicknameContextId = (channel == null ? void 0 : channel.isPrivate()) === true ? channel?.id : channel == null ? void 0 : channel.getGuildId();
|
|
}
|
|
const id = nicknameContextId;
|
|
const r21 = [];
|
|
let c15552_1 = r21;
|
|
if (message.author != null) {
|
|
const transformedUser = getTransformedUser(message.author);
|
|
if (transformedUser != null) {
|
|
r21.push(transformedUser);
|
|
if (id != null && transformedUser != null) {
|
|
transformedUser.nicknames[id] = null;
|
|
}
|
|
}
|
|
}
|
|
const mentions = message.mentions;
|
|
if (mentions != null) {
|
|
mentions.forEach((mention) => {
|
|
const transformedUser = getTransformedUser(mention);
|
|
if (transformedUser != null) {
|
|
c15552_1.push(transformedUser);
|
|
if (id != null && transformedUser != null) {
|
|
transformedUser.nicknames[id] = null;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return r21;
|
|
};
|
|
c3907_11 = {
|
|
UPDATE_USERS: "UPDATE_USERS",
|
|
USER_RESULTS: "USER_RESULTS",
|
|
QUERY_SET: "QUERY_SET",
|
|
QUERY_CLEAR: "QUERY_CLEAR",
|
|
REQUEST_DEBUG_STATE: "REQUEST_DEBUG_STATE",
|
|
DEBUG_STATE: "DEBUG_STATE"
|
|
};
|
|
export class UserSearchContext {
|
|
constructor(a0, a1, _limit = 10) {
|
|
let env15553;
|
|
const r7 = env15553 = {
|
|
$parent: env3907
|
|
};
|
|
env15553[0] = this;
|
|
this.handleMessages = $mk77903(r7);
|
|
this._worker = a0;
|
|
this._uuid = v4();
|
|
this._callback = a1;
|
|
this._limit = _limit;
|
|
this._currentQuery = null;
|
|
this._nextQuery = null;
|
|
this._subscribed = false;
|
|
this.subscribe();
|
|
}
|
|
setLimit(a0) {
|
|
this._limit = a0;
|
|
if (this._nextQuery != null) {
|
|
this._nextQuery.limit = a0;
|
|
}
|
|
}
|
|
subscribe() {
|
|
if (!(this._worker == null || this._subscribed)) {
|
|
this._worker.addEventListener("message", this.handleMessages, false);
|
|
this._subscribed = true;
|
|
this._setNextQuery();
|
|
}
|
|
}
|
|
unsubscribe() {
|
|
if (this._worker != null && this._subscribed) {
|
|
this._worker.removeEventListener("message", this.handleMessages, false);
|
|
this._subscribed = false;
|
|
}
|
|
}
|
|
destroy() {
|
|
this.clearQuery();
|
|
this.unsubscribe();
|
|
}
|
|
clearQuery() {
|
|
this._currentQuery = false;
|
|
this._nextQuery = null;
|
|
if (this._worker != null && this._subscribed) {
|
|
this._worker.postMessage({
|
|
uuid: this._uuid,
|
|
type: c3907_11.QUERY_CLEAR
|
|
});
|
|
}
|
|
}
|
|
setQuery(a0) {
|
|
const { query, filters, blacklist } = a0;
|
|
let boosters = a0.boosters;
|
|
let boosterFallback = a0.boosterFallback;
|
|
if (boosters == null) {
|
|
boosters = {};
|
|
}
|
|
if (boosterFallback == null) {
|
|
boosterFallback = 1;
|
|
}
|
|
this._nextQuery = {
|
|
query,
|
|
filters,
|
|
blacklist,
|
|
boosters,
|
|
boosterFallback,
|
|
limit: this._limit
|
|
};
|
|
this._setNextQuery();
|
|
}
|
|
_setNextQuery() {
|
|
const r0 = this._currentQuery != null && this._currentQuery !== false || this._nextQuery == null;
|
|
L10: {
|
|
if (!r0) {
|
|
if (this._worker != null && this._subscribed) {
|
|
this._currentQuery = this._nextQuery;
|
|
this._nextQuery = null;
|
|
this._worker.postMessage({
|
|
uuid: this._uuid,
|
|
type: c3907_11.QUERY_SET,
|
|
payload: this._currentQuery
|
|
});
|
|
break L10;
|
|
}
|
|
if (!this._subscribed) {
|
|
this.subscribe();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
class UserSearchManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
LOGOUT: () => this._handleLogout(),
|
|
POST_CONNECTION_OPEN: () => this._handleConnectionOpen(),
|
|
CONNECTION_OPEN_SUPPLEMENTAL: (a0) => this._handleConnectionOpenSupplemental(a0),
|
|
OVERLAY_INITIALIZE: (a0) => this._handleOverlayInitialize(a0),
|
|
CURRENT_USER_UPDATE: (a0) => this._handleCurrentUserUpdate(a0),
|
|
GUILD_CREATE: (a0) => this._handleGuildCreate(a0),
|
|
GUILD_MEMBERS_CHUNK_BATCH: (a0) => this._handleGuildMembersChunkBatch(a0),
|
|
GUILD_MEMBER_ADD: (a0) => this._handleGuildMemberUpdate(a0),
|
|
GUILD_MEMBER_UPDATE: (a0) => this._handleGuildMemberUpdate(a0),
|
|
RELATIONSHIP_ADD: (a0) => this._handleRelationshipAdd(a0),
|
|
RELATIONSHIP_UPDATE: (a0) => this._handleRelationshipUpdate(a0),
|
|
RELATIONSHIP_REMOVE: (a0) => this._handleRelationshipRemove(a0),
|
|
CHANNEL_CREATE: (a0) => this._handleDMCreate(a0),
|
|
CHANNEL_UPDATES: (a0) => this._handleDMUpdates(a0),
|
|
CHANNEL_RECIPIENT_ADD: (a0) => this._handleRecipientChanges(a0),
|
|
PASSIVE_UPDATE_V2: (a0) => this._handlePassiveUpdateV2(a0),
|
|
THREAD_LIST_SYNC: (a0) => this._handleThreadListSync(a0),
|
|
LOAD_FORUM_POSTS: (a0) => this._handleLoadForumPosts(a0),
|
|
LOAD_MESSAGES_SUCCESS: (a0) => this._handleLoadMessagesSuccess(a0),
|
|
SEARCH_MESSAGES_SUCCESS: (a0) => this._handleSearchMessagesSuccess(a0),
|
|
LOAD_THREADS_SUCCESS: (a0) => this._handleLoadThreadsSuccess(a0),
|
|
LOAD_ARCHIVED_THREADS_SUCCESS: (a0) => this._handleLoadThreadsSuccess(a0),
|
|
LOAD_PINNED_MESSAGES_SUCCESS: (a0) => this._handleLoadPinnedMessagesSuccess(a0),
|
|
GUILD_SCHEDULED_EVENT_USERS_FETCH_SUCCESS: (a0) => this._handleGuildScheduledEventUsersFetchSuccess(a0),
|
|
MESSAGE_CREATE: (a0) => this._handleMessageCreateOrUpdate(a0),
|
|
MESSAGE_UPDATE: (a0) => this._handleMessageCreateOrUpdate(a0)
|
|
};
|
|
_handleLogout = () => {
|
|
this.rebootWebworker();
|
|
};
|
|
_handleConnectionOpen = () => {
|
|
setTimeout(() => {
|
|
const currentUser = UserStore.getCurrentUser();
|
|
if (currentUser != null) {
|
|
const transformedUser = getTransformedUser(currentUser);
|
|
const r11 = {};
|
|
r11[transformedUser.id] = transformedUser;
|
|
let c29679_0 = r11;
|
|
Object.values(UserStore.getUsers()).forEach((item) => {
|
|
c29679_0[item.id] = getTransformedUser(item);
|
|
});
|
|
const mutableAllGuildsAndMembers = GuildMemberStore.getMutableAllGuildsAndMembers();
|
|
for (const key in mutableAllGuildsAndMembers) {
|
|
const r37 = mutableAllGuildsAndMembers[key];
|
|
for (const key2 in r37) {
|
|
const r19 = r11[key2];
|
|
let r42 = mutableAllGuildsAndMembers[key][key2]?.nick;
|
|
if (r42 == null) {
|
|
r42 = UserUtils.getGlobalName(r19);
|
|
}
|
|
if (r19 != null && r19 != null) {
|
|
r19.nicknames[key] = r42 != null ? r42 !== "" ? r42 : null : null;
|
|
}
|
|
}
|
|
}
|
|
this.updateUsers(Object.values(r11), "connection_open");
|
|
}
|
|
}, 3000);
|
|
};
|
|
_handleConnectionOpenSupplemental = ({ guilds }) => {
|
|
setTimeout(() => {
|
|
this.updateUsers([...Module12.flatMap(guilds, ({ members, id: id2 }) => {
|
|
let env31397;
|
|
const r1 = env31397 = {
|
|
$parent: env3907
|
|
};
|
|
env31397[0] = id2;
|
|
const r5 = [];
|
|
env31397[1] = r5;
|
|
members.forEach($mk77901(r1));
|
|
return r5;
|
|
}), ...Module12.flatMap(guilds, (a0) => {
|
|
const r1 = [];
|
|
let c31398_1 = r1;
|
|
const activity_instances = a0.activity_instances;
|
|
if (activity_instances != null) {
|
|
activity_instances.forEach((activity_instance) => {
|
|
activity_instance.participants.forEach(({ member }) => {
|
|
if (member != null) {
|
|
const transformedUser = getTransformedUser(member.user);
|
|
if (transformedUser != null) {
|
|
const id2 = a0.id;
|
|
const nick = member.nick;
|
|
if (transformedUser != null) {
|
|
transformedUser.nicknames[id2] = nick != null ? nick !== "" ? nick : null : null;
|
|
}
|
|
c31398_1.push(transformedUser);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
return r1;
|
|
})], "connection_open_supplemental");
|
|
}, 3000);
|
|
};
|
|
_handleOverlayInitialize = ({ users, guildMembers }) => {
|
|
const map = new Map();
|
|
for (const item of users) {
|
|
map.set(item.id, getTransformedUser(item));
|
|
}
|
|
for (const item3 of SnowflakeUtils.keys(guildMembers)) {
|
|
const r60 = guildMembers[item3];
|
|
if (r60 != null) {
|
|
for (const item2 of SnowflakeUtils.keys(r60)) {
|
|
const r76 = map.get(item2);
|
|
const r78 = r60[item2];
|
|
if (r76 != null && r78 != null && r78.nick != null) {
|
|
setNick(r76, item3, r78.nick);
|
|
map.set(item2, r76);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.updateUsers(Array.from(map.values()), "overlay_initialize");
|
|
map.clear();
|
|
};
|
|
_handleCurrentUserUpdate = (a0) => {
|
|
const transformedUser = getTransformedUser(a0.user);
|
|
if (transformedUser != null) {
|
|
this.updateUsers([transformedUser], "current_user_update");
|
|
}
|
|
};
|
|
_handleGuildCreate = ({ guild }) => {
|
|
let env25730;
|
|
const { members, id: id2 } = guild;
|
|
const r10 = env25730 = {
|
|
$parent: env3907
|
|
};
|
|
env25730[0] = id2;
|
|
const r11 = [];
|
|
env25730[1] = r11;
|
|
members.forEach($mk77901(r10));
|
|
this.updateUsers(r11, "guild_create");
|
|
};
|
|
_handleGuildMembersChunkBatch = ({ chunks }) => {
|
|
const r4 = [];
|
|
for (const item of chunks) {
|
|
r4.push.apply(r4, [...updateMembersList(item.members, item.guildId)]);
|
|
}
|
|
this.updateUsers(r4, "guild_members_chunk_batch");
|
|
};
|
|
_handleGuildMemberUpdate = ({ guildId: guildId5, user, nick }) => {
|
|
const transformedUser = getTransformedUser(user);
|
|
if (transformedUser != null) {
|
|
if (transformedUser != null) {
|
|
transformedUser.nicknames[guildId5] = nick != null ? nick !== "" ? nick : null : null;
|
|
}
|
|
this.updateUsers([transformedUser], "guild_member_update");
|
|
}
|
|
};
|
|
_handlePassiveUpdateV2 = ({ members, guildId: guildId5 }) => {
|
|
let env25731;
|
|
const r9 = env25731 = {
|
|
$parent: env3907
|
|
};
|
|
env25731[0] = guildId5;
|
|
const r10 = [];
|
|
env25731[1] = r10;
|
|
members.forEach($mk77901(r9));
|
|
this.updateUsers(r10, "passive_update_v2");
|
|
};
|
|
_handleRelationshipAdd = (a0) => {
|
|
this.updateUsers([getTransformedUser(a0.relationship.user)], "relationship_add");
|
|
};
|
|
_handleRelationshipUpdate = (a0) => {
|
|
this.updateUsers([getTransformedUser(UserStore.getUser(a0.relationship.id))], "relationship_update");
|
|
};
|
|
_handleRelationshipRemove = (a0) => {
|
|
this.updateUsers([getTransformedUser(UserStore.getUser(a0.relationship.id))], "relationship_remove");
|
|
};
|
|
_handleDMCreate = (a0) => {
|
|
let env25732;
|
|
const id2 = a0.channel.id;
|
|
const r11 = env3907;
|
|
const channel = ChannelStore.getChannel(id2);
|
|
const r12 = env25732 = {
|
|
$parent: r11
|
|
};
|
|
env25732[0] = channel;
|
|
const r13 = [];
|
|
env25732[1] = r13;
|
|
if (channel != null && (0, isPrivate)(channel.type)) {
|
|
let recipients = channel.recipients;
|
|
if (recipients === void 0) {
|
|
recipients = [];
|
|
}
|
|
recipients.forEach($mk77900(r12));
|
|
}
|
|
if (r13.length !== 0) {
|
|
const transformedUser = getTransformedUser(UserStore.getCurrentUser());
|
|
if (transformedUser != null) {
|
|
transformedUser.nicknames[id2] = null;
|
|
}
|
|
r13.push(transformedUser);
|
|
this.updateUsers(r13, "dm_create");
|
|
}
|
|
};
|
|
_handleDMUpdates = (a0) => {
|
|
for (const channel of a0.channels) {
|
|
const dMUpdates = getDMUpdates(ChannelStore.getChannel(channel.id));
|
|
if (dMUpdates.length !== 0) {
|
|
const transformedUser = getTransformedUser(UserStore.getCurrentUser());
|
|
setNick(transformedUser, channel.id);
|
|
dMUpdates.push(transformedUser);
|
|
this.updateUsers(dMUpdates, "dm_updates");
|
|
}
|
|
}
|
|
};
|
|
_handleRecipientChanges = (a0) => {
|
|
const { channelId, user } = a0;
|
|
if (a0.isMember) {
|
|
const transformedUser = getTransformedUser(user);
|
|
if (transformedUser != null) {
|
|
transformedUser.nicknames[channelId] = null;
|
|
}
|
|
this.updateUsers([transformedUser], "recipient_changes");
|
|
}
|
|
};
|
|
_handleThreadListSync = ({ guildId, mostRecentMessages }) => {
|
|
let c25733_1;
|
|
c25733_1 = void 0;
|
|
if (mostRecentMessages != null) {
|
|
const r5 = [];
|
|
c25733_1 = r5;
|
|
mostRecentMessages.forEach((mostRecentMessage) => {
|
|
getUsersFromMessage({
|
|
message: mostRecentMessage,
|
|
nicknameContextId: guildId
|
|
}).forEach((item) => c25733_1.push(item));
|
|
});
|
|
this.updateUsers(r5, "thread_list_sync");
|
|
}
|
|
};
|
|
_handleLoadForumPosts = ({ guildId: guildId2, threads }) => {
|
|
const r4 = [];
|
|
let c25734_1 = r4;
|
|
Object.values(threads).forEach(({ first_message, most_recent_message, owner }) => {
|
|
if (first_message != null) {
|
|
getUsersFromMessage({
|
|
message: first_message,
|
|
nicknameContextId: guildId2
|
|
}).forEach((item) => c25734_1.push(item));
|
|
}
|
|
if (most_recent_message != null) {
|
|
getUsersFromMessage({
|
|
message: most_recent_message,
|
|
nicknameContextId: guildId2
|
|
}).forEach((item) => c25734_1.push(item));
|
|
}
|
|
if (owner != null) {
|
|
let env29680;
|
|
const r24 = [owner];
|
|
const r27 = env29680 = {
|
|
$parent: env3907
|
|
};
|
|
env29680[0] = guildId2;
|
|
const r28 = [];
|
|
env29680[1] = r28;
|
|
r24.forEach($mk77901(r27));
|
|
r28.forEach((item) => c25734_1.push(item));
|
|
}
|
|
});
|
|
this.updateUsers(r4, "load_forum_posts");
|
|
};
|
|
_handleLoadMessagesSuccess = (a0) => {
|
|
this.updateUsers(a0.messages.flatMap((a0) => getUsersFromMessage({
|
|
message: a0
|
|
})), "load_messages_success");
|
|
};
|
|
_handleLoadPinnedMessagesSuccess = ({ pins }) => {
|
|
const r4 = [];
|
|
let c25735_0 = r4;
|
|
pins.forEach((pin) => {
|
|
getUsersFromMessage({
|
|
message: pin.message
|
|
}).forEach((item) => c25735_0.push(item));
|
|
});
|
|
this.updateUsers(r4, "load_pinned_messages_success");
|
|
};
|
|
_handleSearchMessagesSuccess = ({ data }) => {
|
|
const r4 = [];
|
|
let c25736_0 = r4;
|
|
data.forEach((a0) => {
|
|
a0.messages.forEach((a0) => {
|
|
a0.forEach((a0) => {
|
|
getUsersFromMessage({
|
|
message: a0
|
|
}).forEach((item) => c25736_0.push(item));
|
|
});
|
|
});
|
|
});
|
|
this.updateUsers(r4, "search_messages_success");
|
|
};
|
|
_handleLoadThreadsSuccess = (a0) => {
|
|
const r2 = env3907;
|
|
const { guildId: guildId3, firstMessages, mostRecentMessages, owners } = a0;
|
|
const r10 = [];
|
|
let c25737_1 = r10;
|
|
if (firstMessages != null) {
|
|
firstMessages.forEach((firstMessage) => {
|
|
getUsersFromMessage({
|
|
message: firstMessage,
|
|
nicknameContextId: guildId3
|
|
}).forEach((item) => c25737_1.push(item));
|
|
});
|
|
}
|
|
if (mostRecentMessages != null) {
|
|
mostRecentMessages.forEach((mostRecentMessage) => {
|
|
getUsersFromMessage({
|
|
message: mostRecentMessage,
|
|
nicknameContextId: guildId3
|
|
}).forEach((item) => c25737_1.push(item));
|
|
});
|
|
}
|
|
if (owners != null) {
|
|
let env25738;
|
|
const r15 = env25738 = {
|
|
$parent: r2
|
|
};
|
|
env25738[0] = guildId3;
|
|
const r16 = [];
|
|
env25738[1] = r16;
|
|
owners.forEach($mk77901(r15));
|
|
r16.forEach((item) => c25737_1.push(item));
|
|
}
|
|
this.updateUsers(r10, "load_threads_success");
|
|
};
|
|
_handleMessageCreateOrUpdate = (a0) => {
|
|
this.updateUsers(getUsersFromMessage({
|
|
message: a0.message
|
|
}), "message_create_or_update");
|
|
};
|
|
_handleGuildScheduledEventUsersFetchSuccess = ({ guildId: guildId4, guildScheduledEventUsers }) => {
|
|
const r4 = [];
|
|
let c25739_1 = r4;
|
|
guildScheduledEventUsers.forEach(({ user, member }) => {
|
|
const transformedUser = getTransformedUser(user);
|
|
if (transformedUser != null) {
|
|
const nick = member?.nick;
|
|
if (transformedUser != null) {
|
|
transformedUser.nicknames[guildId4] = nick != null ? nick !== "" ? nick : null : null;
|
|
}
|
|
c25739_1.push(transformedUser);
|
|
}
|
|
});
|
|
this.updateUsers(r4, "guild_scheduled_event_users_fetch_success");
|
|
};
|
|
_initialize() {
|
|
this.rebootWebworker();
|
|
}
|
|
_terminate() {
|
|
if (this._worker != null) {
|
|
this._worker.terminate();
|
|
this._worker = null;
|
|
}
|
|
}
|
|
rebootWebworker() {
|
|
if (this._worker != null) {
|
|
this._worker.terminate();
|
|
this._worker = null;
|
|
}
|
|
this._worker = _UserSearch_worker;
|
|
}
|
|
updateUsers(a0, a1) {
|
|
const _worker = this._worker;
|
|
if (_worker != null) {
|
|
const payload = a0.filter(isNotNullish);
|
|
for (const item of payload) {
|
|
if (item?.id == null) {
|
|
const username = item?.username;
|
|
SentryUtils_native.addBreadcrumb({
|
|
category: "debug",
|
|
message: "User missing id",
|
|
data: {
|
|
action: a1,
|
|
userFields: {
|
|
userIsNull: item == null,
|
|
idIsNull: true,
|
|
usernameIsNull: username == null,
|
|
isBot: item?.isBot,
|
|
isFriend: item?.isFriend,
|
|
isProvisional: item?.isProvisional,
|
|
globalNameIsNull: item?.globalName == null,
|
|
usersArrayLength: payload.length
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
_worker.postMessage({
|
|
type: c3907_11.UPDATE_USERS,
|
|
payload
|
|
});
|
|
}
|
|
}
|
|
getUserSearchContext(a0, _limit = 10) {
|
|
this.initialize();
|
|
const _worker = this._worker;
|
|
if (_worker == null) {
|
|
throw new Error("SearchContextManager: No webworker initialized");
|
|
}
|
|
if (_limit === void 0) {
|
|
_limit = 10;
|
|
}
|
|
let env15555;
|
|
const r17 = {
|
|
__proto__: UserSearchContext.prototype
|
|
};
|
|
const r8 = env15555 = {
|
|
$parent: env3907
|
|
};
|
|
env15555[0] = r17;
|
|
r17.handleMessages = $mk77903(r8);
|
|
r17._worker = _worker;
|
|
r17._uuid = v4();
|
|
r17._callback = a0;
|
|
r17._limit = _limit;
|
|
r17._currentQuery = null;
|
|
r17._nextQuery = null;
|
|
r17._subscribed = false;
|
|
r17.subscribe();
|
|
return r17;
|
|
}
|
|
requestDebugState() {
|
|
return Promise.resolve(null);
|
|
}
|
|
}
|
|
c3907_18 = UserSearchManager;
|
|
const r79 = new UserSearchManager();
|
|
export default r79;
|