209 lines
8.8 KiB
TypeScript
209 lines
8.8 KiB
TypeScript
// Module ID: 7522
|
|
// Function ID: 7523
|
|
// Name: ScheduledMessagesConfig
|
|
// Dependencies: [32, 1922, 676, 1924, 7523, 3, 38, 1472, 7361, 1403, 4043, 1946, 589, 4690, 7524, 1236, 1370, 2]
|
|
// Exports: canUseScheduledMessages, convertServerScheduledMessageCreateArgs, convertServerScheduledMessageSend, getDefaultScheduledTime, getMessageForState, getScheduledMessagesLimit, parseContentAndFlagsForSilentMessage, unparseContentAndFlagsForSilentMessage, useCanUseScheduledMessages, useScheduledMessagesLimit
|
|
|
|
// Module 7522 (ScheduledMessagesConfig)
|
|
import timestampDefault from "timestamp" /* 3 */;
|
|
import _modDef38 from "module_38" /* 38 */;
|
|
import hasFlag from "hasFlag" /* 1403 */;
|
|
import isPremiumAtLeast from "isPremiumAtLeast" /* 1946 */;
|
|
import hooksDefault from "hooks" /* 4043 */;
|
|
import createMinimalMessageRecord from "createMinimalMessageRecord" /* 4690 */;
|
|
import regExp from "regExp" /* 7361 */;
|
|
import regExpDefault from "regExp" /* 7361 */;
|
|
import ScheduledMessageSendState from "ScheduledMessageSendState" /* 7524 */;
|
|
import closure_3 from "_slicedToArray" /* 32 */;
|
|
import closure_4 from "mergeGuildAvatar" /* 1922 */;
|
|
import { MessageFlags } from "ME" /* 676 */;
|
|
import { PremiumTypes } from "GuildFeatures" /* 1924 */;
|
|
import MIN_SCHEDULE_TIME_INTO_FUTURE_SECONDS from "MIN_SCHEDULE_TIME_INTO_FUTURE_SECONDS" /* 7523 */;
|
|
import ApexExperiment from "ApexExperiment" /* 1472 */;
|
|
|
|
require = arg1;
|
|
({ MAX_SCHEDULED_MESSAGES_PER_USER: error, MIN_SCHEDULE_TIME_INTO_FUTURE_SECONDS: closure_8 } = MIN_SCHEDULE_TIME_INTO_FUTURE_SECONDS);
|
|
class ScheduledMessagesConfig {
|
|
constructor(arg0, arg1) {
|
|
obj = Object.create(new.target.prototype);
|
|
tmp2 = require("module_38")(null != arg1.limit, "Config is missing scheduled message limit");
|
|
obj.enabled = global;
|
|
obj.limit = arg1.limit;
|
|
return obj;
|
|
}
|
|
}
|
|
ApexExperiment = { name: "2026-08-scheduled-messages", kind: "user", defaultConfig: null, variations: null };
|
|
ApexExperiment = Object.create(ScheduledMessagesConfig.prototype);
|
|
_modDef38(true, "Config is missing scheduled message limit");
|
|
ApexExperiment.enabled = false;
|
|
ApexExperiment.limit = 0;
|
|
ApexExperiment[2] = ApexExperiment;
|
|
let obj1 = {
|
|
1: null,
|
|
2: (arg0) => {
|
|
const parsed = JSON.parse(arg0);
|
|
if (typeof ScheduledMessagesConfig !== "function") {
|
|
HermesBuiltin.throwTypeError();
|
|
}
|
|
const obj = Object.create(ScheduledMessagesConfig.prototype);
|
|
_modDef38(null != parsed.limit, "Config is missing scheduled message limit");
|
|
obj.enabled = true;
|
|
obj.limit = parsed.limit;
|
|
return obj;
|
|
}
|
|
};
|
|
obj1[2] = (arg0) => {
|
|
const parsed = JSON.parse(arg0);
|
|
if (typeof ScheduledMessagesConfig !== "function") {
|
|
HermesBuiltin.throwTypeError();
|
|
}
|
|
const obj = Object.create(ScheduledMessagesConfig.prototype);
|
|
_modDef38(null != parsed.limit, "Config is missing scheduled message limit");
|
|
obj.enabled = true;
|
|
obj.limit = parsed.limit;
|
|
return obj;
|
|
};
|
|
ApexExperiment[3] = obj1;
|
|
let closure_10 = ApexExperiment.createApexExperiment(ApexExperiment);
|
|
const tmp3 = new timestampDefault("Scheduled Messages");
|
|
const result = require("set").fileFinishedImporting("modules/scheduled_messages/ScheduledMessageUtils.tsx");
|
|
|
|
export const scheduledMessageLogger = tmp3;
|
|
export const parseContentAndFlagsForSilentMessage = function parseContentAndFlagsForSilentMessage(arg0) {
|
|
({ content, flags } = arg0);
|
|
const tmp2 = callback(regExpDefault(content), 2);
|
|
const items = [, ];
|
|
if (tmp2[0]) {
|
|
items[0] = tmp2[1];
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
items[1] = hasFlag.addFlag(flags, MessageFlags.SUPPRESS_NOTIFICATIONS);
|
|
let tmp4 = items;
|
|
const obj = hasFlag;
|
|
} else {
|
|
items[0] = content;
|
|
let num = flags;
|
|
if (flags == null) {
|
|
num = 0;
|
|
}
|
|
items[1] = num;
|
|
tmp4 = items;
|
|
}
|
|
return tmp4;
|
|
};
|
|
export const unparseContentAndFlagsForSilentMessage = function unparseContentAndFlagsForSilentMessage(createArgs) {
|
|
({ content, flags } = createArgs);
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
let combined = content;
|
|
if (obj.hasFlag(flags, MessageFlags.SUPPRESS_NOTIFICATIONS)) {
|
|
const _HermesInternal = HermesInternal;
|
|
combined = "" + regExp.SILENT_SENTINEL + " " + content;
|
|
}
|
|
return combined;
|
|
};
|
|
export const useCanUseScheduledMessages = function useCanUseScheduledMessages() {
|
|
return store.useConfig({ location: "useCanUseScheduledMessages" }).enabled;
|
|
};
|
|
export const canUseScheduledMessages = function canUseScheduledMessages(location) {
|
|
return store.getConfig({ location }).enabled;
|
|
};
|
|
export const getDefaultScheduledTime = function getDefaultScheduledTime() {
|
|
const obj = hooksDefault();
|
|
const addResult = hooksDefault().add(closure_8, "seconds");
|
|
const obj2 = hooksDefault();
|
|
const addResult1 = hooksDefault().startOf("hour").add(1, "hour");
|
|
let addResult2 = addResult1;
|
|
if (addResult1.isBefore(addResult)) {
|
|
addResult2 = addResult1.add(1, "hour");
|
|
}
|
|
return addResult2;
|
|
};
|
|
export const getScheduledMessagesLimit = function getScheduledMessagesLimit(ScheduledMessagesCreateRoadblock) {
|
|
let obj = isPremiumAtLeast;
|
|
obj = { location: ScheduledMessagesCreateRoadblock };
|
|
const config = store.getConfig(obj);
|
|
if (config.enabled) {
|
|
if (isPremiumResult) {
|
|
obj = { limit: null, isUpgradable: false };
|
|
obj[0] = closure_7;
|
|
obj1 = obj;
|
|
} else {
|
|
obj1 = { limit: null, isUpgradable: true };
|
|
obj1[0] = config.limit;
|
|
}
|
|
} else {
|
|
return { limit: 0, isUpgradable: false };
|
|
}
|
|
};
|
|
export const useScheduledMessagesLimit = function useScheduledMessagesLimit(ScheduledMessagesMobileModal) {
|
|
let obj = { location: ScheduledMessagesMobileModal };
|
|
const config = store.useConfig(obj);
|
|
const items = [closure_4];
|
|
if (config.enabled) {
|
|
if (obj2.useStateFromStores(items, () => callback(table[11]).isPremium(currentUser.getCurrentUser(), TIER_2.TIER_2))) {
|
|
obj = { limit: null, isUpgradable: false };
|
|
obj[0] = closure_7;
|
|
} else {
|
|
obj = { limit: null, isUpgradable: true };
|
|
obj[0] = config.limit;
|
|
}
|
|
} else {
|
|
return { limit: 0, isUpgradable: false };
|
|
}
|
|
};
|
|
export const convertServerScheduledMessageSend = function convertServerScheduledMessageSend(body) {
|
|
obj = { userId: body.user_id, scheduledMessageId: body.scheduled_message_id, sendAtTimestamp: body.send_at_timestamp, createArgs: obj, state: body.state, attachmentUploads: null, record: null };
|
|
const create_args = body.create_args;
|
|
obj = { channelId: create_args.channel_id, content: create_args.content, type: create_args.type, flags: create_args.flags, messageReference: create_args.message_reference };
|
|
let attachment_uploads = body.attachment_uploads;
|
|
if (attachment_uploads == null) {
|
|
attachment_uploads = [];
|
|
}
|
|
obj[5] = attachment_uploads.map((filename) => ({ filename: filename.filename, uploadedFilename: filename.uploaded_filename, description: filename.description, title: filename.title }));
|
|
obj = {};
|
|
const merged = Object.assign(body.message_preview);
|
|
obj.timestamp = body.send_at_timestamp;
|
|
obj[6] = createMinimalMessageRecord.createMessageRecord(obj);
|
|
return obj;
|
|
};
|
|
export const getMessageForState = function getMessageForState(state) {
|
|
if (ScheduledMessageSendState.ScheduledMessageSendState.SCHEDULED === state) {
|
|
let obj = { isError: false, stateMessage: null };
|
|
const intl6 = tmp(1236).intl;
|
|
obj[1] = intl6.string(tmp(1236).t.Fn6Odn);
|
|
return obj;
|
|
} else if (tmp(7524).ScheduledMessageSendState.ERROR_CHANNEL_NOT_FOUND === state) {
|
|
obj = { isError: true, stateMessage: null };
|
|
const intl5 = tmp(1236).intl;
|
|
obj[1] = intl5.string(tmp(1236).t.v5O2dK);
|
|
return obj;
|
|
} else if (tmp(7524).ScheduledMessageSendState.ERROR_USER_NOT_FOUND === state) {
|
|
obj1 = { isError: true, stateMessage: null };
|
|
const intl4 = tmp(1236).intl;
|
|
obj1[1] = intl4.string(tmp(1236).t.j8uIfG);
|
|
return obj1;
|
|
} else if (tmp(7524).ScheduledMessageSendState.ERROR_USER_CANNOT_USE_SCHEDULED_MESSAGES === state) {
|
|
const obj2 = { isError: true, stateMessage: null };
|
|
const intl3 = tmp(1236).intl;
|
|
obj2[1] = intl3.string(tmp(1236).t["w6zHX/"]);
|
|
return obj2;
|
|
} else if (tmp(7524).ScheduledMessageSendState.ERROR_SEND_FAILED === state) {
|
|
const obj3 = { isError: true, stateMessage: null };
|
|
const intl2 = tmp(1236).intl;
|
|
obj3[1] = intl2.string(tmp(1236).t.pflV7z);
|
|
return obj3;
|
|
} else if (tmp(7524).ScheduledMessageSendState.ERROR_SCHEDULED_MESSAGES_DISABLED === state) {
|
|
const obj4 = { isError: true, stateMessage: null };
|
|
const intl = tmp(1236).intl;
|
|
obj4[1] = intl.string(tmp(1236).t.j8uIfG);
|
|
return obj4;
|
|
} else {
|
|
tmp(1370).assertNever(state);
|
|
}
|
|
};
|
|
export const convertServerScheduledMessageCreateArgs = function convertServerScheduledMessageCreateArgs(channelId) {
|
|
return { channelId: channelId.channel_id, content: channelId.content, type: channelId.type, flags: channelId.flags, messageReference: channelId.message_reference };
|
|
};
|