mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Reformat all files with Prettier
This commit is contained in:
parent
0cde0d46d2
commit
ac79eb09f5
206 changed files with 727 additions and 888 deletions
|
@ -68,10 +68,7 @@ export class ApiLogins extends BaseRepository {
|
|||
token: hashedToken,
|
||||
user_id: userId,
|
||||
logged_in_at: moment.utc().format(DBDateFormat),
|
||||
expires_at: moment
|
||||
.utc()
|
||||
.add(LOGIN_EXPIRY_TIME, "ms")
|
||||
.format(DBDateFormat),
|
||||
expires_at: moment.utc().add(LOGIN_EXPIRY_TIME, "ms").format(DBDateFormat),
|
||||
});
|
||||
|
||||
return `${loginId}.${token}`;
|
||||
|
@ -96,10 +93,7 @@ export class ApiLogins extends BaseRepository {
|
|||
await this.apiLogins.update(
|
||||
{ id: loginId },
|
||||
{
|
||||
expires_at: moment()
|
||||
.utc()
|
||||
.add(LOGIN_EXPIRY_TIME, "ms")
|
||||
.format(DBDateFormat),
|
||||
expires_at: moment().utc().add(LOGIN_EXPIRY_TIME, "ms").format(DBDateFormat),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class ApiUserInfo extends BaseRepository {
|
|||
}
|
||||
|
||||
update(id, data: ApiUserInfoData) {
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const repo = entityManager.getRepository(ApiUserInfoEntity);
|
||||
|
||||
const existingInfo = await repo.findOne({ where: { id } });
|
||||
|
|
|
@ -41,11 +41,7 @@ export class Configs extends BaseRepository {
|
|||
}
|
||||
|
||||
getActiveLargerThanId(id) {
|
||||
return this.configs
|
||||
.createQueryBuilder()
|
||||
.where("id > :id", { id })
|
||||
.andWhere("is_active = 1")
|
||||
.getMany();
|
||||
return this.configs.createQueryBuilder().where("id > :id", { id }).andWhere("is_active = 1").getMany();
|
||||
}
|
||||
|
||||
async hasConfig(key) {
|
||||
|
@ -65,7 +61,7 @@ export class Configs extends BaseRepository {
|
|||
}
|
||||
|
||||
async saveNewRevision(key, config, editedBy) {
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const repo = entityManager.getRepository(Config);
|
||||
// Mark all old revisions inactive
|
||||
await repo.update({ key }, { is_active: false });
|
||||
|
|
|
@ -88,10 +88,10 @@ export class GuildArchives extends BaseGuildRepository {
|
|||
id: msg.id,
|
||||
timestamp: moment.utc(msg.posted_at).format("YYYY-MM-DD HH:mm:ss"),
|
||||
content: msg.data.content,
|
||||
attachments: msg.data.attachments?.map(att => {
|
||||
attachments: msg.data.attachments?.map((att) => {
|
||||
return JSON.stringify({ name: att.name, url: att.url, type: att.contentType });
|
||||
}),
|
||||
stickers: msg.data.stickers?.map(sti => {
|
||||
stickers: msg.data.stickers?.map((sti) => {
|
||||
return JSON.stringify({ name: sti.name, id: sti.id, isDefault: isDefaultSticker(sti.id) });
|
||||
}),
|
||||
user: partialUser,
|
||||
|
|
|
@ -123,7 +123,7 @@ export class GuildCases extends BaseGuildRepository {
|
|||
guild_id: this.guildId,
|
||||
case_number: () => `(SELECT IFNULL(MAX(case_number)+1, 1) FROM cases AS ma2 WHERE guild_id = ${this.guildId})`,
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
if (err?.code === "ER_DUP_ENTRY") {
|
||||
if (data.audit_log_id) {
|
||||
console.trace(`Tried to insert case with duplicate audit_log_id`);
|
||||
|
@ -148,7 +148,7 @@ export class GuildCases extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async softDelete(id: number, deletedById: string, deletedByName: string, deletedByText: string) {
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const cases = entityManager.getRepository(Case);
|
||||
const caseNotes = entityManager.getRepository(CaseNote);
|
||||
|
||||
|
|
|
@ -17,19 +17,11 @@ const MAX_COUNTER_VALUE = 2147483647; // 2^31-1, for MySQL INT
|
|||
const decayQueue = new Queue();
|
||||
|
||||
async function deleteCountersMarkedToBeDeleted(): Promise<void> {
|
||||
await getRepository(Counter)
|
||||
.createQueryBuilder()
|
||||
.where("delete_at <= NOW()")
|
||||
.delete()
|
||||
.execute();
|
||||
await getRepository(Counter).createQueryBuilder().where("delete_at <= NOW()").delete().execute();
|
||||
}
|
||||
|
||||
async function deleteTriggersMarkedToBeDeleted(): Promise<void> {
|
||||
await getRepository(CounterTrigger)
|
||||
.createQueryBuilder()
|
||||
.where("delete_at <= NOW()")
|
||||
.delete()
|
||||
.execute();
|
||||
await getRepository(CounterTrigger).createQueryBuilder().where("delete_at <= NOW()").delete().execute();
|
||||
}
|
||||
|
||||
setInterval(deleteCountersMarkedToBeDeleted, 1 * HOURS);
|
||||
|
@ -97,10 +89,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
criteria.id = Not(In(idsToKeep));
|
||||
}
|
||||
|
||||
const deleteAt = moment
|
||||
.utc()
|
||||
.add(DELETE_UNUSED_COUNTERS_AFTER, "ms")
|
||||
.format(DBDateFormat);
|
||||
const deleteAt = moment.utc().add(DELETE_UNUSED_COUNTERS_AFTER, "ms").format(DBDateFormat);
|
||||
|
||||
await this.counters.update(criteria, {
|
||||
delete_at: deleteAt,
|
||||
|
@ -108,11 +97,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async deleteCountersMarkedToBeDeleted(): Promise<void> {
|
||||
await this.counters
|
||||
.createQueryBuilder()
|
||||
.where("delete_at <= NOW()")
|
||||
.delete()
|
||||
.execute();
|
||||
await this.counters.createQueryBuilder().where("delete_at <= NOW()").delete().execute();
|
||||
}
|
||||
|
||||
async changeCounterValue(
|
||||
|
@ -230,14 +215,11 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
const triggersToMark = await triggersToMarkQuery.getMany();
|
||||
|
||||
if (triggersToMark.length) {
|
||||
const deleteAt = moment
|
||||
.utc()
|
||||
.add(DELETE_UNUSED_COUNTER_TRIGGERS_AFTER, "ms")
|
||||
.format(DBDateFormat);
|
||||
const deleteAt = moment.utc().add(DELETE_UNUSED_COUNTER_TRIGGERS_AFTER, "ms").format(DBDateFormat);
|
||||
|
||||
await this.counterTriggers.update(
|
||||
{
|
||||
id: In(triggersToMark.map(t => t.id)),
|
||||
id: In(triggersToMark.map((t) => t.id)),
|
||||
},
|
||||
{
|
||||
delete_at: deleteAt,
|
||||
|
@ -247,11 +229,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async deleteTriggersMarkedToBeDeleted(): Promise<void> {
|
||||
await this.counterTriggers
|
||||
.createQueryBuilder()
|
||||
.where("delete_at <= NOW()")
|
||||
.delete()
|
||||
.execute();
|
||||
await this.counterTriggers.createQueryBuilder().where("delete_at <= NOW()").delete().execute();
|
||||
}
|
||||
|
||||
async initCounterTrigger(
|
||||
|
@ -278,7 +256,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
throw new Error(`Invalid comparison value: ${reverseComparisonValue}`);
|
||||
}
|
||||
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const existing = await entityManager.findOne(CounterTrigger, {
|
||||
counter_id: counterId,
|
||||
name: triggerName,
|
||||
|
@ -330,7 +308,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
channelId = channelId || "0";
|
||||
userId = userId || "0";
|
||||
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const previouslyTriggered = await entityManager.findOne(CounterTriggerState, {
|
||||
trigger_id: counterTrigger.id,
|
||||
user_id: userId!,
|
||||
|
@ -378,7 +356,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
async checkAllValuesForTrigger(
|
||||
counterTrigger: CounterTrigger,
|
||||
): Promise<Array<{ channelId: string; userId: string }>> {
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const matchingValues = await entityManager
|
||||
.createQueryBuilder(CounterValue, "cv")
|
||||
.leftJoin(
|
||||
|
@ -395,7 +373,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
if (matchingValues.length) {
|
||||
await entityManager.insert(
|
||||
CounterTriggerState,
|
||||
matchingValues.map(row => ({
|
||||
matchingValues.map((row) => ({
|
||||
trigger_id: counterTrigger.id,
|
||||
channel_id: row.channel_id,
|
||||
user_id: row.user_id,
|
||||
|
@ -403,7 +381,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
);
|
||||
}
|
||||
|
||||
return matchingValues.map(row => ({
|
||||
return matchingValues.map((row) => ({
|
||||
channelId: row.channel_id,
|
||||
userId: row.user_id,
|
||||
}));
|
||||
|
@ -429,7 +407,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
channelId = channelId || "0";
|
||||
userId = userId || "0";
|
||||
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const matchingValue = await entityManager
|
||||
.createQueryBuilder(CounterValue, "cv")
|
||||
.innerJoin(
|
||||
|
@ -468,7 +446,7 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
async checkAllValuesForReverseTrigger(
|
||||
counterTrigger: CounterTrigger,
|
||||
): Promise<Array<{ channelId: string; userId: string }>> {
|
||||
return connection.transaction(async entityManager => {
|
||||
return connection.transaction(async (entityManager) => {
|
||||
const matchingValues: Array<{
|
||||
id: string;
|
||||
triggerStateId: string;
|
||||
|
@ -496,11 +474,11 @@ export class GuildCounters extends BaseGuildRepository {
|
|||
|
||||
if (matchingValues.length) {
|
||||
await entityManager.delete(CounterTriggerState, {
|
||||
id: In(matchingValues.map(v => v.triggerStateId)),
|
||||
id: In(matchingValues.map((v) => v.triggerStateId)),
|
||||
});
|
||||
}
|
||||
|
||||
return matchingValues.map(row => ({
|
||||
return matchingValues.map((row) => ({
|
||||
channelId: row.channel_id,
|
||||
userId: row.user_id,
|
||||
}));
|
||||
|
|
|
@ -46,12 +46,12 @@ export class GuildLogs extends events.EventEmitter {
|
|||
}
|
||||
|
||||
isLogIgnored(type: LogType, ignoreId: any) {
|
||||
return this.ignoredLogs.some(info => type === info.type && ignoreId === info.ignoreId);
|
||||
return this.ignoredLogs.some((info) => type === info.type && ignoreId === info.ignoreId);
|
||||
}
|
||||
|
||||
clearIgnoredLog(type: LogType, ignoreId: any) {
|
||||
this.ignoredLogs.splice(
|
||||
this.ignoredLogs.findIndex(info => type === info.type && ignoreId === info.ignoreId),
|
||||
this.ignoredLogs.findIndex((info) => type === info.type && ignoreId === info.ignoreId),
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export class GuildMemberTimezones extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async set(memberId, timezone: string) {
|
||||
await connection.transaction(async entityManager => {
|
||||
await connection.transaction(async (entityManager) => {
|
||||
const repo = entityManager.getRepository(MemberTimezone);
|
||||
const existingRow = await repo.findOne({
|
||||
guild_id: this.guildId,
|
||||
|
|
|
@ -35,12 +35,7 @@ export class GuildMutes extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async addMute(userId, expiryTime, rolesToRestore?: string[]): Promise<Mute> {
|
||||
const expiresAt = expiryTime
|
||||
? moment
|
||||
.utc()
|
||||
.add(expiryTime, "ms")
|
||||
.format("YYYY-MM-DD HH:mm:ss")
|
||||
: null;
|
||||
const expiresAt = expiryTime ? moment.utc().add(expiryTime, "ms").format("YYYY-MM-DD HH:mm:ss") : null;
|
||||
|
||||
const result = await this.mutes.insert({
|
||||
guild_id: this.guildId,
|
||||
|
@ -53,12 +48,7 @@ export class GuildMutes extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async updateExpiryTime(userId, newExpiryTime, rolesToRestore?: string[]) {
|
||||
const expiresAt = newExpiryTime
|
||||
? moment
|
||||
.utc()
|
||||
.add(newExpiryTime, "ms")
|
||||
.format("YYYY-MM-DD HH:mm:ss")
|
||||
: null;
|
||||
const expiresAt = newExpiryTime ? moment.utc().add(newExpiryTime, "ms").format("YYYY-MM-DD HH:mm:ss") : null;
|
||||
|
||||
if (rolesToRestore && rolesToRestore.length) {
|
||||
return this.mutes.update(
|
||||
|
@ -89,7 +79,7 @@ export class GuildMutes extends BaseGuildRepository {
|
|||
.createQueryBuilder("mutes")
|
||||
.where("guild_id = :guild_id", { guild_id: this.guildId })
|
||||
.andWhere(
|
||||
new Brackets(qb => {
|
||||
new Brackets((qb) => {
|
||||
qb.where("expires_at > NOW()").orWhere("expires_at IS NULL");
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -70,7 +70,7 @@ export class GuildNicknameHistory extends BaseGuildRepository {
|
|||
|
||||
if (toDelete.length > 0) {
|
||||
await this.nicknameHistory.delete({
|
||||
id: In(toDelete.map(v => v.id)),
|
||||
id: In(toDelete.map((v) => v.id)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
};
|
||||
|
||||
if (msg.attachments.size) {
|
||||
data.attachments = Array.from(msg.attachments.values()).map(att => ({
|
||||
data.attachments = Array.from(msg.attachments.values()).map((att) => ({
|
||||
id: att.id,
|
||||
contentType: att.contentType,
|
||||
name: att.name,
|
||||
|
@ -59,14 +59,14 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
if (msg.embeds.length) {
|
||||
data.embeds = msg.embeds.map(embed => ({
|
||||
data.embeds = msg.embeds.map((embed) => ({
|
||||
title: embed.title,
|
||||
description: embed.description,
|
||||
url: embed.url,
|
||||
timestamp: embed.timestamp,
|
||||
color: embed.color,
|
||||
|
||||
fields: embed.fields.map(field => ({
|
||||
fields: embed.fields.map((field) => ({
|
||||
name: field.name,
|
||||
value: field.value,
|
||||
inline: field.inline,
|
||||
|
@ -119,7 +119,7 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
if (msg.stickers?.size) {
|
||||
data.stickers = Array.from(msg.stickers.values()).map(sticker => ({
|
||||
data.stickers = Array.from(msg.stickers.values()).map((sticker) => ({
|
||||
format: sticker.format,
|
||||
guildId: sticker.guildId,
|
||||
id: sticker.id,
|
||||
|
|
|
@ -11,10 +11,7 @@ export class GuildScheduledPosts extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
all(): Promise<ScheduledPost[]> {
|
||||
return this.scheduledPosts
|
||||
.createQueryBuilder()
|
||||
.where("guild_id = :guildId", { guildId: this.guildId })
|
||||
.getMany();
|
||||
return this.scheduledPosts.createQueryBuilder().where("guild_id = :guildId", { guildId: this.guildId }).getMany();
|
||||
}
|
||||
|
||||
getDueScheduledPosts(): Promise<ScheduledPost[]> {
|
||||
|
|
|
@ -67,10 +67,7 @@ export class GuildSlowmodes extends BaseGuildRepository {
|
|||
const slowmode = await this.getChannelSlowmode(channelId);
|
||||
if (!slowmode) return;
|
||||
|
||||
const expiresAt = moment
|
||||
.utc()
|
||||
.add(slowmode.slowmode_seconds, "seconds")
|
||||
.format("YYYY-MM-DD HH:mm:ss");
|
||||
const expiresAt = moment.utc().add(slowmode.slowmode_seconds, "seconds").format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
if (await this.userHasSlowmode(channelId, userId)) {
|
||||
// Update existing
|
||||
|
|
|
@ -30,10 +30,7 @@ export class GuildTempbans extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async addTempban(userId, expiryTime, modId): Promise<Tempban> {
|
||||
const expiresAt = moment
|
||||
.utc()
|
||||
.add(expiryTime, "ms")
|
||||
.format("YYYY-MM-DD HH:mm:ss");
|
||||
const expiresAt = moment.utc().add(expiryTime, "ms").format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
const result = await this.tempbans.insert({
|
||||
guild_id: this.guildId,
|
||||
|
@ -47,10 +44,7 @@ export class GuildTempbans extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async updateExpiryTime(userId, newExpiryTime, modId) {
|
||||
const expiresAt = moment
|
||||
.utc()
|
||||
.add(newExpiryTime, "ms")
|
||||
.format("YYYY-MM-DD HH:mm:ss");
|
||||
const expiresAt = moment.utc().add(newExpiryTime, "ms").format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
return this.tempbans.update(
|
||||
{
|
||||
|
|
|
@ -19,10 +19,7 @@ export class GuildVCAlerts extends BaseGuildRepository {
|
|||
}
|
||||
|
||||
async getAllGuildAlerts(): Promise<VCAlert[]> {
|
||||
return this.allAlerts
|
||||
.createQueryBuilder()
|
||||
.where("guild_id = :guildId", { guildId: this.guildId })
|
||||
.getMany();
|
||||
return this.allAlerts.createQueryBuilder().where("guild_id = :guildId", { guildId: this.guildId }).getMany();
|
||||
}
|
||||
|
||||
async getAlertsByUserId(userId: string): Promise<VCAlert[]> {
|
||||
|
|
|
@ -67,7 +67,7 @@ export class UsernameHistory extends BaseRepository {
|
|||
|
||||
if (toDelete.length > 0) {
|
||||
await this.usernameHistory.delete({
|
||||
id: In(toDelete.map(v => v.id)),
|
||||
id: In(toDelete.map((v) => v.id)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,7 @@ export async function cleanupConfigs() {
|
|||
let rows;
|
||||
|
||||
// >1 month old: 1 config retained per month
|
||||
const oneMonthCutoff = moment
|
||||
.utc()
|
||||
.subtract(30, "days")
|
||||
.format(DBDateFormat);
|
||||
const oneMonthCutoff = moment.utc().subtract(30, "days").format(DBDateFormat);
|
||||
do {
|
||||
rows = await connection.query(
|
||||
`
|
||||
|
@ -46,7 +43,7 @@ export async function cleanupConfigs() {
|
|||
|
||||
if (rows.length > 0) {
|
||||
await configRepository.delete({
|
||||
id: In(rows.map(r => r.id)),
|
||||
id: In(rows.map((r) => r.id)),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,10 +51,7 @@ export async function cleanupConfigs() {
|
|||
} while (rows.length === CLEAN_PER_LOOP);
|
||||
|
||||
// >2 weeks old: 1 config retained per day
|
||||
const twoWeekCutoff = moment
|
||||
.utc()
|
||||
.subtract(2, "weeks")
|
||||
.format(DBDateFormat);
|
||||
const twoWeekCutoff = moment.utc().subtract(2, "weeks").format(DBDateFormat);
|
||||
do {
|
||||
rows = await connection.query(
|
||||
`
|
||||
|
@ -87,7 +81,7 @@ export async function cleanupConfigs() {
|
|||
|
||||
if (rows.length > 0) {
|
||||
await configRepository.delete({
|
||||
id: In(rows.map(r => r.id)),
|
||||
id: In(rows.map((r) => r.id)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -18,18 +18,9 @@ export async function cleanupMessages(): Promise<number> {
|
|||
|
||||
const messagesRepository = getRepository(SavedMessage);
|
||||
|
||||
const deletedAtThreshold = moment
|
||||
.utc()
|
||||
.subtract(DELETED_MESSAGE_RETENTION_PERIOD, "ms")
|
||||
.format(DBDateFormat);
|
||||
const postedAtThreshold = moment
|
||||
.utc()
|
||||
.subtract(RETENTION_PERIOD, "ms")
|
||||
.format(DBDateFormat);
|
||||
const botPostedAtThreshold = moment
|
||||
.utc()
|
||||
.subtract(BOT_MESSAGE_RETENTION_PERIOD, "ms")
|
||||
.format(DBDateFormat);
|
||||
const deletedAtThreshold = moment.utc().subtract(DELETED_MESSAGE_RETENTION_PERIOD, "ms").format(DBDateFormat);
|
||||
const postedAtThreshold = moment.utc().subtract(RETENTION_PERIOD, "ms").format(DBDateFormat);
|
||||
const botPostedAtThreshold = moment.utc().subtract(BOT_MESSAGE_RETENTION_PERIOD, "ms").format(DBDateFormat);
|
||||
|
||||
// SELECT + DELETE messages in batches
|
||||
// This is to avoid deadlocks that happened frequently when deleting with the same criteria as the select below
|
||||
|
@ -60,7 +51,7 @@ export async function cleanupMessages(): Promise<number> {
|
|||
|
||||
if (rows.length > 0) {
|
||||
await messagesRepository.delete({
|
||||
id: In(rows.map(r => r.id)),
|
||||
id: In(rows.map((r) => r.id)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,7 @@ export async function cleanupNicknames(): Promise<number> {
|
|||
let cleaned = 0;
|
||||
|
||||
const nicknameHistoryRepository = getRepository(NicknameHistoryEntry);
|
||||
const dateThreshold = moment
|
||||
.utc()
|
||||
.subtract(NICKNAME_RETENTION_PERIOD, "ms")
|
||||
.format(DBDateFormat);
|
||||
const dateThreshold = moment.utc().subtract(NICKNAME_RETENTION_PERIOD, "ms").format(DBDateFormat);
|
||||
|
||||
// Clean old nicknames (NICKNAME_RETENTION_PERIOD)
|
||||
let rows;
|
||||
|
@ -31,7 +28,7 @@ export async function cleanupNicknames(): Promise<number> {
|
|||
|
||||
if (rows.length > 0) {
|
||||
await nicknameHistoryRepository.delete({
|
||||
id: In(rows.map(r => r.id)),
|
||||
id: In(rows.map((r) => r.id)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,7 @@ export async function cleanupUsernames(): Promise<number> {
|
|||
let cleaned = 0;
|
||||
|
||||
const usernameHistoryRepository = getRepository(UsernameHistoryEntry);
|
||||
const dateThreshold = moment
|
||||
.utc()
|
||||
.subtract(USERNAME_RETENTION_PERIOD, "ms")
|
||||
.format(DBDateFormat);
|
||||
const dateThreshold = moment.utc().subtract(USERNAME_RETENTION_PERIOD, "ms").format(DBDateFormat);
|
||||
|
||||
// Clean old usernames (USERNAME_RETENTION_PERIOD)
|
||||
let rows;
|
||||
|
@ -31,7 +28,7 @@ export async function cleanupUsernames(): Promise<number> {
|
|||
|
||||
if (rows.length > 0) {
|
||||
await usernameHistoryRepository.delete({
|
||||
id: In(rows.map(r => r.id)),
|
||||
id: In(rows.map((r) => r.id)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ export let connection: Connection;
|
|||
|
||||
export function connect() {
|
||||
if (!connectionPromise) {
|
||||
connectionPromise = createConnection().then(newConnection => {
|
||||
connectionPromise = createConnection().then((newConnection) => {
|
||||
// Verify the DB timezone is set to UTC
|
||||
return newConnection.query("SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP) AS tz").then(r => {
|
||||
return newConnection.query("SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP) AS tz").then((r) => {
|
||||
if (r[0].tz !== "00:00:00") {
|
||||
throw new SimpleError(`Database timezone must be UTC (detected ${r[0].tz})`);
|
||||
}
|
||||
|
|
|
@ -19,10 +19,7 @@ export class ApiLogin {
|
|||
@Column()
|
||||
expires_at: string;
|
||||
|
||||
@ManyToOne(
|
||||
type => ApiUserInfo,
|
||||
userInfo => userInfo.logins,
|
||||
)
|
||||
@ManyToOne((type) => ApiUserInfo, (userInfo) => userInfo.logins)
|
||||
@JoinColumn({ name: "user_id" })
|
||||
userInfo: ApiUserInfo;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,7 @@ export class ApiPermissionAssignment {
|
|||
@Column({ type: String, nullable: true })
|
||||
expires_at: string | null;
|
||||
|
||||
@ManyToOne(
|
||||
type => ApiUserInfo,
|
||||
userInfo => userInfo.permissionAssignments,
|
||||
)
|
||||
@ManyToOne((type) => ApiUserInfo, (userInfo) => userInfo.permissionAssignments)
|
||||
@JoinColumn({ name: "target_id" })
|
||||
userInfo: ApiUserInfo;
|
||||
}
|
||||
|
|
|
@ -20,15 +20,9 @@ export class ApiUserInfo {
|
|||
@Column()
|
||||
updated_at: string;
|
||||
|
||||
@OneToMany(
|
||||
type => ApiLogin,
|
||||
login => login.userInfo,
|
||||
)
|
||||
@OneToMany((type) => ApiLogin, (login) => login.userInfo)
|
||||
logins: ApiLogin[];
|
||||
|
||||
@OneToMany(
|
||||
type => ApiPermissionAssignment,
|
||||
p => p.userInfo,
|
||||
)
|
||||
@OneToMany((type) => ApiPermissionAssignment, (p) => p.userInfo)
|
||||
permissionAssignments: ApiPermissionAssignment[];
|
||||
}
|
||||
|
|
|
@ -35,9 +35,6 @@ export class Case {
|
|||
*/
|
||||
@Column({ type: String, nullable: true }) log_message_id: string | null;
|
||||
|
||||
@OneToMany(
|
||||
type => CaseNote,
|
||||
note => note.case,
|
||||
)
|
||||
@OneToMany((type) => CaseNote, (note) => note.case)
|
||||
notes: CaseNote[];
|
||||
}
|
||||
|
|
|
@ -15,10 +15,7 @@ export class CaseNote {
|
|||
|
||||
@Column() created_at: string;
|
||||
|
||||
@ManyToOne(
|
||||
type => Case,
|
||||
theCase => theCase.notes,
|
||||
)
|
||||
@ManyToOne((type) => Case, (theCase) => theCase.notes)
|
||||
@JoinColumn({ name: "case_id" })
|
||||
case: Case;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class Config {
|
|||
@Column()
|
||||
edited_at: string;
|
||||
|
||||
@ManyToOne(type => ApiUserInfo)
|
||||
@ManyToOne((type) => ApiUserInfo)
|
||||
@JoinColumn({ name: "edited_by" })
|
||||
userInfo: ApiUserInfo;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export class StarboardMessage {
|
|||
@Column()
|
||||
guild_id: string;
|
||||
|
||||
@OneToOne(type => SavedMessage)
|
||||
@OneToOne((type) => SavedMessage)
|
||||
@JoinColumn({ name: "message_id" })
|
||||
message: SavedMessage;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export class StarboardReaction {
|
|||
@Column()
|
||||
reactor_id: string;
|
||||
|
||||
@OneToOne(type => SavedMessage)
|
||||
@OneToOne((type) => SavedMessage)
|
||||
@JoinColumn({ name: "message_id" })
|
||||
message: SavedMessage;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue