This commit is contained in:
Troplo 2022-11-03 18:30:37 +11:00
parent fa26fafcde
commit 9e1c1f993f
28 changed files with 46 additions and 38 deletions

View file

@ -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(

View file

@ -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)

View file

@ -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: {

View file

@ -1,6 +1,6 @@
{
"name": "colubrina",
"version": "1.0.33",
"version": "1.0.34",
"description": "Simple instant communication.",
"private": true,
"author": "Troplo <troplo@troplo.com>",
@ -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",

View file

@ -5,6 +5,9 @@
$vuetify.theme.themes[$vuetify.theme.dark ? 'dark' : 'light'].bg
"
>
<v-overlay :value="!$store.state.wsConnected" absolute style="z-index: 69">
<v-progress-circular indeterminate size="64"></v-progress-circular>
</v-overlay>
<DevOverlay v-if="$store.state.site.release === 'dev'"></DevOverlay>
<v-overlay :value="$store.state.site.loading">
<v-progress-circular indeterminate size="64"></v-progress-circular>
@ -452,7 +455,7 @@
</template>
<style></style>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
import { VueFinalModal } from "vue-final-modal"
import Header from "@/components/Header"
import DevOverlay from "@/components/DevOverlay"

View file

@ -248,7 +248,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
import twemoji from "twemoji"
const emojis = require("../lib/emojis.json")

View file

@ -15,7 +15,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "DevOverlay",
data() {

View file

@ -1,8 +1,5 @@
<template>
<div v-if="$store.state.user.username">
<v-overlay :value="!$store.state.wsConnected" absolute>
<v-progress-circular indeterminate size="64"></v-progress-circular>
</v-overlay>
<NicknameDialog :nickname="nickname" />
<v-menu
v-model="context.user.value"
@ -687,6 +684,7 @@
style="margin-bottom: -18px"
elevation="2"
v-model="search"
autocomplete="none"
></v-text-field>
<v-toolbar color="sheet" class="rounded-xl mb-3" elevation="2">
<v-toolbar-title class="subtitle-1">
@ -777,9 +775,6 @@
<template v-slot:append>
<v-card tile color="bg" elevation="0">
<v-divider></v-divider>
<v-overlay :value="!$store.state.wsConnected" absolute>
<v-progress-circular indeterminate size="48"></v-progress-circular>
</v-overlay>
<v-list-item>
<v-menu top offset-y>
<template v-slot:activator="{ on, attrs }">
@ -876,7 +871,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
import NicknameDialog from "@/components/NicknameDialog"
import Vue from "vue"

View file

@ -383,7 +383,7 @@
<script>
import Embed from "./Embed.vue"
import CommsInput from "./CommsInput.vue"
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
import Poll from "@/components/Poll"
export default {

View file

@ -35,7 +35,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "NicknameDialog",

View file

@ -48,7 +48,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "Poll",

View file

@ -134,7 +134,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "UserDialog",

View file

@ -28,7 +28,7 @@ const md = require("markdown-it")({
highlight: function (/*str, lang*/) {
return ""
}
}).disable(["image", "autolink"])
}).disable(["image", "autolink", "list"])
const emoji = require("markdown-it-emoji")
const defaultRender =
md.renderer.rules.link_open ||

View file

@ -1,7 +1,7 @@
import Vue from "vue"
import Vuex from "vuex"
import Vuetify from "../plugins/vuetify"
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
Vue.use(Vuex)
function getDirectRecipient(context, item) {

View file

@ -37,7 +37,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "Admin",

View file

@ -3,7 +3,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "AdminLogs",

View file

@ -47,7 +47,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "AdminState",
data() {

View file

@ -27,7 +27,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "AdminThemes",

View file

@ -69,7 +69,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "AdminUsers",

View file

@ -267,7 +267,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "CommunicationsFriends",

View file

@ -30,7 +30,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "EmailConfirm",

View file

@ -21,7 +21,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "EmailVerify",

View file

@ -109,7 +109,7 @@
<script>
import Vue from "vue"
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "Login",

View file

@ -129,7 +129,7 @@
<script>
import Vue from "vue"
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "Login",

View file

@ -139,7 +139,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "SettingsAppearance",

View file

@ -18,6 +18,7 @@
v-model="totp.password"
color="white"
@keydown.enter="totpEnable"
autocomplete="false"
>
</v-text-field>
<v-btn @click="totpEnable" text>Proceed</v-btn>
@ -96,7 +97,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "SettingsSecurity",

View file

@ -43,7 +43,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "SettingsSessions",

View file

@ -95,7 +95,7 @@
</template>
<script>
import AjaxErrorHandler from "@/lib/errorHandler"
import AjaxErrorHandler from "@/lib/errorHandler.js"
export default {
name: "SettingsSite",