mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-12-26 08:25:14 +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") {
|
||||
const chats = await Chat.findAll({
|
||||
const chats = await ChatAssociation.findAll({
|
||||
where: {
|
||||
userId: req.user.id,
|
||||
type: "direct"
|
||||
userId: req.user.id
|
||||
},
|
||||
include: [
|
||||
{
|
||||
model: ChatAssociation,
|
||||
as: "associations"
|
||||
model: Chat,
|
||||
as: "chat",
|
||||
where: {
|
||||
type: "direct"
|
||||
},
|
||||
include: [
|
||||
{
|
||||
model: User,
|
||||
as: "users"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
const chat = chats.find((chat) => {
|
||||
return chat.associations.find((association) => {
|
||||
return association.userId === req.body.users[0]
|
||||
})
|
||||
const users = chat.chat.users.map((user) => user.id)
|
||||
return users.includes(req.body.users[0]) && users.includes(req.user.id)
|
||||
})
|
||||
if (chat) {
|
||||
res.json({
|
||||
...chat.associations.find((association) => {
|
||||
return association.userId === req.user.id
|
||||
}).dataValues,
|
||||
...chat.dataValues,
|
||||
existing: true
|
||||
})
|
||||
return
|
||||
|
|
|
@ -953,6 +953,10 @@ export default {
|
|||
this.searchUsers()
|
||||
this.searchUsersForGroupAdmin()
|
||||
})
|
||||
this.$socket.on("siteState", () => {
|
||||
this.searchUsers()
|
||||
this.searchUsersForGroupAdmin()
|
||||
})
|
||||
this.$socket.on("userSettings", () => {
|
||||
this.$store.dispatch("getChats")
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue