mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-11-22 19:27:55 +11:00
fix
This commit is contained in:
parent
fd174f7355
commit
ad48cce336
2 changed files with 20 additions and 11 deletions
|
@ -1555,28 +1555,33 @@ router.post("/create", auth, async (req, res, next) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (type === "direct") {
|
if (type === "direct") {
|
||||||
const chats = await Chat.findAll({
|
const chats = await ChatAssociation.findAll({
|
||||||
where: {
|
where: {
|
||||||
userId: req.user.id,
|
userId: req.user.id
|
||||||
type: "direct"
|
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: ChatAssociation,
|
model: Chat,
|
||||||
as: "associations"
|
as: "chat",
|
||||||
|
where: {
|
||||||
|
type: "direct"
|
||||||
|
},
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: User,
|
||||||
|
as: "users"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
const chat = chats.find((chat) => {
|
const chat = chats.find((chat) => {
|
||||||
return chat.associations.find((association) => {
|
const users = chat.chat.users.map((user) => user.id)
|
||||||
return association.userId === req.body.users[0]
|
return users.includes(req.body.users[0]) && users.includes(req.user.id)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
if (chat) {
|
if (chat) {
|
||||||
res.json({
|
res.json({
|
||||||
...chat.associations.find((association) => {
|
...chat.dataValues,
|
||||||
return association.userId === req.user.id
|
|
||||||
}).dataValues,
|
|
||||||
existing: true
|
existing: true
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
|
|
@ -953,6 +953,10 @@ export default {
|
||||||
this.searchUsers()
|
this.searchUsers()
|
||||||
this.searchUsersForGroupAdmin()
|
this.searchUsersForGroupAdmin()
|
||||||
})
|
})
|
||||||
|
this.$socket.on("siteState", () => {
|
||||||
|
this.searchUsers()
|
||||||
|
this.searchUsersForGroupAdmin()
|
||||||
|
})
|
||||||
this.$socket.on("userSettings", () => {
|
this.$socket.on("userSettings", () => {
|
||||||
this.$store.dispatch("getChats")
|
this.$store.dispatch("getChats")
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue