mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Refactor decide mutation to new CaseFolder structure
This commit is contained in:
parent
7c3ec289f7
commit
cf02ca4506
@ -25,12 +25,12 @@ module.exports = {
|
|||||||
target: 'User',
|
target: 'User',
|
||||||
direction: 'in',
|
direction: 'in',
|
||||||
},
|
},
|
||||||
decidedByModerator: {
|
// Wolle reviewedByModerator: {
|
||||||
type: 'relationship',
|
// type: 'relationship',
|
||||||
relationship: 'DECIDED',
|
// relationship: 'DECIDED',
|
||||||
target: 'User',
|
// target: 'User',
|
||||||
direction: 'in',
|
// direction: 'in',
|
||||||
},
|
// },
|
||||||
notified: {
|
notified: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'NOTIFIED',
|
relationship: 'NOTIFIED',
|
||||||
|
|||||||
@ -17,12 +17,12 @@ module.exports = {
|
|||||||
image: { type: 'string', allow: [null] },
|
image: { type: 'string', allow: [null] },
|
||||||
deleted: { type: 'boolean', default: false },
|
deleted: { type: 'boolean', default: false },
|
||||||
disabled: { type: 'boolean', default: false },
|
disabled: { type: 'boolean', default: false },
|
||||||
decidedByModerator: {
|
// Wolle reviewedByModerator: {
|
||||||
type: 'relationship',
|
// type: 'relationship',
|
||||||
relationship: 'DECIDED',
|
// relationship: 'DECIDED',
|
||||||
target: 'User',
|
// target: 'User',
|
||||||
direction: 'in',
|
// direction: 'in',
|
||||||
},
|
// },
|
||||||
notified: {
|
notified: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'NOTIFIED',
|
relationship: 'NOTIFIED',
|
||||||
|
|||||||
@ -42,12 +42,12 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' },
|
friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' },
|
||||||
decidedByModerator: {
|
// Wolle reviewedByModerator: {
|
||||||
type: 'relationship',
|
// type: 'relationship',
|
||||||
relationship: 'DECIDED',
|
// relationship: 'DECIDED',
|
||||||
target: 'User',
|
// target: 'User',
|
||||||
direction: 'in',
|
// direction: 'in',
|
||||||
},
|
// },
|
||||||
rewarded: {
|
rewarded: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'REWARDED',
|
relationship: 'REWARDED',
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export default applyScalars(
|
|||||||
'SocialMedia',
|
'SocialMedia',
|
||||||
'NOTIFIED',
|
'NOTIFIED',
|
||||||
'REPORTED',
|
'REPORTED',
|
||||||
'DECIDED',
|
'REVIEWED',
|
||||||
'Donations',
|
'Donations',
|
||||||
],
|
],
|
||||||
// add 'User' here as soon as possible
|
// add 'User' here as soon as possible
|
||||||
@ -46,7 +46,7 @@ export default applyScalars(
|
|||||||
'EMOTED',
|
'EMOTED',
|
||||||
'NOTIFIED',
|
'NOTIFIED',
|
||||||
'REPORTED',
|
'REPORTED',
|
||||||
'DECIDED',
|
'REVIEWED',
|
||||||
'Donations',
|
'Donations',
|
||||||
],
|
],
|
||||||
// add 'User' here as soon as possible
|
// add 'User' here as soon as possible
|
||||||
|
|||||||
@ -69,8 +69,35 @@ export default {
|
|||||||
hasOne: {
|
hasOne: {
|
||||||
author: '<-[:WROTE]-(related:User)',
|
author: '<-[:WROTE]-(related:User)',
|
||||||
post: '-[:COMMENTS]->(related:Post)',
|
post: '-[:COMMENTS]->(related:Post)',
|
||||||
decidedByModerator: '<-[:DECIDED]-(related:User)',
|
// Wolle reviewedByModerator: '<-[:DECIDED]-(related:User)',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
// Wolle reviewedByModerator: async (parent, params, context, resolveInfo) => {
|
||||||
|
// console.log('reviewedByModerator !!!')
|
||||||
|
// console.log('reviewedByModerator !!!')
|
||||||
|
// console.log('reviewedByModerator !!!')
|
||||||
|
// console.log('reviewedByModerator !!!')
|
||||||
|
// console.log('reviewedByModerator !!!')
|
||||||
|
// if (typeof parent.reviewedByModerator !== 'undefined') return parent.reviewedByModerator
|
||||||
|
// // const { id } = parent
|
||||||
|
// // const statement = `
|
||||||
|
// // MATCH (p:Post {id: $id})-[:TAGGED|CATEGORIZED]->(categoryOrTag)<-[:TAGGED|CATEGORIZED]-(post:Post)
|
||||||
|
// // WHERE NOT post.deleted AND NOT post.disabled
|
||||||
|
// // RETURN DISTINCT post
|
||||||
|
// // LIMIT 10
|
||||||
|
// // `
|
||||||
|
// // let reviewedByModerator
|
||||||
|
// // const session = context.driver.session()
|
||||||
|
// // try {
|
||||||
|
// // const result = await session.run(statement, { id })
|
||||||
|
// // relatedContributions = result.records.map(r => r.get('post').properties)
|
||||||
|
// // } finally {
|
||||||
|
// // session.close()
|
||||||
|
// // }
|
||||||
|
// // return reviewedByModerator
|
||||||
|
// return {
|
||||||
|
// id: 'Hallo !!!'
|
||||||
|
// }
|
||||||
|
// },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,33 +1,32 @@
|
|||||||
import uuid from 'uuid/v4'
|
import uuid from 'uuid/v4'
|
||||||
import { undefinedToNullResolver } from './helpers/Resolver'
|
import { undefinedToNullResolver } from './helpers/Resolver'
|
||||||
|
|
||||||
const queryOpenDecisionWriteTransaction = (session, resourceId) => {
|
// const queryOpenDecisionWriteTransaction = (session, resourceId) => {
|
||||||
return session.writeTransaction(async txc => {
|
// return session.writeTransaction(async txc => {
|
||||||
const queryOpenDecisionTransactionResponse = await txc.run(
|
// const queryOpenDecisionTransactionResponse = await txc.run(
|
||||||
`
|
// `
|
||||||
//MATCH (moderator:User)-[decision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
// //MATCH (moderator:User)-[decision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
||||||
//WHERE resource:User OR resource:Comment OR resource:Post
|
// //WHERE resource:User OR resource:Comment OR resource:Post
|
||||||
//RETURN decision, moderator {.id} AS decisionModerator
|
// //RETURN decision, moderator {.id} AS decisionModerator
|
||||||
|
|
||||||
// Wolle only review on reported resources
|
// // Wolle only review on reported resources
|
||||||
|
|
||||||
MATCH (moderator:User)-[:REPORTED]->(caseFolder:CaseFolder {closed: false})-[:FLAGGED]->(resource {id: $resourceId})
|
// MATCH (caseModerator:User)-[:REPORTED]->(caseFolder:CaseFolder {closed: false})-[:FLAGGED]->(resource {id: $resourceId})
|
||||||
WHERE resource:User OR resource:Post OR resource:Comment
|
// WHERE resource:User OR resource:Post OR resource:Comment
|
||||||
RETURN caseFolder, moderator {.id} AS caseModerator
|
// RETURN caseFolder, caseModerator {.id}
|
||||||
`,
|
// `,
|
||||||
{ resourceId },
|
// { resourceId },
|
||||||
)
|
// )
|
||||||
return queryOpenDecisionTransactionResponse.records.map(record => ({
|
// return queryOpenDecisionTransactionResponse.records.map(record => ({
|
||||||
caseFolder: record.get('caseFolder'),
|
// caseFolder: record.get('caseFolder'),
|
||||||
caseModerator: record.get('caseModerator'),
|
// caseModerator: record.get('caseModerator'),
|
||||||
}))
|
// }))
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
decide: async (_object, params, context, _resolveInfo) => {
|
decide: async (_object, params, context, _resolveInfo) => {
|
||||||
let createdRelationshipWithNestedAttributes = null
|
|
||||||
// Wolle console.log('params: ', params)
|
// Wolle console.log('params: ', params)
|
||||||
const { resourceId } = params
|
const { resourceId } = params
|
||||||
// Wolle console.log('resourceId: ', resourceId)
|
// Wolle console.log('resourceId: ', resourceId)
|
||||||
@ -35,101 +34,161 @@ export default {
|
|||||||
// Wolle console.log('disable: ', disable)
|
// Wolle console.log('disable: ', disable)
|
||||||
const { user: moderator, driver } = context
|
const { user: moderator, driver } = context
|
||||||
|
|
||||||
|
let createdRelationshipWithNestedAttributes = null // return value
|
||||||
|
|
||||||
const session = driver.session()
|
const session = driver.session()
|
||||||
try {
|
try {
|
||||||
const queryOpenDecisionWriteTxResultPromise = queryOpenDecisionWriteTransaction(
|
// const queryOpenDecisionWriteTxResultPromise = queryOpenDecisionWriteTransaction(
|
||||||
session,
|
// session,
|
||||||
resourceId,
|
// resourceId,
|
||||||
)
|
// )
|
||||||
const [openDecisionTxResult] = await queryOpenDecisionWriteTxResultPromise
|
// console.log('queryOpenDecisionWriteTxResultPromise: ', queryOpenDecisionWriteTxResultPromise)
|
||||||
|
// console.log('queryOpenDecisionWriteTxResultPromise: ', queryOpenDecisionWriteTxResultPromise)
|
||||||
|
// console.log('queryOpenDecisionWriteTxResultPromise: ', queryOpenDecisionWriteTxResultPromise)
|
||||||
|
// console.log('queryOpenDecisionWriteTxResultPromise: ', queryOpenDecisionWriteTxResultPromise)
|
||||||
|
// console.log('queryOpenDecisionWriteTxResultPromise: ', queryOpenDecisionWriteTxResultPromise)
|
||||||
|
// const [openDecisionTxResult] = await queryOpenDecisionWriteTxResultPromise
|
||||||
|
|
||||||
let cypherHeader = ''
|
// let cypherHeader = ''
|
||||||
|
|
||||||
if (!openDecisionTxResult) {
|
// // Wolle openDecisionTxResult should not be undefined !!!
|
||||||
// no open caseFolder, then create one
|
// if (!openDecisionTxResult) {
|
||||||
if (disable === undefined) disable = false // default for creation
|
// // no open caseFolder, then create one
|
||||||
if (closed === undefined) closed = false // default for creation
|
// if (disable === undefined) disable = false // default for creation
|
||||||
cypherHeader = `
|
// if (closed === undefined) closed = false // default for creation
|
||||||
MATCH (resource {id: $resourceId})
|
// cypherHeader = `
|
||||||
WHERE resource: User OR resource: Comment OR resource: Post
|
// MATCH (resource {id: $resourceId})
|
||||||
OPTIONAL MATCH (:User)-[lastDecision:DECIDED {latest: true}]->(resource)
|
// WHERE resource: User OR resource: Comment OR resource: Post
|
||||||
SET (CASE WHEN lastDecision IS NOT NULL THEN lastDecision END).latest = false
|
// OPTIONAL MATCH (:User)-[lastDecision:DECIDED {latest: true}]->(resource)
|
||||||
WITH resource
|
// SET (CASE WHEN lastDecision IS NOT NULL THEN lastDecision END).latest = false
|
||||||
MATCH (moderator:User {id: $moderatorId})
|
// WITH resource
|
||||||
CREATE (resource)<-[decision:DECIDED]-(moderator)
|
// MATCH (moderator:User {id: $moderatorId})
|
||||||
SET decision.latest = true
|
// CREATE (resource)<-[decision:DECIDED]-(moderator)
|
||||||
`
|
// SET decision.latest = true
|
||||||
} else {
|
// `
|
||||||
// an open caseFolder, then change it
|
// } else {
|
||||||
if (disable === undefined) disable = openDecisionTxResult.caseFolder.properties.disable // default set to existing
|
// // an open caseFolder, then change it
|
||||||
if (closed === undefined) closed = openDecisionTxResult.caseFolder.properties.closed // default set to existing
|
// if (disable === undefined) disable = openDecisionTxResult.caseFolder.properties.disable // default set to existing
|
||||||
// current moderator is not the same as old
|
// if (closed === undefined) closed = openDecisionTxResult.caseFolder.properties.closed // default set to existing
|
||||||
if (moderator.id !== openDecisionTxResult.caseModerator.id) {
|
// // current moderator is not the same as old
|
||||||
// from a different moderator, then create relation with properties to new moderator
|
// if (moderator.id !== openDecisionTxResult.caseModerator.id) {
|
||||||
cypherHeader = `
|
// // from a different moderator, then create relation with properties to new moderator
|
||||||
MATCH (moderator:User)-[oldDecision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
// cypherHeader = `
|
||||||
WHERE resource:User OR resource:Comment OR resource:Post
|
// MATCH (moderator:User)-[oldDecision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
||||||
DELETE oldDecision
|
// WHERE resource:User OR resource:Comment OR resource:Post
|
||||||
MATCH (moderator:User {id: $moderatorId})
|
// DELETE oldDecision
|
||||||
MATCH (resource {id: $resourceId})
|
// MATCH (moderator:User {id: $moderatorId})
|
||||||
WHERE resource:User OR resource:Comment OR resource:Post
|
// MATCH (resource {id: $resourceId})
|
||||||
CREATE (resource)<-[decision:DECIDED]-(moderator)
|
// WHERE resource:User OR resource:Comment OR resource:Post
|
||||||
SET decision = oldDecision
|
// CREATE (resource)<-[decision:DECIDED]-(moderator)
|
||||||
`
|
// SET decision = oldDecision
|
||||||
} else {
|
// `
|
||||||
// an open caseFolder from same moderator, then match this
|
// } else {
|
||||||
cypherHeader = `
|
// // an open caseFolder from same moderator, then match this
|
||||||
MATCH (moderator:User)-[decision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
// cypherHeader = `
|
||||||
WHERE resource:User OR resource:Comment OR resource:Post
|
// MATCH (moderator:User)-[decision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
||||||
`
|
// WHERE resource:User OR resource:Comment OR resource:Post
|
||||||
}
|
// `
|
||||||
}
|
// }
|
||||||
let decisionUUID = null
|
// }
|
||||||
let cypherClosed = ''
|
// let decisionUUID = null
|
||||||
if (closed) {
|
// let cypherClosed = ''
|
||||||
decisionUUID = uuid()
|
// if (closed) {
|
||||||
cypherClosed = `
|
// decisionUUID = uuid()
|
||||||
WITH decision, resource, moderator
|
// cypherClosed = `
|
||||||
OPTIONAL MATCH (:User)-[report:REPORTED {closed: false}]->(resource)
|
// WITH decision, resource, moderator
|
||||||
SET (CASE WHEN report IS NOT NULL THEN report END).closed = true
|
// OPTIONAL MATCH (:User)-[report:REPORTED {closed: false}]->(resource)
|
||||||
SET (CASE WHEN report IS NOT NULL THEN report END).decisionUuid = $decisionUUID
|
// SET (CASE WHEN report IS NOT NULL THEN report END).closed = true
|
||||||
SET decision.uuid = $decisionUUID
|
// SET (CASE WHEN report IS NOT NULL THEN report END).decisionUuid = $decisionUUID
|
||||||
`
|
// SET decision.uuid = $decisionUUID
|
||||||
}
|
// `
|
||||||
|
// }
|
||||||
|
// const cypher =
|
||||||
|
// cypherHeader +
|
||||||
|
// `SET decision.updatedAt = toString(datetime())
|
||||||
|
// SET (CASE WHEN decision.createdAt IS NULL THEN decision END).createdAt = decision.updatedAt
|
||||||
|
// SET decision.disable = $disable, decision.closed = $closed
|
||||||
|
// SET resource.disabled = $disable
|
||||||
|
// ` +
|
||||||
|
// cypherClosed +
|
||||||
|
// `RETURN decision, resource, moderator, labels(resource)[0] AS type
|
||||||
|
// `
|
||||||
const cypher =
|
const cypher =
|
||||||
cypherHeader +
|
`
|
||||||
`SET decision.updatedAt = toString(datetime())
|
// Wolle only review on reported resources
|
||||||
SET (CASE WHEN decision.createdAt IS NULL THEN decision END).createdAt = decision.updatedAt
|
|
||||||
SET decision.disable = $disable, decision.closed = $closed
|
MATCH (moderator:User {id: $moderatorId})
|
||||||
|
MATCH (resource {id: $resourceId})
|
||||||
|
WHERE resource:User OR resource:Post OR resource:Comment
|
||||||
|
|
||||||
|
// no open caseFolder, create one, update existing
|
||||||
|
MERGE (resource)<-[:FLAGGED]-(caseFolder:CaseFolder {closed: false})
|
||||||
|
ON CREATE SET caseFolder.id = randomUUID(), caseFolder.createdAt = $createdAt, caseFolder.updatedAt = caseFolder.createdAt, caseFolder.disable = $disable, caseFolder.closed = $closed
|
||||||
|
ON MATCH SET caseFolder.updatedAt = $createdAt, caseFolder.disable = $disable, caseFolder.closed = $closed
|
||||||
|
|
||||||
|
// Create review on caseFolder
|
||||||
|
WITH moderator, resource, caseFolder
|
||||||
|
CREATE (caseFolder)<-[review:REVIEWED {createdAt: $createdAt, updatedAt: $createdAt, disable: $disable, closed: $closed}]-(moderator)
|
||||||
|
|
||||||
SET resource.disabled = $disable
|
SET resource.disabled = $disable
|
||||||
` +
|
|
||||||
cypherClosed +
|
RETURN moderator, review, caseFolder {.id}, resource, labels(resource)[0] AS type
|
||||||
`RETURN decision, resource, moderator, labels(resource)[0] AS type
|
|
||||||
|
//RETURN decision, resource, moderator, labels(resource)[0] AS type
|
||||||
`
|
`
|
||||||
|
|
||||||
// Wolle console.log('cypher: ', cypher)
|
// Wolle console.log('cypher: ', cypher)
|
||||||
// console.log('disable: ', disable)
|
// console.log('disable: ', disable)
|
||||||
|
|
||||||
|
// const mutateDecisionWriteTxResultPromise = session.writeTransaction(async txc => {
|
||||||
|
// const mutateDecisionTransactionResponse = await txc.run(
|
||||||
|
// cypher, {
|
||||||
|
// resourceId,
|
||||||
|
// moderatorId: moderator.id,
|
||||||
|
// disable,
|
||||||
|
// closed,
|
||||||
|
// decisionUUID,
|
||||||
|
// })
|
||||||
|
// return mutateDecisionTransactionResponse.records.map(record => ({
|
||||||
|
// decision: record.get('decision'),
|
||||||
|
// resource: record.get('resource'),
|
||||||
|
// moderator: record.get('moderator'),
|
||||||
|
// type: record.get('type'),
|
||||||
|
// }))
|
||||||
|
// })
|
||||||
const mutateDecisionWriteTxResultPromise = session.writeTransaction(async txc => {
|
const mutateDecisionWriteTxResultPromise = session.writeTransaction(async txc => {
|
||||||
const mutateDecisionTransactionResponse = await txc.run(cypher, {
|
const mutateDecisionTransactionResponse = await txc.run(
|
||||||
|
cypher, {
|
||||||
resourceId,
|
resourceId,
|
||||||
moderatorId: moderator.id,
|
moderatorId: moderator.id,
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
disable,
|
disable,
|
||||||
closed,
|
closed,
|
||||||
decisionUUID,
|
|
||||||
})
|
})
|
||||||
return mutateDecisionTransactionResponse.records.map(record => ({
|
return mutateDecisionTransactionResponse.records.map(record => ({
|
||||||
decision: record.get('decision'),
|
|
||||||
resource: record.get('resource'),
|
|
||||||
moderator: record.get('moderator'),
|
moderator: record.get('moderator'),
|
||||||
|
review: record.get('review'),
|
||||||
|
caseFolder: record.get('caseFolder'),
|
||||||
|
resource: record.get('resource'),
|
||||||
type: record.get('type'),
|
type: record.get('type'),
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
const txResult = await mutateDecisionWriteTxResultPromise
|
const txResult = await mutateDecisionWriteTxResultPromise
|
||||||
if (!txResult[0]) return null
|
if (!txResult[0]) return null
|
||||||
const { decision, resource, moderator: moderatorInResult, type } = txResult[0]
|
// const { decision, resource, moderator: moderatorInResult, type } = txResult[0]
|
||||||
|
// createdRelationshipWithNestedAttributes = {
|
||||||
|
// ...decision.properties,
|
||||||
|
// moderator: moderatorInResult.properties,
|
||||||
|
// type,
|
||||||
|
// post: null,
|
||||||
|
// comment: null,
|
||||||
|
// user: null,
|
||||||
|
// }
|
||||||
|
const { moderator: moderatorInResult, review, caseFolder, resource, type } = txResult[0]
|
||||||
createdRelationshipWithNestedAttributes = {
|
createdRelationshipWithNestedAttributes = {
|
||||||
...decision.properties,
|
...review.properties,
|
||||||
moderator: moderatorInResult.properties,
|
moderator: moderatorInResult.properties,
|
||||||
|
caseFolderId: caseFolder.id,
|
||||||
type,
|
type,
|
||||||
post: null,
|
post: null,
|
||||||
comment: null,
|
comment: null,
|
||||||
@ -153,7 +212,7 @@ export default {
|
|||||||
return createdRelationshipWithNestedAttributes
|
return createdRelationshipWithNestedAttributes
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DECIDED: {
|
REVIEWED: {
|
||||||
...undefinedToNullResolver(['uuid']),
|
// Wolle ...undefinedToNullResolver(['uuid']),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ const commentQuery = gql`
|
|||||||
Comment(id: $id) {
|
Comment(id: $id) {
|
||||||
id
|
id
|
||||||
disabled
|
disabled
|
||||||
decidedByModerator {
|
reviewedByModerator {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ const postQuery = gql`
|
|||||||
Post(id: $id) {
|
Post(id: $id) {
|
||||||
id
|
id
|
||||||
disabled
|
disabled
|
||||||
decidedByModerator {
|
reviewedByModerator {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ describe('moderate resources', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes .decidedByModerator', async () => {
|
it('changes .reviewedByModerator', async () => {
|
||||||
resourceVariables = {
|
resourceVariables = {
|
||||||
id: 'comment-id',
|
id: 'comment-id',
|
||||||
}
|
}
|
||||||
@ -180,9 +180,9 @@ describe('moderate resources', () => {
|
|||||||
...disableVariables,
|
...disableVariables,
|
||||||
resourceId: 'comment-id',
|
resourceId: 'comment-id',
|
||||||
}
|
}
|
||||||
const before = { data: { Comment: [{ id: 'comment-id', decidedByModerator: null }] } }
|
const before = { data: { Comment: [{ id: 'comment-id', reviewedByModerator: null }] } }
|
||||||
const expected = {
|
const expected = {
|
||||||
data: { Comment: [{ id: 'comment-id', decidedByModerator: { id: 'moderator-id' } }] },
|
data: { Comment: [{ id: 'comment-id', reviewedByModerator: { id: 'moderator-id' } }] },
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: commentQuery, variables: resourceVariables }),
|
query({ query: commentQuery, variables: resourceVariables }),
|
||||||
@ -241,7 +241,7 @@ describe('moderate resources', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes .decidedByModerator', async () => {
|
it('changes .reviewedByModerator', async () => {
|
||||||
resourceVariables = {
|
resourceVariables = {
|
||||||
id: 'sample-post-id',
|
id: 'sample-post-id',
|
||||||
}
|
}
|
||||||
@ -249,10 +249,10 @@ describe('moderate resources', () => {
|
|||||||
...disableVariables,
|
...disableVariables,
|
||||||
resourceId: 'sample-post-id',
|
resourceId: 'sample-post-id',
|
||||||
}
|
}
|
||||||
const before = { data: { Post: [{ id: 'sample-post-id', decidedByModerator: null }] } }
|
const before = { data: { Post: [{ id: 'sample-post-id', reviewedByModerator: null }] } }
|
||||||
const expected = {
|
const expected = {
|
||||||
data: {
|
data: {
|
||||||
Post: [{ id: 'sample-post-id', decidedByModerator: { id: 'moderator-id' } }],
|
Post: [{ id: 'sample-post-id', reviewedByModerator: { id: 'moderator-id' } }],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,9 +387,9 @@ describe('moderate resources', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes .decidedByModerator', async () => {
|
it('changes .reviewedByModerator', async () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
data: { Comment: [{ id: 'comment-id', decidedByModerator: { id: 'moderator-id' } }] },
|
data: { Comment: [{ id: 'comment-id', reviewedByModerator: { id: 'moderator-id' } }] },
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
@ -443,9 +443,9 @@ describe('moderate resources', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('changes .decidedByModerator', async () => {
|
it('changes .reviewedByModerator', async () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
data: { Post: [{ id: 'post-id', decidedByModerator: { id: 'moderator-id' } }] },
|
data: { Post: [{ id: 'post-id', reviewedByModerator: { id: 'moderator-id' } }] },
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: decideMutation, variables: enableVariables }),
|
mutate({ mutation: decideMutation, variables: enableVariables }),
|
||||||
|
|||||||
@ -307,7 +307,7 @@ export default {
|
|||||||
},
|
},
|
||||||
hasOne: {
|
hasOne: {
|
||||||
author: '<-[:WROTE]-(related:User)',
|
author: '<-[:WROTE]-(related:User)',
|
||||||
decidedByModerator: '<-[:DECIDED]-(related:User)',
|
// Wolle reviewedByModerator: '<-[:DECIDED]-(related:User)',
|
||||||
pinnedBy: '<-[:PINNED]-(related:User)',
|
pinnedBy: '<-[:PINNED]-(related:User)',
|
||||||
},
|
},
|
||||||
count: {
|
count: {
|
||||||
|
|||||||
@ -199,7 +199,7 @@ export default {
|
|||||||
},
|
},
|
||||||
hasOne: {
|
hasOne: {
|
||||||
invitedBy: '<-[:INVITED]-(related:User)',
|
invitedBy: '<-[:INVITED]-(related:User)',
|
||||||
decidedByModerator: '<-[:DECIDED]-(related:User)',
|
// Wolle reviewedByModerator: '<-[:DECIDED]-(related:User)',
|
||||||
location: '-[:IS_IN]->(related:Location)',
|
location: '-[:IS_IN]->(related:Location)',
|
||||||
},
|
},
|
||||||
hasMany: {
|
hasMany: {
|
||||||
|
|||||||
@ -9,7 +9,16 @@ type Comment {
|
|||||||
updatedAt: String
|
updatedAt: String
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
decidedByModerator: User @relation(name: "DECIDED", direction: "IN")
|
# Wolle reviewedByModerator: User # Wolle @relation(name: "DECIDED", direction: "IN")
|
||||||
|
reviewedByModerator: User
|
||||||
|
@cypher(
|
||||||
|
statement: """
|
||||||
|
MATCH (this)<-[:FLAGGED]-(caseFolder:CaseFolder)<-[review:REVIEWED]-(moderator:User)
|
||||||
|
RETURN moderator
|
||||||
|
ORDER BY caseFolder.updatedAt ASC, review.updatedAt ASC
|
||||||
|
LIMIT 1
|
||||||
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
|
|||||||
@ -46,8 +46,16 @@ type Post {
|
|||||||
visibility: Visibility
|
visibility: Visibility
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
|
reviewedByModerator: User
|
||||||
|
@cypher(
|
||||||
|
statement: """
|
||||||
|
MATCH (this)<-[:FLAGGED]-(caseFolder:CaseFolder)<-[review:REVIEWED]-(moderator:User)
|
||||||
|
RETURN moderator
|
||||||
|
ORDER BY caseFolder.updatedAt ASC, review.updatedAt ASC
|
||||||
|
LIMIT 1
|
||||||
|
"""
|
||||||
|
)
|
||||||
pinned: Boolean
|
pinned: Boolean
|
||||||
decidedByModerator: User @relation(name: "DECIDED", direction: "IN")
|
|
||||||
createdAt: String
|
createdAt: String
|
||||||
updatedAt: String
|
updatedAt: String
|
||||||
language: String
|
language: String
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
type DECIDED {
|
type REVIEWED {
|
||||||
createdAt: String!
|
createdAt: String!
|
||||||
updatedAt: String!
|
updatedAt: String!
|
||||||
# reasonCategory: ReasonCategory
|
# reasonCategory: ReasonCategory
|
||||||
# reasonDescription: String
|
# reasonDescription: String
|
||||||
disable: Boolean!
|
disable: Boolean!
|
||||||
closed: Boolean!
|
closed: Boolean!
|
||||||
uuid: ID
|
caseFolderId: ID!
|
||||||
last: Boolean!
|
# Wolle last: Boolean!
|
||||||
|
|
||||||
moderator: User
|
moderator: User
|
||||||
@cypher(statement: "MATCH (resource)<-[:DECIDED]-(moderator:User) RETURN moderator")
|
# @cypher(statement: "MATCH (resource)<-[:DECIDED]-(moderator:User) RETURN moderator")
|
||||||
# not yet supported
|
# not yet supported
|
||||||
# resource: ReportResource
|
# resource: ReportResource
|
||||||
# @cypher(statement: "MATCH (resource)<-[:DECIDED]-(:User) RETURN resource")
|
# @cypher(statement: "MATCH (resource)<-[:DECIDED]-(:User) RETURN resource")
|
||||||
type: String
|
type: String
|
||||||
@cypher(statement: "MATCH (resource)<-[:DECIDED]-(user:User) RETURN labels(resource)[0]")
|
# @cypher(statement: "MATCH (resource)<-[:DECIDED]-(user:User) RETURN labels(resource)[0]")
|
||||||
user: User
|
user: User
|
||||||
post: Post
|
post: Post
|
||||||
comment: Comment
|
comment: Comment
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
decide(resourceId: ID!, disable: Boolean, closed: Boolean): DECIDED
|
decide(resourceId: ID!, disable: Boolean, closed: Boolean): REVIEWED
|
||||||
}
|
}
|
||||||
@ -8,7 +8,15 @@ type User {
|
|||||||
coverImg: String
|
coverImg: String
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
decidedByModerator: User @relation(name: "DECIDED", direction: "IN")
|
reviewedByModerator: User
|
||||||
|
@cypher(
|
||||||
|
statement: """
|
||||||
|
MATCH (this)<-[:FLAGGED]-(caseFolder:CaseFolder)<-[review:REVIEWED]-(moderator:User)
|
||||||
|
RETURN moderator
|
||||||
|
ORDER BY caseFolder.updatedAt ASC, review.updatedAt ASC
|
||||||
|
LIMIT 1
|
||||||
|
"""
|
||||||
|
)
|
||||||
role: UserGroup!
|
role: UserGroup!
|
||||||
publicKey: String
|
publicKey: String
|
||||||
invitedBy: User @relation(name: "INVITED", direction: "IN")
|
invitedBy: User @relation(name: "INVITED", direction: "IN")
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export const reportListQuery = () => {
|
|||||||
name
|
name
|
||||||
disabled
|
disabled
|
||||||
deleted
|
deleted
|
||||||
decidedByModerator {
|
reviewedByModerator {
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
@ -60,7 +60,7 @@ export const reportListQuery = () => {
|
|||||||
disabled
|
disabled
|
||||||
deleted
|
deleted
|
||||||
}
|
}
|
||||||
decidedByModerator {
|
reviewedByModerator {
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
@ -84,7 +84,7 @@ export const reportListQuery = () => {
|
|||||||
contributionsCount
|
contributionsCount
|
||||||
commentedCount
|
commentedCount
|
||||||
}
|
}
|
||||||
decidedByModerator {
|
reviewedByModerator {
|
||||||
id
|
id
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
|
|||||||
@ -101,8 +101,8 @@
|
|||||||
>
|
>
|
||||||
{{ $t('moderation.reports.decideButton') }}
|
{{ $t('moderation.reports.decideButton') }}
|
||||||
</ds-button>
|
</ds-button>
|
||||||
<!-- decidedByModerator -->
|
<!-- reviewedByModerator -->
|
||||||
<div v-if="content.resource.decidedByModerator">
|
<div v-if="content.resource.reviewedByModerator">
|
||||||
<br />
|
<br />
|
||||||
<div v-if="content.caseFolderDisable">
|
<div v-if="content.caseFolderDisable">
|
||||||
<ds-icon name="eye-slash" class="ban" />
|
<ds-icon name="eye-slash" class="ban" />
|
||||||
@ -113,7 +113,7 @@
|
|||||||
{{ $t('moderation.reports.enabledBy') }}
|
{{ $t('moderation.reports.enabledBy') }}
|
||||||
</div>
|
</div>
|
||||||
<hc-user
|
<hc-user
|
||||||
:user="content.resource.decidedByModerator"
|
:user="content.resource.reviewedByModerator"
|
||||||
:showAvatar="false"
|
:showAvatar="false"
|
||||||
:trunc="30"
|
:trunc="30"
|
||||||
:date-time="content.caseFolderUpdatedAt"
|
:date-time="content.caseFolderUpdatedAt"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user