mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Clean up
This commit is contained in:
parent
9a7774ce86
commit
59f53a07c6
@ -25,12 +25,6 @@ module.exports = {
|
|||||||
target: 'User',
|
target: 'User',
|
||||||
direction: 'in',
|
direction: 'in',
|
||||||
},
|
},
|
||||||
// Wolle reviewedByModerator: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'DECIDED',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'in',
|
|
||||||
// },
|
|
||||||
notified: {
|
notified: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'NOTIFIED',
|
relationship: 'NOTIFIED',
|
||||||
|
|||||||
@ -17,12 +17,6 @@ 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 },
|
||||||
// Wolle reviewedByModerator: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'DECIDED',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'in',
|
|
||||||
// },
|
|
||||||
notified: {
|
notified: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'NOTIFIED',
|
relationship: 'NOTIFIED',
|
||||||
|
|||||||
@ -42,12 +42,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' },
|
friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' },
|
||||||
// Wolle reviewedByModerator: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'DECIDED',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'in',
|
|
||||||
// },
|
|
||||||
rewarded: {
|
rewarded: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'REWARDED',
|
relationship: 'REWARDED',
|
||||||
|
|||||||
@ -1,28 +1,3 @@
|
|||||||
// Wolle import { undefinedToNullResolver } from './helpers/Resolver'
|
|
||||||
|
|
||||||
// Wolle const queryOpenDecisionWriteTransaction = (session, resourceId) => {
|
|
||||||
// return session.writeTransaction(async txc => {
|
|
||||||
// const queryOpenDecisionTransactionResponse = await txc.run(
|
|
||||||
// `
|
|
||||||
// //MATCH (moderator:User)-[decision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
|
||||||
// //WHERE resource:User OR resource:Comment OR resource:Post
|
|
||||||
// //RETURN decision, moderator {.id} AS decisionModerator
|
|
||||||
|
|
||||||
// // Wolle only review on reported resources
|
|
||||||
|
|
||||||
// MATCH (caseModerator:User)-[:REPORTED]->(claim:Claim {closed: false})-[:BELONGS_TO]->(resource {id: $resourceId})
|
|
||||||
// WHERE resource:User OR resource:Post OR resource:Comment
|
|
||||||
// RETURN claim, caseModerator {.id}
|
|
||||||
// `,
|
|
||||||
// { resourceId },
|
|
||||||
// )
|
|
||||||
// return queryOpenDecisionTransactionResponse.records.map(record => ({
|
|
||||||
// claim: record.get('claim'),
|
|
||||||
// caseModerator: record.get('caseModerator'),
|
|
||||||
// }))
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
review: async (_object, params, context, _resolveInfo) => {
|
review: async (_object, params, context, _resolveInfo) => {
|
||||||
@ -40,89 +15,10 @@ export default {
|
|||||||
|
|
||||||
const session = driver.session()
|
const session = driver.session()
|
||||||
try {
|
try {
|
||||||
// const queryOpenDecisionWriteTxResultPromise = queryOpenDecisionWriteTransaction(
|
|
||||||
// session,
|
|
||||||
// resourceId,
|
|
||||||
// )
|
|
||||||
// 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 = ''
|
|
||||||
|
|
||||||
// // Wolle openDecisionTxResult should not be undefined !!!
|
|
||||||
// if (!openDecisionTxResult) {
|
|
||||||
// // no open claim, then create one
|
|
||||||
// if (disable === undefined) disable = false // default for creation
|
|
||||||
// if (closed === undefined) closed = false // default for creation
|
|
||||||
// cypherHeader = `
|
|
||||||
// MATCH (resource {id: $resourceId})
|
|
||||||
// WHERE resource: User OR resource: Comment OR resource: Post
|
|
||||||
// OPTIONAL MATCH (:User)-[lastDecision:DECIDED {latest: true}]->(resource)
|
|
||||||
// SET (CASE WHEN lastDecision IS NOT NULL THEN lastDecision END).latest = false
|
|
||||||
// WITH resource
|
|
||||||
// MATCH (moderator:User {id: $moderatorId})
|
|
||||||
// CREATE (resource)<-[decision:DECIDED]-(moderator)
|
|
||||||
// SET decision.latest = true
|
|
||||||
// `
|
|
||||||
// } else {
|
|
||||||
// // an open claim, then change it
|
|
||||||
// if (disable === undefined) disable = openDecisionTxResult.claim.properties.disable // default set to existing
|
|
||||||
// if (closed === undefined) closed = openDecisionTxResult.claim.properties.closed // default set to existing
|
|
||||||
// // current moderator is not the same as old
|
|
||||||
// if (moderator.id !== openDecisionTxResult.caseModerator.id) {
|
|
||||||
// // from a different moderator, then create relation with properties to new moderator
|
|
||||||
// cypherHeader = `
|
|
||||||
// MATCH (moderator:User)-[oldDecision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
|
||||||
// WHERE resource:User OR resource:Comment OR resource:Post
|
|
||||||
// DELETE oldDecision
|
|
||||||
// MATCH (moderator:User {id: $moderatorId})
|
|
||||||
// MATCH (resource {id: $resourceId})
|
|
||||||
// WHERE resource:User OR resource:Comment OR resource:Post
|
|
||||||
// CREATE (resource)<-[decision:DECIDED]-(moderator)
|
|
||||||
// SET decision = oldDecision
|
|
||||||
// `
|
|
||||||
// } else {
|
|
||||||
// // an open claim from same moderator, then match this
|
|
||||||
// cypherHeader = `
|
|
||||||
// MATCH (moderator:User)-[decision:DECIDED {closed: false}]->(resource {id: $resourceId})
|
|
||||||
// WHERE resource:User OR resource:Comment OR resource:Post
|
|
||||||
// `
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// let decisionUUID = null
|
|
||||||
// let cypherClosed = ''
|
|
||||||
// if (closed) {
|
|
||||||
// decisionUUID = uuid()
|
|
||||||
// cypherClosed = `
|
|
||||||
// WITH decision, resource, moderator
|
|
||||||
// OPTIONAL MATCH (:User)-[report:REPORTED {closed: false}]->(resource)
|
|
||||||
// SET (CASE WHEN report IS NOT NULL THEN report END).closed = true
|
|
||||||
// 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 = `
|
||||||
// Wolle only review on reported resources
|
|
||||||
|
|
||||||
MATCH (moderator:User {id: $moderatorId})
|
MATCH (moderator:User {id: $moderatorId})
|
||||||
MATCH (resource {id: $resourceId})
|
MATCH (resource {id: $resourceId})
|
||||||
WHERE resource:User OR resource:Post OR resource:Comment
|
WHERE resource:User OR resource:Post OR resource:Comment
|
||||||
// report exists?
|
|
||||||
//WHERE (claim)<-[report:REPORTED]-(submitter:User)
|
|
||||||
|
|
||||||
// no open claim, create one, update existing
|
// no open claim, create one, update existing
|
||||||
MERGE (resource)<-[:BELONGS_TO]-(claim:Claim {closed: false})
|
MERGE (resource)<-[:BELONGS_TO]-(claim:Claim {closed: false})
|
||||||
@ -154,26 +50,6 @@ export default {
|
|||||||
|
|
||||||
RETURN moderator, review, claim, resource, labels(resource)[0] AS type
|
RETURN moderator, review, claim, resource, labels(resource)[0] AS type
|
||||||
`
|
`
|
||||||
|
|
||||||
// Wolle console.log('cypher: ', cypher)
|
|
||||||
// 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,
|
||||||
@ -229,7 +105,4 @@ export default {
|
|||||||
return createdRelationshipWithNestedAttributes
|
return createdRelationshipWithNestedAttributes
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
REVIEWED: {
|
|
||||||
// Wolle ...undefinedToNullResolver(['uuid']),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,7 +153,6 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
describe('moderate a comment', () => {
|
describe('moderate a comment', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
// Wolle variables = {}
|
|
||||||
await factory.create('Comment', {
|
await factory.create('Comment', {
|
||||||
id: 'comment-id',
|
id: 'comment-id',
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
// Wolle import { undefinedToNullResolver } from './helpers/Resolver'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
report: async (_parent, params, context, _resolveInfo) => {
|
report: async (_parent, params, context, _resolveInfo) => {
|
||||||
@ -16,7 +14,7 @@ export default {
|
|||||||
// no open claim, create one
|
// no open claim, create one
|
||||||
MERGE (resource)<-[:BELONGS_TO]-(claim:Claim {closed: false})
|
MERGE (resource)<-[:BELONGS_TO]-(claim:Claim {closed: false})
|
||||||
ON CREATE SET claim.id = randomUUID(), claim.createdAt = $createdAt, claim.updatedAt = claim.createdAt, claim.rule = 'latestReviewUpdatedAtRules', claim.disable = false, claim.closed = false
|
ON CREATE SET claim.id = randomUUID(), claim.createdAt = $createdAt, claim.updatedAt = claim.createdAt, claim.rule = 'latestReviewUpdatedAtRules', claim.disable = false, claim.closed = false
|
||||||
// Create report on claim
|
// Create report to claim
|
||||||
WITH submitter, resource, claim
|
WITH submitter, resource, claim
|
||||||
CREATE (claim)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter)
|
CREATE (claim)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter)
|
||||||
|
|
||||||
@ -90,7 +88,6 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const cypher = `
|
const cypher = `
|
||||||
MATCH (submitter:User)-[report:REPORTED]->(claim:Claim)-[:BELONGS_TO]->(resource)
|
MATCH (submitter:User)-[report:REPORTED]->(claim:Claim)-[:BELONGS_TO]->(resource)
|
||||||
// Wolle OPTIONAL MATCH (reviewer:User)-[:REVIEWED]->(claim)
|
|
||||||
WHERE resource:User OR resource:Post OR resource:Comment
|
WHERE resource:User OR resource:Post OR resource:Comment
|
||||||
RETURN submitter, report, claim, resource, labels(resource)[0] as type
|
RETURN submitter, report, claim, resource, labels(resource)[0] as type
|
||||||
${orderByClause}
|
${orderByClause}
|
||||||
@ -141,19 +138,7 @@ export default {
|
|||||||
session.close()
|
session.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wolle console.log('response: ')
|
|
||||||
// response.forEach((ele, index) => {
|
|
||||||
// // console.log('ele #', index, ': ', ele)
|
|
||||||
// // if (ele.decision === undefined)
|
|
||||||
// // console.log('ele #', index, ': ', ele)
|
|
||||||
// if (ele.decision) console.log('ele #', index, ': ', ele)
|
|
||||||
// })
|
|
||||||
// // Wolle console.log('response: ', response)
|
|
||||||
|
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
REPORTED: {
|
|
||||||
// Wolle ...undefinedToNullResolver(['claimId', 'claimDisable', 'claimUpdatedAt', 'claimClosed']),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,12 +12,7 @@ type REVIEWED {
|
|||||||
claimClosed: Boolean!
|
claimClosed: Boolean!
|
||||||
|
|
||||||
moderator: User
|
moderator: User
|
||||||
# Wolle @cypher(statement: "MATCH (resource)<-[:DECIDED]-(moderator:User) RETURN moderator")
|
|
||||||
# not yet supported
|
|
||||||
# Wolle resource: ReportResource
|
|
||||||
# @cypher(statement: "MATCH (resource)<-[:DECIDED]-(:User) RETURN resource")
|
|
||||||
type: String
|
type: String
|
||||||
# @cypher(statement: "MATCH (resource)<-[:DECIDED]-(user:User) RETURN labels(resource)[0]")
|
|
||||||
user: User
|
user: User
|
||||||
post: Post
|
post: Post
|
||||||
comment: Comment
|
comment: Comment
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user