Fix everything (db/encryption, logging etc)

This commit is contained in:
Isaac
2022-07-17 23:01:00 +01:00
parent 24d5e6d99d
commit 4a48ba635a
6 changed files with 61 additions and 43 deletions

View File

@@ -60,40 +60,36 @@ async function logAdminEvent(client, {
};
const channel = client.channels.cache.get(settings.logChannel);
if (!channel) return;
const embeds = [
new MessageEmbed()
.setColor('ORANGE')
.setAuthor({
iconURL: user.avatarURL(),
name: user.username,
})
.setTitle(getMessage('log.admin.title.joined', {
...i18nOptions,
targetType: getMessage(`log.admin.title.target.${target.type}`),
verb: getMessage(`log.admin.verb.${action}`),
}))
.setDescription(getMessage('log.admin.description.joined', {
...i18nOptions,
targetType: getMessage(`log.admin.description.target.${target.type}`),
verb: getMessage(`log.admin.verb.${action}`),
}))
.addField(getMessage(`log.admin.title.target.${target.type}`), target.name ?? target.id),
];
return await channel.send({
embeds: [
if (diff && diff.original) {
embeds.push(
new MessageEmbed()
.setColor('ORANGE')
.setAuthor({
iconURL: user.avatarURL(),
name: user.username,
})
.setTitle(getMessage('log.admin.title.joined', {
...i18nOptions,
targetType: getMessage(`log.admin.title.target.${target.type}`),
verb: getMessage(`log.admin.verb.${action}`),
}))
.setDescription(getMessage('log.admin.description.joined', {
...i18nOptions,
targetType: getMessage(`log.admin.description.target.${target.type}`),
verb: getMessage(`log.admin.verb.${action}`),
}))
.addField(getMessage(`log.admin.title.target.${target.type}`), target.name ?? target.id),
// .setFooter({
// iconURL: client.guilds.cache.get(guildId).iconURL(),
// text: settings.footer,
// }),
...[
diff?.original &&
new MessageEmbed()
.setColor('ORANGE')
.setTitle(getMessage('log.admin.changes.title'))
.setDescription(getMessage('log.admin.changes.description'))
.setFields(makeDiff(diff)),
],
],
});
.setTitle(getMessage('log.admin.changes'))
.setFields(makeDiff(diff)),
);
}
return await channel.send({ embeds });
}
module.exports = {

View File

@@ -17,7 +17,7 @@ const fields = [
'regex',
];
const shouldEncrypt = ['create', 'createMany', 'update', 'updateMany', 'upsert'];
const shouldDecrypt = ['findUnique', 'findFirst', 'findMany'];
// const shouldDecrypt = ['findUnique', 'findFirst', 'findMany'];
@@ -62,7 +62,8 @@ module.exports = log => {
return async (params, next) => {
if (params.args.data && shouldEncrypt.includes(params.action)) params.args = encrypt(params.args);
let result = await next(params);
if (result && shouldDecrypt.includes(params.action)) result = decrypt(result);
// if (result && shouldDecrypt.includes(params.action)) result = decrypt(result);
if (result) result = decrypt(result);
return result;
};
};