mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Cleanup
This commit is contained in:
parent
78eeb7e497
commit
0149af12d4
@ -35,9 +35,6 @@ export const createGroupMutation = gql`
|
|||||||
groupType
|
groupType
|
||||||
actionRadius
|
actionRadius
|
||||||
myRole
|
myRole
|
||||||
# Wolle: owner {
|
|
||||||
# name
|
|
||||||
# }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@ -54,9 +51,6 @@ export const groupQuery = gql`
|
|||||||
$updatedAt: String
|
$updatedAt: String
|
||||||
$about: String
|
$about: String
|
||||||
$description: String
|
$description: String
|
||||||
# $groupType: GroupType!,
|
|
||||||
# $actionRadius: GroupActionRadius!,
|
|
||||||
# $categoryIds: [ID]
|
|
||||||
$locationName: String
|
$locationName: String
|
||||||
$first: Int
|
$first: Int
|
||||||
$offset: Int
|
$offset: Int
|
||||||
@ -72,9 +66,6 @@ export const groupQuery = gql`
|
|||||||
updatedAt: $updatedAt
|
updatedAt: $updatedAt
|
||||||
about: $about
|
about: $about
|
||||||
description: $description
|
description: $description
|
||||||
# groupType: $groupType
|
|
||||||
# actionRadius: $actionRadius
|
|
||||||
# categoryIds: $categoryIds
|
|
||||||
locationName: $locationName
|
locationName: $locationName
|
||||||
first: $first
|
first: $first
|
||||||
offset: $offset
|
offset: $offset
|
||||||
@ -99,9 +90,6 @@ export const groupQuery = gql`
|
|||||||
name
|
name
|
||||||
icon
|
icon
|
||||||
}
|
}
|
||||||
# Wolle: owner {
|
|
||||||
# name
|
|
||||||
# }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -38,109 +38,11 @@ export default {
|
|||||||
locationName: { type: 'string', allow: [null] },
|
locationName: { type: 'string', allow: [null] },
|
||||||
|
|
||||||
wasSeeded: 'boolean', // Wolle: used or needed?
|
wasSeeded: 'boolean', // Wolle: used or needed?
|
||||||
// Wolle: owner: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'OWNS',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'in',
|
|
||||||
// },
|
|
||||||
// Wolle: followedBy: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'FOLLOWS',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'in',
|
|
||||||
// properties: {
|
|
||||||
// createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// Wolle: correct this way?
|
|
||||||
// members: { type: 'relationship', relationship: 'MEMBERS', target: 'User', direction: 'out' },
|
|
||||||
// Wolle: needed? lastActiveAt: { type: 'string', isoDate: true },
|
|
||||||
// Wolle: emoted: {
|
|
||||||
// type: 'relationships',
|
|
||||||
// relationship: 'EMOTED',
|
|
||||||
// target: 'Post',
|
|
||||||
// direction: 'out',
|
|
||||||
// properties: {
|
|
||||||
// emotion: {
|
|
||||||
// type: 'string',
|
|
||||||
// valid: ['happy', 'cry', 'surprised', 'angry', 'funny'],
|
|
||||||
// invalid: [null],
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// eager: true,
|
|
||||||
// cascade: true,
|
|
||||||
// },
|
|
||||||
// Wolle: blocked: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'BLOCKED',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'out',
|
|
||||||
// properties: {
|
|
||||||
// createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// Wolle: muted: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'MUTED',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'out',
|
|
||||||
// properties: {
|
|
||||||
// createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// Wolle: notifications: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'NOTIFIED',
|
|
||||||
// target: 'User',
|
|
||||||
// direction: 'in',
|
|
||||||
// },
|
|
||||||
// Wolle inviteCodes: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'GENERATED',
|
|
||||||
// target: 'InviteCode',
|
|
||||||
// direction: 'out',
|
|
||||||
// },
|
|
||||||
// Wolle: redeemedInviteCode: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'REDEEMED',
|
|
||||||
// target: 'InviteCode',
|
|
||||||
// direction: 'out',
|
|
||||||
// },
|
|
||||||
// Wolle: shouted: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'SHOUTED',
|
|
||||||
// target: 'Post',
|
|
||||||
// direction: 'out',
|
|
||||||
// properties: {
|
|
||||||
// createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
isIn: {
|
isIn: {
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationship: 'IS_IN',
|
relationship: 'IS_IN',
|
||||||
target: 'Location',
|
target: 'Location',
|
||||||
direction: 'out',
|
direction: 'out',
|
||||||
},
|
},
|
||||||
// Wolle: pinned: {
|
|
||||||
// type: 'relationship',
|
|
||||||
// relationship: 'PINNED',
|
|
||||||
// target: 'Post',
|
|
||||||
// direction: 'out',
|
|
||||||
// properties: {
|
|
||||||
// createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// Wolle: showShoutsPublicly: {
|
|
||||||
// type: 'boolean',
|
|
||||||
// default: false,
|
|
||||||
// },
|
|
||||||
// Wolle: sendNotificationEmails: {
|
|
||||||
// type: 'boolean',
|
|
||||||
// default: true,
|
|
||||||
// },
|
|
||||||
// Wolle: locale: {
|
|
||||||
// type: 'string',
|
|
||||||
// allow: [null],
|
|
||||||
// },
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,13 @@
|
|||||||
import { v4 as uuid } from 'uuid'
|
import { v4 as uuid } from 'uuid'
|
||||||
// Wolle: import { neo4jgraphql } from 'neo4j-graphql-js'
|
|
||||||
// Wolle: import { isEmpty } from 'lodash'
|
|
||||||
import { UserInputError } from 'apollo-server'
|
import { UserInputError } from 'apollo-server'
|
||||||
import CONFIG from '../../config'
|
import CONFIG from '../../config'
|
||||||
import { CATEGORIES_MIN, CATEGORIES_MAX } from '../../constants/categories'
|
import { CATEGORIES_MIN, CATEGORIES_MAX } from '../../constants/categories'
|
||||||
import { DESCRIPTION_WITHOUT_HTML_LENGTH_MIN } from '../../constants/groups'
|
import { DESCRIPTION_WITHOUT_HTML_LENGTH_MIN } from '../../constants/groups'
|
||||||
import { removeHtmlTags } from '../../middleware/helpers/cleanHtml.js'
|
import { removeHtmlTags } from '../../middleware/helpers/cleanHtml.js'
|
||||||
// Wolle: import { mergeImage, deleteImage } from './images/images'
|
|
||||||
import Resolver from './helpers/Resolver'
|
import Resolver from './helpers/Resolver'
|
||||||
// Wolle: import { filterForMutedUsers } from './helpers/filterForMutedUsers'
|
|
||||||
|
|
||||||
// Wolle: const maintainPinnedPosts = (params) => {
|
|
||||||
// const pinnedPostFilter = { pinned: true }
|
|
||||||
// if (isEmpty(params.filter)) {
|
|
||||||
// params.filter = { OR: [pinnedPostFilter, {}] }
|
|
||||||
// } else {
|
|
||||||
// params.filter = { OR: [pinnedPostFilter, { ...params.filter }] }
|
|
||||||
// }
|
|
||||||
// return params
|
|
||||||
// }
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Query: {
|
Query: {
|
||||||
// Wolle: Post: async (object, params, context, resolveInfo) => {
|
|
||||||
// params = await filterForMutedUsers(params, context)
|
|
||||||
// // params = await maintainPinnedPosts(params)
|
|
||||||
// return neo4jgraphql(object, params, context, resolveInfo)
|
|
||||||
// },
|
|
||||||
Group: async (_object, params, context, _resolveInfo) => {
|
Group: async (_object, params, context, _resolveInfo) => {
|
||||||
const { isMember } = params
|
const { isMember } = params
|
||||||
const session = context.driver.session()
|
const session = context.driver.session()
|
||||||
@ -130,105 +111,12 @@ export default {
|
|||||||
session.close()
|
session.close()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// UpdatePost: async (_parent, params, context, _resolveInfo) => {
|
|
||||||
// const { categoryIds } = params
|
|
||||||
// const { image: imageInput } = params
|
|
||||||
// delete params.categoryIds
|
|
||||||
// delete params.image
|
|
||||||
// const session = context.driver.session()
|
|
||||||
// let updatePostCypher = `
|
|
||||||
// MATCH (post:Post {id: $params.id})
|
|
||||||
// SET post += $params
|
|
||||||
// SET post.updatedAt = toString(datetime())
|
|
||||||
// WITH post
|
|
||||||
// `
|
|
||||||
|
|
||||||
// if (categoryIds && categoryIds.length) {
|
|
||||||
// const cypherDeletePreviousRelations = `
|
|
||||||
// MATCH (post:Post { id: $params.id })-[previousRelations:CATEGORIZED]->(category:Category)
|
|
||||||
// DELETE previousRelations
|
|
||||||
// RETURN post, category
|
|
||||||
// `
|
|
||||||
|
|
||||||
// await session.writeTransaction((transaction) => {
|
|
||||||
// return transaction.run(cypherDeletePreviousRelations, { params })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// updatePostCypher += `
|
|
||||||
// UNWIND $categoryIds AS categoryId
|
|
||||||
// MATCH (category:Category {id: categoryId})
|
|
||||||
// MERGE (post)-[:CATEGORIZED]->(category)
|
|
||||||
// WITH post
|
|
||||||
// `
|
|
||||||
// }
|
|
||||||
|
|
||||||
// updatePostCypher += `RETURN post {.*}`
|
|
||||||
// const updatePostVariables = { categoryIds, params }
|
|
||||||
// try {
|
|
||||||
// const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
|
||||||
// const updatePostTransactionResponse = await transaction.run(
|
|
||||||
// updatePostCypher,
|
|
||||||
// updatePostVariables,
|
|
||||||
// )
|
|
||||||
// const [post] = updatePostTransactionResponse.records.map((record) => record.get('post'))
|
|
||||||
// await mergeImage(post, 'HERO_IMAGE', imageInput, { transaction })
|
|
||||||
// return post
|
|
||||||
// })
|
|
||||||
// const post = await writeTxResultPromise
|
|
||||||
// return post
|
|
||||||
// } finally {
|
|
||||||
// session.close()
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
|
|
||||||
// DeletePost: async (object, args, context, resolveInfo) => {
|
|
||||||
// const session = context.driver.session()
|
|
||||||
// const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
|
||||||
// const deletePostTransactionResponse = await transaction.run(
|
|
||||||
// `
|
|
||||||
// MATCH (post:Post {id: $postId})
|
|
||||||
// OPTIONAL MATCH (post)<-[:COMMENTS]-(comment:Comment)
|
|
||||||
// SET post.deleted = TRUE
|
|
||||||
// SET post.content = 'UNAVAILABLE'
|
|
||||||
// SET post.contentExcerpt = 'UNAVAILABLE'
|
|
||||||
// SET post.title = 'UNAVAILABLE'
|
|
||||||
// SET comment.deleted = TRUE
|
|
||||||
// RETURN post {.*}
|
|
||||||
// `,
|
|
||||||
// { postId: args.id },
|
|
||||||
// )
|
|
||||||
// const [post] = deletePostTransactionResponse.records.map((record) => record.get('post'))
|
|
||||||
// await deleteImage(post, 'HERO_IMAGE', { transaction })
|
|
||||||
// return post
|
|
||||||
// })
|
|
||||||
// try {
|
|
||||||
// const post = await writeTxResultPromise
|
|
||||||
// return post
|
|
||||||
// } finally {
|
|
||||||
// session.close()
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
Group: {
|
Group: {
|
||||||
...Resolver('Group', {
|
...Resolver('Group', {
|
||||||
// Wolle: undefinedToNull: ['activityId', 'objectId', 'language', 'pinnedAt', 'pinned'],
|
|
||||||
hasMany: {
|
hasMany: {
|
||||||
// Wolle: tags: '-[:TAGGED]->(related:Tag)',
|
|
||||||
categories: '-[:CATEGORIZED]->(related:Category)',
|
categories: '-[:CATEGORIZED]->(related:Category)',
|
||||||
},
|
},
|
||||||
// hasOne: {
|
|
||||||
// owner: '<-[:OWNS]-(related:User)',
|
|
||||||
// // Wolle: image: '-[:HERO_IMAGE]->(related:Image)',
|
|
||||||
// },
|
|
||||||
// Wolle: count: {
|
|
||||||
// contributionsCount:
|
|
||||||
// '-[:WROTE]->(related:Post) WHERE NOT related.disabled = true AND NOT related.deleted = true',
|
|
||||||
// },
|
|
||||||
// Wolle: boolean: {
|
|
||||||
// shoutedByCurrentUser:
|
|
||||||
// 'MATCH(this)<-[:SHOUTED]-(related:User {id: $cypherParams.currentUserId}) RETURN COUNT(related) >= 1',
|
|
||||||
// viewedTeaserByCurrentUser:
|
|
||||||
// 'MATCH (this)<-[:VIEWED_TEASER]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
|
||||||
// },
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,163 +197,6 @@ describe('Group', () => {
|
|||||||
).resolves.toMatchObject(expected)
|
).resolves.toMatchObject(expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// describe('can be filtered', () => {
|
|
||||||
// Wolle: it('by categories', async () => {
|
|
||||||
// const postQueryFilteredByCategories = gql`
|
|
||||||
// query Post($filter: _PostFilter) {
|
|
||||||
// Post(filter: $filter) {
|
|
||||||
// id
|
|
||||||
// categories {
|
|
||||||
// id
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `
|
|
||||||
// const expected = {
|
|
||||||
// data: {
|
|
||||||
// Post: [
|
|
||||||
// {
|
|
||||||
// id: 'post-by-followed-user',
|
|
||||||
// categories: [{ id: 'cat9' }],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// variables = { ...variables, filter: { categories_some: { id_in: ['cat9'] } } }
|
|
||||||
// await expect(
|
|
||||||
// query({ query: postQueryFilteredByCategories, variables }),
|
|
||||||
// ).resolves.toMatchObject(expected)
|
|
||||||
// })
|
|
||||||
// Wolle: let followedUser, happyPost, cryPost
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// ;[followedUser] = await Promise.all([
|
|
||||||
// Factory.build(
|
|
||||||
// 'user',
|
|
||||||
// {
|
|
||||||
// id: 'followed-by-me',
|
|
||||||
// name: 'Followed User',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// email: 'followed@example.org',
|
|
||||||
// password: '1234',
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ])
|
|
||||||
// ;[happyPost, cryPost] = await Promise.all([
|
|
||||||
// Factory.build('post', { id: 'happy-post' }, { categoryIds: ['cat4'] }),
|
|
||||||
// Factory.build('post', { id: 'cry-post' }, { categoryIds: ['cat15'] }),
|
|
||||||
// Factory.build(
|
|
||||||
// 'post',
|
|
||||||
// {
|
|
||||||
// id: 'post-by-followed-user',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// categoryIds: ['cat9'],
|
|
||||||
// author: followedUser,
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ])
|
|
||||||
// })
|
|
||||||
// describe('no filter', () => {
|
|
||||||
// it('returns all posts', async () => {
|
|
||||||
// const postQueryNoFilters = gql`
|
|
||||||
// query Post($filter: _PostFilter) {
|
|
||||||
// Post(filter: $filter) {
|
|
||||||
// id
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `
|
|
||||||
// const expected = [{ id: 'happy-post' }, { id: 'cry-post' }, { id: 'post-by-followed-user' }]
|
|
||||||
// variables = { filter: {} }
|
|
||||||
// await expect(query({ query: postQueryNoFilters, variables })).resolves.toMatchObject({
|
|
||||||
// data: {
|
|
||||||
// Post: expect.arrayContaining(expected),
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// describe('by emotions', () => {
|
|
||||||
// const postQueryFilteredByEmotions = gql`
|
|
||||||
// query Post($filter: _PostFilter) {
|
|
||||||
// Post(filter: $filter) {
|
|
||||||
// id
|
|
||||||
// emotions {
|
|
||||||
// emotion
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `
|
|
||||||
// it('filters by single emotion', async () => {
|
|
||||||
// const expected = {
|
|
||||||
// data: {
|
|
||||||
// Post: [
|
|
||||||
// {
|
|
||||||
// id: 'happy-post',
|
|
||||||
// emotions: [{ emotion: 'happy' }],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// await user.relateTo(happyPost, 'emoted', { emotion: 'happy' })
|
|
||||||
// variables = { ...variables, filter: { emotions_some: { emotion_in: ['happy'] } } }
|
|
||||||
// await expect(
|
|
||||||
// query({ query: postQueryFilteredByEmotions, variables }),
|
|
||||||
// ).resolves.toMatchObject(expected)
|
|
||||||
// })
|
|
||||||
// it('filters by multiple emotions', async () => {
|
|
||||||
// const expected = [
|
|
||||||
// {
|
|
||||||
// id: 'happy-post',
|
|
||||||
// emotions: [{ emotion: 'happy' }],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// id: 'cry-post',
|
|
||||||
// emotions: [{ emotion: 'cry' }],
|
|
||||||
// },
|
|
||||||
// ]
|
|
||||||
// await user.relateTo(happyPost, 'emoted', { emotion: 'happy' })
|
|
||||||
// await user.relateTo(cryPost, 'emoted', { emotion: 'cry' })
|
|
||||||
// variables = { ...variables, filter: { emotions_some: { emotion_in: ['happy', 'cry'] } } }
|
|
||||||
// await expect(
|
|
||||||
// query({ query: postQueryFilteredByEmotions, variables }),
|
|
||||||
// ).resolves.toMatchObject({
|
|
||||||
// data: {
|
|
||||||
// Post: expect.arrayContaining(expected),
|
|
||||||
// },
|
|
||||||
// errors: undefined,
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// it('by followed-by', async () => {
|
|
||||||
// const postQueryFilteredByUsersFollowed = gql`
|
|
||||||
// query Post($filter: _PostFilter) {
|
|
||||||
// Post(filter: $filter) {
|
|
||||||
// id
|
|
||||||
// author {
|
|
||||||
// id
|
|
||||||
// name
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `
|
|
||||||
// await user.relateTo(followedUser, 'following')
|
|
||||||
// variables = { filter: { author: { followedBy_some: { id: 'current-user' } } } }
|
|
||||||
// await expect(
|
|
||||||
// query({ query: postQueryFilteredByUsersFollowed, variables }),
|
|
||||||
// ).resolves.toMatchObject({
|
|
||||||
// data: {
|
|
||||||
// Post: [
|
|
||||||
// {
|
|
||||||
// id: 'post-by-followed-user',
|
|
||||||
// author: { id: 'followed-by-me', name: 'Followed User' },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// errors: undefined,
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -406,9 +249,6 @@ describe('CreateGroup', () => {
|
|||||||
CreateGroup: {
|
CreateGroup: {
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
myRole: 'owner',
|
myRole: 'owner',
|
||||||
// Wolle: owner: {
|
|
||||||
// name: 'TestUser',
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -467,301 +307,3 @@ describe('CreateGroup', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// describe('UpdatePost', () => {
|
|
||||||
// let author, newlyCreatedPost
|
|
||||||
// const updatePostMutation = gql`
|
|
||||||
// mutation ($id: ID!, $title: String!, $content: String!, $image: ImageInput) {
|
|
||||||
// UpdatePost(id: $id, title: $title, content: $content, image: $image) {
|
|
||||||
// id
|
|
||||||
// title
|
|
||||||
// content
|
|
||||||
// author {
|
|
||||||
// name
|
|
||||||
// slug
|
|
||||||
// }
|
|
||||||
// createdAt
|
|
||||||
// updatedAt
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// author = await Factory.build('user', { slug: 'the-author' })
|
|
||||||
// newlyCreatedPost = await Factory.build(
|
|
||||||
// 'post',
|
|
||||||
// {
|
|
||||||
// id: 'p9876',
|
|
||||||
// title: 'Old title',
|
|
||||||
// content: 'Old content',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// author,
|
|
||||||
// categoryIds,
|
|
||||||
// },
|
|
||||||
// )
|
|
||||||
|
|
||||||
// variables = {
|
|
||||||
// id: 'p9876',
|
|
||||||
// title: 'New title',
|
|
||||||
// content: 'New content',
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('unauthenticated', () => {
|
|
||||||
// it('throws authorization error', async () => {
|
|
||||||
// authenticatedUser = null
|
|
||||||
// expect(mutate({ mutation: updatePostMutation, variables })).resolves.toMatchObject({
|
|
||||||
// errors: [{ message: 'Not Authorised!' }],
|
|
||||||
// data: { UpdatePost: null },
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('authenticated but not the author', () => {
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// authenticatedUser = await user.toJson()
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('throws authorization error', async () => {
|
|
||||||
// const { errors } = await mutate({ mutation: updatePostMutation, variables })
|
|
||||||
// expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('authenticated as author', () => {
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// authenticatedUser = await author.toJson()
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('updates a post', async () => {
|
|
||||||
// const expected = {
|
|
||||||
// data: { UpdatePost: { id: 'p9876', content: 'New content' } },
|
|
||||||
// errors: undefined,
|
|
||||||
// }
|
|
||||||
// await expect(mutate({ mutation: updatePostMutation, variables })).resolves.toMatchObject(
|
|
||||||
// expected,
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('updates a post, but maintains non-updated attributes', async () => {
|
|
||||||
// const expected = {
|
|
||||||
// data: {
|
|
||||||
// UpdatePost: { id: 'p9876', content: 'New content', createdAt: expect.any(String) },
|
|
||||||
// },
|
|
||||||
// errors: undefined,
|
|
||||||
// }
|
|
||||||
// await expect(mutate({ mutation: updatePostMutation, variables })).resolves.toMatchObject(
|
|
||||||
// expected,
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('updates the updatedAt attribute', async () => {
|
|
||||||
// newlyCreatedPost = await newlyCreatedPost.toJson()
|
|
||||||
// const {
|
|
||||||
// data: { UpdatePost },
|
|
||||||
// } = await mutate({ mutation: updatePostMutation, variables })
|
|
||||||
// expect(newlyCreatedPost.updatedAt).toBeTruthy()
|
|
||||||
// expect(Date.parse(newlyCreatedPost.updatedAt)).toEqual(expect.any(Number))
|
|
||||||
// expect(UpdatePost.updatedAt).toBeTruthy()
|
|
||||||
// expect(Date.parse(UpdatePost.updatedAt)).toEqual(expect.any(Number))
|
|
||||||
// expect(newlyCreatedPost.updatedAt).not.toEqual(UpdatePost.updatedAt)
|
|
||||||
// })
|
|
||||||
|
|
||||||
// /* describe('no new category ids provided for update', () => {
|
|
||||||
// it('resolves and keeps current categories', async () => {
|
|
||||||
// const expected = {
|
|
||||||
// data: {
|
|
||||||
// UpdatePost: {
|
|
||||||
// id: 'p9876',
|
|
||||||
// categories: expect.arrayContaining([{ id: 'cat9' }, { id: 'cat4' }, { id: 'cat15' }]),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// errors: undefined,
|
|
||||||
// }
|
|
||||||
// await expect(mutate({ mutation: updatePostMutation, variables })).resolves.toMatchObject(
|
|
||||||
// expected,
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
// }) */
|
|
||||||
|
|
||||||
// /* describe('given category ids', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// variables = { ...variables, categoryIds: ['cat27'] }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('updates categories of a post', async () => {
|
|
||||||
// const expected = {
|
|
||||||
// data: {
|
|
||||||
// UpdatePost: {
|
|
||||||
// id: 'p9876',
|
|
||||||
// categories: expect.arrayContaining([{ id: 'cat27' }]),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// errors: undefined,
|
|
||||||
// }
|
|
||||||
// await expect(mutate({ mutation: updatePostMutation, variables })).resolves.toMatchObject(
|
|
||||||
// expected,
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
// }) */
|
|
||||||
|
|
||||||
// describe('params.image', () => {
|
|
||||||
// describe('is object', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// variables = { ...variables, image: { sensitive: true } }
|
|
||||||
// })
|
|
||||||
// it('updates the image', async () => {
|
|
||||||
// await expect(neode.first('Image', { sensitive: true })).resolves.toBeFalsy()
|
|
||||||
// await mutate({ mutation: updatePostMutation, variables })
|
|
||||||
// await expect(neode.first('Image', { sensitive: true })).resolves.toBeTruthy()
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('is null', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// variables = { ...variables, image: null }
|
|
||||||
// })
|
|
||||||
// it('deletes the image', async () => {
|
|
||||||
// await expect(neode.all('Image')).resolves.toHaveLength(6)
|
|
||||||
// await mutate({ mutation: updatePostMutation, variables })
|
|
||||||
// await expect(neode.all('Image')).resolves.toHaveLength(5)
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('is undefined', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// delete variables.image
|
|
||||||
// })
|
|
||||||
// it('keeps the image unchanged', async () => {
|
|
||||||
// await expect(neode.first('Image', { sensitive: true })).resolves.toBeFalsy()
|
|
||||||
// await mutate({ mutation: updatePostMutation, variables })
|
|
||||||
// await expect(neode.first('Image', { sensitive: true })).resolves.toBeFalsy()
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('DeletePost', () => {
|
|
||||||
// let author
|
|
||||||
// const deletePostMutation = gql`
|
|
||||||
// mutation ($id: ID!) {
|
|
||||||
// DeletePost(id: $id) {
|
|
||||||
// id
|
|
||||||
// deleted
|
|
||||||
// content
|
|
||||||
// contentExcerpt
|
|
||||||
// image {
|
|
||||||
// url
|
|
||||||
// }
|
|
||||||
// comments {
|
|
||||||
// deleted
|
|
||||||
// content
|
|
||||||
// contentExcerpt
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// `
|
|
||||||
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// author = await Factory.build('user')
|
|
||||||
// await Factory.build(
|
|
||||||
// 'post',
|
|
||||||
// {
|
|
||||||
// id: 'p4711',
|
|
||||||
// title: 'I will be deleted',
|
|
||||||
// content: 'To be deleted',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// image: Factory.build('image', {
|
|
||||||
// url: 'path/to/some/image',
|
|
||||||
// }),
|
|
||||||
// author,
|
|
||||||
// categoryIds,
|
|
||||||
// },
|
|
||||||
// )
|
|
||||||
// variables = { ...variables, id: 'p4711' }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('unauthenticated', () => {
|
|
||||||
// it('throws authorization error', async () => {
|
|
||||||
// const { errors } = await mutate({ mutation: deletePostMutation, variables })
|
|
||||||
// expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('authenticated but not the author', () => {
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// authenticatedUser = await user.toJson()
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('throws authorization error', async () => {
|
|
||||||
// const { errors } = await mutate({ mutation: deletePostMutation, variables })
|
|
||||||
// expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('authenticated as author', () => {
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// authenticatedUser = await author.toJson()
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('marks the post as deleted and blacks out attributes', async () => {
|
|
||||||
// const expected = {
|
|
||||||
// data: {
|
|
||||||
// DeletePost: {
|
|
||||||
// id: 'p4711',
|
|
||||||
// deleted: true,
|
|
||||||
// content: 'UNAVAILABLE',
|
|
||||||
// contentExcerpt: 'UNAVAILABLE',
|
|
||||||
// image: null,
|
|
||||||
// comments: [],
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// await expect(mutate({ mutation: deletePostMutation, variables })).resolves.toMatchObject(
|
|
||||||
// expected,
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
|
|
||||||
// describe('if there are comments on the post', () => {
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// await Factory.build(
|
|
||||||
// 'comment',
|
|
||||||
// {
|
|
||||||
// content: 'to be deleted comment content',
|
|
||||||
// contentExcerpt: 'to be deleted comment content',
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// postId: 'p4711',
|
|
||||||
// },
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
|
|
||||||
// it('marks the comments as deleted', async () => {
|
|
||||||
// const expected = {
|
|
||||||
// data: {
|
|
||||||
// DeletePost: {
|
|
||||||
// id: 'p4711',
|
|
||||||
// deleted: true,
|
|
||||||
// content: 'UNAVAILABLE',
|
|
||||||
// contentExcerpt: 'UNAVAILABLE',
|
|
||||||
// image: null,
|
|
||||||
// comments: [
|
|
||||||
// {
|
|
||||||
// deleted: true,
|
|
||||||
// // Should we black out the comment content in the database, too?
|
|
||||||
// content: 'UNAVAILABLE',
|
|
||||||
// contentExcerpt: 'UNAVAILABLE',
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// await expect(mutate({ mutation: deletePostMutation, variables })).resolves.toMatchObject(
|
|
||||||
// expected,
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
|
|||||||
@ -13,8 +13,6 @@ enum _GroupOrdering {
|
|||||||
createdAt_desc
|
createdAt_desc
|
||||||
updatedAt_asc
|
updatedAt_asc
|
||||||
updatedAt_desc
|
updatedAt_desc
|
||||||
# Wolle: needed? locale_asc
|
|
||||||
# locale_desc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Group {
|
type Group {
|
||||||
@ -40,90 +38,6 @@ type Group {
|
|||||||
categories: [Category] @relation(name: "CATEGORIZED", direction: "OUT")
|
categories: [Category] @relation(name: "CATEGORIZED", direction: "OUT")
|
||||||
|
|
||||||
myRole: GroupMemberRole # if 'null' then the current user is no member
|
myRole: GroupMemberRole # if 'null' then the current user is no member
|
||||||
|
|
||||||
# Wolle: needed?
|
|
||||||
# socialMedia: [SocialMedia]! @relation(name: "OWNED_BY", direction: "IN")
|
|
||||||
|
|
||||||
# Wolle: owner: User @relation(name: "OWNS", direction: "IN")
|
|
||||||
|
|
||||||
# Wolle: showShoutsPublicly: Boolean
|
|
||||||
# Wolle: sendNotificationEmails: Boolean
|
|
||||||
# Wolle: needed? locale: String
|
|
||||||
# members: [User]! @relation(name: "MEMBERS", direction: "OUT")
|
|
||||||
# membersCount: Int!
|
|
||||||
# @cypher(statement: "MATCH (this)-[:MEMBERS]->(r:User) RETURN COUNT(DISTINCT r)")
|
|
||||||
|
|
||||||
# Wolle: followedBy: [User]! @relation(name: "FOLLOWS", direction: "IN")
|
|
||||||
# Wolle: followedByCount: Int!
|
|
||||||
# @cypher(statement: "MATCH (this)<-[:FOLLOWS]-(r:User) RETURN COUNT(DISTINCT r)")
|
|
||||||
|
|
||||||
# Wolle: inviteCodes: [InviteCode] @relation(name: "GENERATED", direction: "OUT")
|
|
||||||
# Wolle: redeemedInviteCode: InviteCode @relation(name: "REDEEMED", direction: "OUT")
|
|
||||||
|
|
||||||
# Is the currently logged in user following that user?
|
|
||||||
# Wolle: followedByCurrentUser: Boolean!
|
|
||||||
# @cypher(
|
|
||||||
# statement: """
|
|
||||||
# MATCH (this)<-[:FOLLOWS]-(u:User { id: $cypherParams.currentUserId})
|
|
||||||
# RETURN COUNT(u) >= 1
|
|
||||||
# """
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Wolle: isBlocked: Boolean!
|
|
||||||
# @cypher(
|
|
||||||
# statement: """
|
|
||||||
# MATCH (this)<-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId})
|
|
||||||
# RETURN COUNT(user) >= 1
|
|
||||||
# """
|
|
||||||
# )
|
|
||||||
# Wolle: blocked: Boolean!
|
|
||||||
# @cypher(
|
|
||||||
# statement: """
|
|
||||||
# MATCH (this)-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId})
|
|
||||||
# RETURN COUNT(user) >= 1
|
|
||||||
# """
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Wolle: isMuted: Boolean!
|
|
||||||
# @cypher(
|
|
||||||
# statement: """
|
|
||||||
# MATCH (this)<-[:MUTED]-(user:User { id: $cypherParams.currentUserId})
|
|
||||||
# RETURN COUNT(user) >= 1
|
|
||||||
# """
|
|
||||||
# )
|
|
||||||
|
|
||||||
# contributions: [WrittenPost]!
|
|
||||||
# contributions2(first: Int = 10, offset: Int = 0): [WrittenPost2]!
|
|
||||||
# @cypher(
|
|
||||||
# statement: "MATCH (this)-[w:WROTE]->(p:Post) RETURN p as Post, w.timestamp as timestamp"
|
|
||||||
# )
|
|
||||||
# Wolle: needed?
|
|
||||||
# contributions: [Post]! @relation(name: "WROTE", direction: "OUT")
|
|
||||||
# contributionsCount: Int!
|
|
||||||
# @cypher(
|
|
||||||
# statement: """
|
|
||||||
# MATCH (this)-[:WROTE]->(r:Post)
|
|
||||||
# WHERE NOT r.deleted = true AND NOT r.disabled = true
|
|
||||||
# RETURN COUNT(r)
|
|
||||||
# """
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Wolle: comments: [Comment]! @relation(name: "WROTE", direction: "OUT")
|
|
||||||
# commentedCount: Int!
|
|
||||||
# @cypher(
|
|
||||||
# statement: "MATCH (this)-[:WROTE]->(:Comment)-[:COMMENTS]->(p:Post) WHERE NOT p.deleted = true AND NOT p.disabled = true RETURN COUNT(DISTINCT(p))"
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Wolle: shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT")
|
|
||||||
# shoutedCount: Int!
|
|
||||||
# @cypher(
|
|
||||||
# statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)"
|
|
||||||
# )
|
|
||||||
|
|
||||||
# Wolle: badges: [Badge]! @relation(name: "REWARDED", direction: "IN")
|
|
||||||
# badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)")
|
|
||||||
|
|
||||||
# Wolle: emotions: [EMOTED]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,39 +55,6 @@ input _GroupFilter {
|
|||||||
id_not: ID
|
id_not: ID
|
||||||
id_in: [ID!]
|
id_in: [ID!]
|
||||||
id_not_in: [ID!]
|
id_not_in: [ID!]
|
||||||
# categories: _CategoryFilter
|
|
||||||
# categories_not: _CategoryFilter
|
|
||||||
# categories_in: [_CategoryFilter!]
|
|
||||||
# categories_not_in: [_CategoryFilter!]
|
|
||||||
# categories_some: _CategoryFilter
|
|
||||||
# categories_none: _CategoryFilter
|
|
||||||
# categories_single: _CategoryFilter
|
|
||||||
# categories_every: _CategoryFilter
|
|
||||||
# Wolle:
|
|
||||||
# friends: _GroupFilter
|
|
||||||
# friends_not: _GroupFilter
|
|
||||||
# friends_in: [_GroupFilter!]
|
|
||||||
# friends_not_in: [_GroupFilter!]
|
|
||||||
# friends_some: _GroupFilter
|
|
||||||
# friends_none: _GroupFilter
|
|
||||||
# friends_single: _GroupFilter
|
|
||||||
# friends_every: _GroupFilter
|
|
||||||
# following: _GroupFilter
|
|
||||||
# following_not: _GroupFilter
|
|
||||||
# following_in: [_GroupFilter!]
|
|
||||||
# following_not_in: [_GroupFilter!]
|
|
||||||
# following_some: _GroupFilter
|
|
||||||
# following_none: _GroupFilter
|
|
||||||
# following_single: _GroupFilter
|
|
||||||
# following_every: _GroupFilter
|
|
||||||
# followedBy: _GroupFilter
|
|
||||||
# followedBy_not: _GroupFilter
|
|
||||||
# followedBy_in: [_GroupFilter!]
|
|
||||||
# followedBy_not_in: [_GroupFilter!]
|
|
||||||
# followedBy_some: _GroupFilter
|
|
||||||
# followedBy_none: _GroupFilter
|
|
||||||
# followedBy_single: _GroupFilter
|
|
||||||
# followedBy_every: _GroupFilter
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
@ -198,32 +79,8 @@ type Query {
|
|||||||
AvailableGroupActionRadii: [GroupActionRadius]!
|
AvailableGroupActionRadii: [GroupActionRadius]!
|
||||||
|
|
||||||
AvailableGroupMemberRoles: [GroupMemberRole]!
|
AvailableGroupMemberRoles: [GroupMemberRole]!
|
||||||
|
|
||||||
# Wolle:
|
|
||||||
# availableRoles: [UserRole]!
|
|
||||||
# mutedUsers: [User]
|
|
||||||
# blockedUsers: [User]
|
|
||||||
# isLoggedIn: Boolean!
|
|
||||||
# currentUser: User
|
|
||||||
# findUsers(query: String!,limit: Int = 10, filter: _GroupFilter): [User]!
|
|
||||||
# @cypher(
|
|
||||||
# statement: """
|
|
||||||
# CALL db.index.fulltext.queryNodes('user_fulltext_search', $query)
|
|
||||||
# YIELD node as post, score
|
|
||||||
# MATCH (user)
|
|
||||||
# WHERE score >= 0.2
|
|
||||||
# AND NOT user.deleted = true AND NOT user.disabled = true
|
|
||||||
# RETURN user
|
|
||||||
# LIMIT $limit
|
|
||||||
# """
|
|
||||||
# )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wolle: enum Deletable {
|
|
||||||
# Post
|
|
||||||
# Comment
|
|
||||||
# }
|
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
CreateGroup(
|
CreateGroup(
|
||||||
id: ID
|
id: ID
|
||||||
@ -236,12 +93,7 @@ type Mutation {
|
|||||||
actionRadius: GroupActionRadius!
|
actionRadius: GroupActionRadius!
|
||||||
categoryIds: [ID]
|
categoryIds: [ID]
|
||||||
locationName: String
|
locationName: String
|
||||||
): # Wolle: add group settings
|
): Group
|
||||||
# Wolle:
|
|
||||||
# showShoutsPublicly: Boolean
|
|
||||||
# sendNotificationEmails: Boolean
|
|
||||||
# locale: String
|
|
||||||
Group
|
|
||||||
|
|
||||||
UpdateGroup(
|
UpdateGroup(
|
||||||
id: ID!
|
id: ID!
|
||||||
@ -251,19 +103,7 @@ type Mutation {
|
|||||||
locationName: String
|
locationName: String
|
||||||
about: String
|
about: String
|
||||||
description: String
|
description: String
|
||||||
): # Wolle:
|
): Group
|
||||||
# showShoutsPublicly: Boolean
|
|
||||||
# sendNotificationEmails: Boolean
|
|
||||||
# locale: String
|
|
||||||
Group
|
|
||||||
|
|
||||||
DeleteGroup(id: ID!): Group
|
DeleteGroup(id: ID!): Group
|
||||||
|
|
||||||
# Wolle:
|
|
||||||
# muteUser(id: ID!): User
|
|
||||||
# unmuteUser(id: ID!): User
|
|
||||||
# blockUser(id: ID!): User
|
|
||||||
# unblockUser(id: ID!): User
|
|
||||||
|
|
||||||
# Wolle: switchUserRole(role: UserRole!, id: ID!): User
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user