mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
fix room properties
This commit is contained in:
parent
d548fc2b84
commit
8b037ffa73
@ -1,20 +1,24 @@
|
|||||||
|
import { v4 as uuid } from 'uuid'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
CreateRoom: async (_parent, params, context, _resolveInfo) => {
|
CreateRoom: async (_parent, params, context, _resolveInfo) => {
|
||||||
const { userId } = params
|
const { userId } = params
|
||||||
const { user: { id: currentUserId } } = context
|
const { user: { id: currentUserId } } = context
|
||||||
|
const roomId = uuid()
|
||||||
const session = context.driver.session()
|
const session = context.driver.session()
|
||||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||||
const createRoomCypher = `
|
const createRoomCypher = `
|
||||||
MATCH (currentUser:User { id: $currentUserId })
|
MATCH (currentUser:User { id: $currentUserId })
|
||||||
MATCH (user:User { id: $userId })
|
MATCH (user:User { id: $userId })
|
||||||
MERGE (currentUser)-[:CHATS_IN]->(room:Room)<-[:CHATS_IN]-(user)
|
MERGE (currentUser)-[:CHATS_IN]->(room:Room)<-[:CHATS_IN]-(user)
|
||||||
SET room.createdAt = toString(datetime())
|
SET room.createdAt = toString(datetime()),
|
||||||
RETURN room
|
room.id = $roomId
|
||||||
|
RETURN room { .* }
|
||||||
`
|
`
|
||||||
const createRommTxResponse = await await transaction.run(
|
const createRommTxResponse = await await transaction.run(
|
||||||
createRoomCypher,
|
createRoomCypher,
|
||||||
{ userId, currentUserId }
|
{ userId, currentUserId, roomId }
|
||||||
)
|
)
|
||||||
const [room] = await createRommTxResponse.records.map((record) =>
|
const [room] = await createRommTxResponse.records.map((record) =>
|
||||||
record.get('room'),
|
record.get('room'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user