mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-11-22 11:17:56 +11:00
parent
853ea645a8
commit
88012b1930
3 changed files with 39 additions and 2 deletions
|
@ -65,7 +65,7 @@ router.delete("/:id/:associationId", auth, async (req, res, next) => {
|
||||||
if (!association) {
|
if (!association) {
|
||||||
throw Errors.chatNotFoundOrNotAdmin
|
throw Errors.chatNotFoundOrNotAdmin
|
||||||
}
|
}
|
||||||
if (association.chat) await association.destroy()
|
await association.destroy()
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
const message = await Message.create({
|
const message = await Message.create({
|
||||||
userId: 0,
|
userId: 0,
|
||||||
|
@ -169,6 +169,9 @@ router.delete("/:id/:associationId", auth, async (req, res, next) => {
|
||||||
associationId: association.id,
|
associationId: association.id,
|
||||||
keyId: `${message.id}-${message.updatedAt.toISOString()}`
|
keyId: `${message.id}-${message.updatedAt.toISOString()}`
|
||||||
})
|
})
|
||||||
|
io.to(association.userId).emit("memberListUpdate", {
|
||||||
|
chatId: chat.chatId
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
next(err)
|
next(err)
|
||||||
|
@ -215,6 +218,31 @@ router.put("/:id/:associationId", auth, async (req, res, next) => {
|
||||||
rank: req.body.rank
|
rank: req.body.rank
|
||||||
})
|
})
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
|
const io = req.app.get("io")
|
||||||
|
const associations = await ChatAssociation.findAll({
|
||||||
|
where: {
|
||||||
|
chatId: chat.chat.id
|
||||||
|
},
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: User,
|
||||||
|
as: "user",
|
||||||
|
attributes: [
|
||||||
|
"username",
|
||||||
|
"name",
|
||||||
|
"avatar",
|
||||||
|
"id",
|
||||||
|
"createdAt",
|
||||||
|
"updatedAt"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
associations.forEach((association) => {
|
||||||
|
io.to(association.userId).emit("memberListUpdate", {
|
||||||
|
chatId: chat.chatId
|
||||||
|
})
|
||||||
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
next(err)
|
next(err)
|
||||||
}
|
}
|
||||||
|
@ -427,6 +455,9 @@ router.post("/:id", auth, async (req, res, next) => {
|
||||||
associationId: association.id,
|
associationId: association.id,
|
||||||
keyId: `${message.id}-${message.updatedAt.toISOString()}`
|
keyId: `${message.id}-${message.updatedAt.toISOString()}`
|
||||||
})
|
})
|
||||||
|
io.to(association.userId).emit("memberListUpdate", {
|
||||||
|
chatId: chat.chatId
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res.sendStatus(204)
|
res.sendStatus(204)
|
||||||
|
@ -561,6 +592,9 @@ router.delete("/:id", auth, async (req, res, next) => {
|
||||||
associationId: association.id,
|
associationId: association.id,
|
||||||
keyId: `${message.id}-${message.updatedAt.toISOString()}`
|
keyId: `${message.id}-${message.updatedAt.toISOString()}`
|
||||||
})
|
})
|
||||||
|
io.to(association.userId).emit("memberListUpdate", {
|
||||||
|
chatId: chat.chatId
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
throw Errors.invalidParameter("chat association id")
|
throw Errors.invalidParameter("chat association id")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "colubrina",
|
"name": "colubrina",
|
||||||
"version": "1.0.28",
|
"version": "1.0.29",
|
||||||
"description": "Simple instant communication.",
|
"description": "Simple instant communication.",
|
||||||
"private": true,
|
"private": true,
|
||||||
"author": "Troplo <troplo@troplo.com>",
|
"author": "Troplo <troplo@troplo.com>",
|
||||||
|
|
|
@ -24,6 +24,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$socket.on("memberListUpdate", () => {
|
||||||
|
this.$store.dispatch("getChats")
|
||||||
|
})
|
||||||
if (!this.$route.params.id) {
|
if (!this.$route.params.id) {
|
||||||
this.$router.push("/communications/friends")
|
this.$router.push("/communications/friends")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue