From 9e1c1f993f472b9fecbe79f3d53cf1f43660a71c Mon Sep 17 00:00:00 2001 From: Troplo Date: Thu, 3 Nov 2022 18:30:37 +1100 Subject: [PATCH] 1.0.34 --- backend/lib/errors.js | 9 +++++++++ backend/routes/associations.js | 4 ++-- backend/routes/communications.js | 8 ++++---- frontend/package.json | 4 ++-- frontend/src/App.vue | 5 ++++- frontend/src/components/CommsInput.vue | 2 +- frontend/src/components/DevOverlay.vue | 2 +- frontend/src/components/Header.vue | 9 ++------- frontend/src/components/Message.vue | 2 +- frontend/src/components/NicknameDialog.vue | 2 +- frontend/src/components/Poll.vue | 2 +- frontend/src/components/UserDialog.vue | 2 +- frontend/src/main.js | 2 +- frontend/src/store/index.js | 2 +- frontend/src/views/Admin/Admin.vue | 2 +- frontend/src/views/Admin/AdminLogs.vue | 2 +- frontend/src/views/Admin/AdminState.vue | 2 +- frontend/src/views/Admin/AdminThemes.vue | 2 +- frontend/src/views/Admin/AdminUsers.vue | 2 +- .../src/views/Communications/CommunicationsFriends.vue | 2 +- frontend/src/views/Email/EmailConfirm.vue | 2 +- frontend/src/views/Email/EmailVerify.vue | 2 +- frontend/src/views/Login.vue | 2 +- frontend/src/views/Register.vue | 2 +- frontend/src/views/Settings/SettingsAppearance.vue | 2 +- frontend/src/views/Settings/SettingsSecurity.vue | 3 ++- frontend/src/views/Settings/SettingsSessions.vue | 2 +- frontend/src/views/Settings/SettingsSite.vue | 2 +- 28 files changed, 46 insertions(+), 38 deletions(-) diff --git a/backend/lib/errors.js b/backend/lib/errors.js index 5f472ba..27b60e1 100644 --- a/backend/lib/errors.js +++ b/backend/lib/errors.js @@ -89,6 +89,15 @@ ProcessedErrors.invalidParameter = function (param, message) { } } +ProcessedErrors.customMessage = function (param) { + return { + name: "customMessage", + message: `${param}`, + status: 400, + parameter: param + } +} + ProcessedErrors.sequelizeValidation = (sequelize, obj) => { return new sequelize.ValidationError(obj.error, [ new sequelize.ValidationErrorItem( diff --git a/backend/routes/associations.js b/backend/routes/associations.js index bacaaf1..c1a7f66 100644 --- a/backend/routes/associations.js +++ b/backend/routes/associations.js @@ -62,8 +62,8 @@ router.delete("/:id/:associationId", auth, async (req, res, next) => { if (!chat) { throw Errors.chatNotFoundOrNotAdmin } - if (!association) { - throw Errors.chatNotFoundOrNotAdmin + if (association?.rank === "admin" || !association) { + throw Errors.customMessage("User is admin and cannot be removed.") } await association.destroy() res.sendStatus(204) diff --git a/backend/routes/communications.js b/backend/routes/communications.js index e40b8c0..91b27f5 100644 --- a/backend/routes/communications.js +++ b/backend/routes/communications.js @@ -1038,8 +1038,8 @@ router.post( async (req, res, next) => { try { const io = req.app.get("io") - if (req.body.message.length > 999) { - throw Errors.invalidParameter("message", "Maximum length is 1000") + if (req.body.message.length > 1999 && !req.user.admin) { + throw Errors.invalidParameter("message", "Maximum length is 2000") } const chat = await ChatAssociation.findOne({ where: { @@ -1309,8 +1309,8 @@ router.post("/:id/message", auth, limiter, async (req, res, next) => { if (!req.body.message.length) { throw Errors.invalidParameter("message") } - if (req.body.message.length > 999) { - throw Errors.invalidParameter("message", "Maximum length is 1000") + if (req.body.message.length > 1999 && !req.user.admin) { + throw Errors.invalidParameter("message", "Maximum length is 2000") } const chat = await ChatAssociation.findOne({ where: { diff --git a/frontend/package.json b/frontend/package.json index f6dd600..21f2b82 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "colubrina", - "version": "1.0.33", + "version": "1.0.34", "description": "Simple instant communication.", "private": true, "author": "Troplo ", @@ -13,7 +13,7 @@ "postinstall": "patch-package && electron-builder install-app-deps", "postuninstall": "electron-builder install-app-deps" }, - "main": "./dist_electron/bundled/background.js", + "main": "background.js", "repository": "https://github.com/Troplo/Colubrina", "dependencies": { "@babel/preset-env": "^7.17.10", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index c838a06..d0e2ffb 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -5,6 +5,9 @@ $vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].bg " > + + + @@ -452,7 +455,7 @@