Expanded edit fields. Added revision history to scene and user pages.

This commit is contained in:
2024-10-06 02:45:56 +02:00
parent 8bf9e22b39
commit 8f843f321d
57 changed files with 1664 additions and 156 deletions

View File

@@ -1,3 +1,4 @@
import config from 'config';
import { parse } from 'yaml';
import { knexOwner as knex } from './knex.js';
@@ -128,3 +129,22 @@ export async function removeTemplate(templateId, reqUser) {
.where('user_id', reqUser.id)
.delete();
}
export async function createBan(ban, reqUser) {
console.log(ban);
if (reqUser.role !== 'admin') {
throw new HttpError('You do not have sufficient privileges to set a ban', 403);
}
const targetUser = ban.userId && await knex('users').where('id', ban.userId).first();
const curatedBan = {
user_id: ban.userId,
username: ban.username,
ip: ban.banIp && targetUser.last_ip,
expires_at: knex.raw('now() + make_interval(mins => :minutes)', { minutes: config.bans.defaultExpiry }),
};
await knex('bans').insert(curatedBan);
}