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',
|
||||
direction: 'in',
|
||||
},
|
||||
// Wolle reviewedByModerator: {
|
||||
// type: 'relationship',
|
||||
// relationship: 'DECIDED',
|
||||
// target: 'User',
|
||||
// direction: 'in',
|
||||
// },
|
||||
notified: {
|
||||
type: 'relationship',
|
||||
relationship: 'NOTIFIED',
|
||||
|
||||
@ -17,12 +17,6 @@ module.exports = {
|
||||
image: { type: 'string', allow: [null] },
|
||||
deleted: { type: 'boolean', default: false },
|
||||
disabled: { type: 'boolean', default: false },
|
||||
// Wolle reviewedByModerator: {
|
||||
// type: 'relationship',
|
||||
// relationship: 'DECIDED',
|
||||
// target: 'User',
|
||||
// direction: 'in',
|
||||
// },
|
||||
notified: {
|
||||
type: 'relationship',
|
||||
relationship: 'NOTIFIED',
|
||||
|
||||
@ -42,12 +42,6 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' },
|
||||
// Wolle reviewedByModerator: {
|
||||
// type: 'relationship',
|
||||
// relationship: 'DECIDED',
|
||||
// target: 'User',
|
||||
// direction: 'in',
|
||||
// },
|
||||
rewarded: {
|
||||
type: 'relationship',
|
||||
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 {
|
||||
Mutation: {
|
||||
review: async (_object, params, context, _resolveInfo) => {
|
||||
@ -40,89 +15,10 @@ export default {
|
||||
|
||||
const session = driver.session()
|
||||
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 = `
|
||||
// Wolle only review on reported resources
|
||||
|
||||
MATCH (moderator:User {id: $moderatorId})
|
||||
MATCH (resource {id: $resourceId})
|
||||
WHERE resource:User OR resource:Post OR resource:Comment
|
||||
// report exists?
|
||||
//WHERE (claim)<-[report:REPORTED]-(submitter:User)
|
||||
|
||||
// no open claim, create one, update existing
|
||||
MERGE (resource)<-[:BELONGS_TO]-(claim:Claim {closed: false})
|
||||
@ -154,26 +50,6 @@ export default {
|
||||
|
||||
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 mutateDecisionTransactionResponse = await txc.run(cypher, {
|
||||
resourceId,
|
||||
@ -229,7 +105,4 @@ export default {
|
||||
return createdRelationshipWithNestedAttributes
|
||||
},
|
||||
},
|
||||
REVIEWED: {
|
||||
// Wolle ...undefinedToNullResolver(['uuid']),
|
||||
},
|
||||
}
|
||||
|
||||
@ -153,7 +153,6 @@ describe('moderate resources', () => {
|
||||
|
||||
describe('moderate a comment', () => {
|
||||
beforeEach(async () => {
|
||||
// Wolle variables = {}
|
||||
await factory.create('Comment', {
|
||||
id: 'comment-id',
|
||||
})
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
// Wolle import { undefinedToNullResolver } from './helpers/Resolver'
|
||||
|
||||
export default {
|
||||
Mutation: {
|
||||
report: async (_parent, params, context, _resolveInfo) => {
|
||||
@ -16,7 +14,7 @@ export default {
|
||||
// no open claim, create one
|
||||
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
|
||||
// Create report on claim
|
||||
// Create report to claim
|
||||
WITH submitter, resource, claim
|
||||
CREATE (claim)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter)
|
||||
|
||||
@ -90,7 +88,6 @@ export default {
|
||||
try {
|
||||
const cypher = `
|
||||
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
|
||||
RETURN submitter, report, claim, resource, labels(resource)[0] as type
|
||||
${orderByClause}
|
||||
@ -141,19 +138,7 @@ export default {
|
||||
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
|
||||
},
|
||||
},
|
||||
REPORTED: {
|
||||
// Wolle ...undefinedToNullResolver(['claimId', 'claimDisable', 'claimUpdatedAt', 'claimClosed']),
|
||||
},
|
||||
}
|
||||
|
||||
@ -12,12 +12,7 @@ type REVIEWED {
|
||||
claimClosed: Boolean!
|
||||
|
||||
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
|
||||
# @cypher(statement: "MATCH (resource)<-[:DECIDED]-(user:User) RETURN labels(resource)[0]")
|
||||
user: User
|
||||
post: Post
|
||||
comment: Comment
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user