mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-11-23 03:36:42 +11:00
1.0.4
This commit is contained in:
parent
34bd37c5b5
commit
3562843c10
6 changed files with 28 additions and 14 deletions
|
@ -41,8 +41,8 @@ module.exports = (sequelize, DataTypes) => {
|
||||||
msg: "Username is required"
|
msg: "Username is required"
|
||||||
},
|
},
|
||||||
len: {
|
len: {
|
||||||
args: [2, 12],
|
args: [2, 16],
|
||||||
msg: "Username must be between 2 and 12 characters"
|
msg: "Username must be between 2 and 16 characters"
|
||||||
},
|
},
|
||||||
regex: {
|
regex: {
|
||||||
args: /^[a-z0-9_-]+$/i,
|
args: /^[a-z0-9_-]+$/i,
|
||||||
|
|
|
@ -378,6 +378,10 @@ router.delete(
|
||||||
chatId: chat.chat.id
|
chatId: chat.chat.id
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
|
{
|
||||||
|
model: Chat,
|
||||||
|
as: "chat"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
model: User,
|
model: User,
|
||||||
as: "user",
|
as: "user",
|
||||||
|
@ -391,6 +395,9 @@ router.delete(
|
||||||
if (!association) {
|
if (!association) {
|
||||||
throw Errors.chatNotFoundOrNotAdmin
|
throw Errors.chatNotFoundOrNotAdmin
|
||||||
}
|
}
|
||||||
|
if(association.chat.type === "direct") {
|
||||||
|
throw Errors.invalidParameter("association id", "You cannot leave direct messages")
|
||||||
|
}
|
||||||
await association.destroy()
|
await association.destroy()
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
const message = await Message.create({
|
const message = await Message.create({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "colubrina-chat",
|
"name": "colubrina-chat",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"author": "Troplo <troplo@troplo.com>",
|
"author": "Troplo <troplo@troplo.com>",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
|
@ -534,7 +534,7 @@ export default {
|
||||||
).unread += 1
|
).unread += 1
|
||||||
if (
|
if (
|
||||||
(message.userId !== this.$store.state.user.id &&
|
(message.userId !== this.$store.state.user.id &&
|
||||||
this.$route.params?.id !== message.associationId &&
|
parseInt(this.$route.params?.id) !== message.associationId &&
|
||||||
this.$store.state.user?.storedStatus !== "busy") ||
|
this.$store.state.user?.storedStatus !== "busy") ||
|
||||||
(message.userId !== this.$store.state.user.id &&
|
(message.userId !== this.$store.state.user.id &&
|
||||||
this.$store.state.user?.storedStatus !== "busy" &&
|
this.$store.state.user?.storedStatus !== "busy" &&
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
outlined
|
outlined
|
||||||
append-outer-icon="mdi-send"
|
append-outer-icon="mdi-send"
|
||||||
auto-grow
|
auto-grow
|
||||||
@keyup.up="editLastMessage"
|
@keyup.up="handleEditMessage"
|
||||||
@keyup.esc="handleEsc"
|
@keyup.esc="handleEsc"
|
||||||
@click:append-outer="handleMessage()"
|
@click:append-outer="handleMessage()"
|
||||||
@keydown.enter.exact.prevent="handleMessage()"
|
@keydown.enter.exact.prevent="handleMessage()"
|
||||||
|
@ -111,6 +111,11 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleEditMessage() {
|
||||||
|
if(!this.message?.length) {
|
||||||
|
this.editLastMessage()
|
||||||
|
}
|
||||||
|
},
|
||||||
handleMessage() {
|
handleMessage() {
|
||||||
if (this.edit) {
|
if (this.edit) {
|
||||||
this.editMessage()
|
this.editMessage()
|
||||||
|
@ -134,7 +139,6 @@ export default {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.edit.editing = false
|
this.edit.editing = false
|
||||||
this.edit.id = null
|
this.edit.id = null
|
||||||
this.edit.content = ""
|
|
||||||
this.focusInput()
|
this.focusInput()
|
||||||
this.endEdit()
|
this.endEdit()
|
||||||
// response will be handled via WebSocket
|
// response will be handled via WebSocket
|
||||||
|
@ -234,7 +238,6 @@ export default {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.focusInput()
|
this.focusInput()
|
||||||
this.message = ""
|
|
||||||
this.autoScroll()
|
this.autoScroll()
|
||||||
this.endSend()
|
this.endSend()
|
||||||
})
|
})
|
||||||
|
@ -264,7 +267,6 @@ export default {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.focusInput()
|
this.focusInput()
|
||||||
this.message = ""
|
|
||||||
this.autoScroll()
|
this.autoScroll()
|
||||||
this.endSend()
|
this.endSend()
|
||||||
this.file = null
|
this.file = null
|
||||||
|
|
|
@ -26,10 +26,7 @@
|
||||||
<v-list-item-title>Group Settings</v-list-item-title>
|
<v-list-item-title>Group Settings</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
@click="
|
@click="groupLeave(context.user.id)"
|
||||||
leave.item = context.user.item
|
|
||||||
leave.dialog = true
|
|
||||||
"
|
|
||||||
color="error"
|
color="error"
|
||||||
>
|
>
|
||||||
<v-list-item-title>Leave Group</v-list-item-title>
|
<v-list-item-title>Leave Group</v-list-item-title>
|
||||||
|
@ -679,6 +676,12 @@ export default {
|
||||||
)
|
)
|
||||||
this.settings.dialog = true
|
this.settings.dialog = true
|
||||||
},
|
},
|
||||||
|
groupLeave(id) {
|
||||||
|
this.leave.item = this.$store.state.chats.find(
|
||||||
|
(chat) => chat.id === id
|
||||||
|
)
|
||||||
|
this.leave.dialog = true
|
||||||
|
},
|
||||||
show(e, context, item, id) {
|
show(e, context, item, id) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.context[context].value = false
|
this.context[context].value = false
|
||||||
|
@ -817,9 +820,11 @@ export default {
|
||||||
.delete("/api/v1/communications/association/" + this.leave.item.id)
|
.delete("/api/v1/communications/association/" + this.leave.item.id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.leave.dialog = false
|
this.leave.dialog = false
|
||||||
|
this.$store.state.chats = this.$store.state.chats.filter(
|
||||||
|
(chat) => chat.id !== this.leave.item.id
|
||||||
|
)
|
||||||
|
this.$router.push("/communications/friends")
|
||||||
this.leave.item = null
|
this.leave.item = null
|
||||||
this.getChats()
|
|
||||||
this.$router.push("/communications/home")
|
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
AjaxErrorHandler(this.$store)(e)
|
AjaxErrorHandler(this.$store)(e)
|
||||||
|
|
Loading…
Reference in a new issue