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) => { ProcessedErrors.sequelizeValidation = (sequelize, obj) => {
return new sequelize.ValidationError(obj.error, [ return new sequelize.ValidationError(obj.error, [
new sequelize.ValidationErrorItem( new sequelize.ValidationErrorItem(

View file

@ -62,8 +62,8 @@ router.delete("/:id/:associationId", auth, async (req, res, next) => {
if (!chat) { if (!chat) {
throw Errors.chatNotFoundOrNotAdmin throw Errors.chatNotFoundOrNotAdmin
} }
if (!association) { if (association?.rank === "admin" || !association) {
throw Errors.chatNotFoundOrNotAdmin throw Errors.customMessage("User is admin and cannot be removed.")
} }
await association.destroy() await association.destroy()
res.sendStatus(204) res.sendStatus(204)

View file

@ -1038,8 +1038,8 @@ router.post(
async (req, res, next) => { async (req, res, next) => {
try { try {
const io = req.app.get("io") const io = req.app.get("io")
if (req.body.message.length > 999) { if (req.body.message.length > 1999 && !req.user.admin) {
throw Errors.invalidParameter("message", "Maximum length is 1000") throw Errors.invalidParameter("message", "Maximum length is 2000")
} }
const chat = await ChatAssociation.findOne({ const chat = await ChatAssociation.findOne({
where: { where: {
@ -1309,8 +1309,8 @@ router.post("/:id/message", auth, limiter, async (req, res, next) => {
if (!req.body.message.length) { if (!req.body.message.length) {
throw Errors.invalidParameter("message") throw Errors.invalidParameter("message")
} }
if (req.body.message.length > 999) { if (req.body.message.length > 1999 && !req.user.admin) {
throw Errors.invalidParameter("message", "Maximum length is 1000") throw Errors.invalidParameter("message", "Maximum length is 2000")
} }
const chat = await ChatAssociation.findOne({ const chat = await ChatAssociation.findOne({
where: { where: {

View file

@ -1,6 +1,6 @@
{ {
"name": "colubrina", "name": "colubrina",
"version": "1.0.33", "version": "1.0.34",
"description": "Simple instant communication.", "description": "Simple instant communication.",
"private": true, "private": true,
"author": "Troplo <troplo@troplo.com>", "author": "Troplo <troplo@troplo.com>",
@ -13,7 +13,7 @@
"postinstall": "patch-package && electron-builder install-app-deps", "postinstall": "patch-package && electron-builder install-app-deps",
"postuninstall": "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", "repository": "https://github.com/Troplo/Colubrina",
"dependencies": { "dependencies": {
"@babel/preset-env": "^7.17.10", "@babel/preset-env": "^7.17.10",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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