mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Merge branch 'master' into dependabot/npm_and_yarn/faker-js/faker-8.0.2
This commit is contained in:
commit
54711d3676
@ -1,25 +1,219 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
es6: true,
|
||||
// es6: true,
|
||||
node: true,
|
||||
jest: true
|
||||
},
|
||||
parserOptions: {
|
||||
/* parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
},
|
||||
},*/
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['prettier', '@typescript-eslint' /*, 'import', 'n', 'promise'*/],
|
||||
extends: [
|
||||
'standard',
|
||||
'plugin:prettier/recommended'
|
||||
// 'eslint:recommended',
|
||||
'plugin:prettier/recommended',
|
||||
// 'plugin:import/recommended',
|
||||
// 'plugin:import/typescript',
|
||||
// 'plugin:security/recommended',
|
||||
// 'plugin:@eslint-community/eslint-comments/recommended',
|
||||
],
|
||||
plugins: [
|
||||
'jest'
|
||||
],
|
||||
rules: {
|
||||
settings: {
|
||||
'import/parsers': {
|
||||
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
||||
},
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
project: ['./tsconfig.json'],
|
||||
},
|
||||
node: true,
|
||||
},
|
||||
},
|
||||
/* rules: {
|
||||
//'indent': [ 'error', 2 ],
|
||||
//'quotes': [ "error", "single"],
|
||||
// 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-console': ['error'],
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'prettier/prettier': ['error'],
|
||||
> 'no-console': ['error'],
|
||||
> 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
> 'prettier/prettier': ['error'],
|
||||
}, */
|
||||
rules: {
|
||||
'no-console': 'error',
|
||||
camelcase: 'error',
|
||||
'no-debugger': 'error',
|
||||
'prettier/prettier': [
|
||||
'error',
|
||||
{
|
||||
htmlWhitespaceSensitivity: 'ignore',
|
||||
},
|
||||
],
|
||||
// import
|
||||
// 'import/export': 'error',
|
||||
// 'import/no-deprecated': 'error',
|
||||
// 'import/no-empty-named-blocks': 'error',
|
||||
// 'import/no-extraneous-dependencies': 'error',
|
||||
// 'import/no-mutable-exports': 'error',
|
||||
// 'import/no-unused-modules': 'error',
|
||||
// 'import/no-named-as-default': 'error',
|
||||
// 'import/no-named-as-default-member': 'error',
|
||||
// 'import/no-amd': 'error',
|
||||
// 'import/no-commonjs': 'error',
|
||||
// 'import/no-import-module-exports': 'error',
|
||||
// 'import/no-nodejs-modules': 'off',
|
||||
// 'import/unambiguous': 'error',
|
||||
// 'import/default': 'error',
|
||||
// 'import/named': 'error',
|
||||
// 'import/namespace': 'error',
|
||||
// 'import/no-absolute-path': 'error',
|
||||
// 'import/no-cycle': 'error',
|
||||
// 'import/no-dynamic-require': 'error',
|
||||
// 'import/no-internal-modules': 'off',
|
||||
// 'import/no-relative-packages': 'error',
|
||||
// 'import/no-relative-parent-imports': ['error', { ignore: ['@/*'] }],
|
||||
// 'import/no-self-import': 'error',
|
||||
// 'import/no-unresolved': 'error',
|
||||
// 'import/no-useless-path-segments': 'error',
|
||||
// 'import/no-webpack-loader-syntax': 'error',
|
||||
// 'import/consistent-type-specifier-style': 'error',
|
||||
// 'import/exports-last': 'off',
|
||||
// 'import/extensions': 'error',
|
||||
// 'import/first': 'error',
|
||||
// 'import/group-exports': 'off',
|
||||
// 'import/newline-after-import': 'error',
|
||||
// 'import/no-anonymous-default-export': 'error',
|
||||
// 'import/no-default-export': 'error',
|
||||
// 'import/no-duplicates': 'error',
|
||||
// 'import/no-named-default': 'error',
|
||||
// 'import/no-namespace': 'error',
|
||||
// 'import/no-unassigned-import': 'error',
|
||||
// 'import/order': [
|
||||
// 'error',
|
||||
// {
|
||||
// groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
|
||||
// 'newlines-between': 'always',
|
||||
// pathGroups: [
|
||||
// {
|
||||
// pattern: '@?*/**',
|
||||
// group: 'external',
|
||||
// position: 'after',
|
||||
// },
|
||||
// {
|
||||
// pattern: '@/**',
|
||||
// group: 'external',
|
||||
// position: 'after',
|
||||
// },
|
||||
// ],
|
||||
// alphabetize: {
|
||||
// order: 'asc' /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
|
||||
// caseInsensitive: true /* ignore case. Options: [true, false] */,
|
||||
// },
|
||||
// distinctGroup: true,
|
||||
// },
|
||||
// ],
|
||||
// 'import/prefer-default-export': 'off',
|
||||
// n
|
||||
// 'n/handle-callback-err': 'error',
|
||||
// 'n/no-callback-literal': 'error',
|
||||
// 'n/no-exports-assign': 'error',
|
||||
// 'n/no-extraneous-import': 'error',
|
||||
// 'n/no-extraneous-require': 'error',
|
||||
// 'n/no-hide-core-modules': 'error',
|
||||
// 'n/no-missing-import': 'off', // not compatible with typescript
|
||||
// 'n/no-missing-require': 'error',
|
||||
// 'n/no-new-require': 'error',
|
||||
// 'n/no-path-concat': 'error',
|
||||
// 'n/no-process-exit': 'error',
|
||||
// 'n/no-unpublished-bin': 'error',
|
||||
// 'n/no-unpublished-import': 'off', // TODO need to exclude seeds
|
||||
// 'n/no-unpublished-require': 'error',
|
||||
// 'n/no-unsupported-features': ['error', { ignores: ['modules'] }],
|
||||
// 'n/no-unsupported-features/es-builtins': 'error',
|
||||
// 'n/no-unsupported-features/es-syntax': 'error',
|
||||
// 'n/no-unsupported-features/node-builtins': 'error',
|
||||
// 'n/process-exit-as-throw': 'error',
|
||||
// 'n/shebang': 'error',
|
||||
// 'n/callback-return': 'error',
|
||||
// 'n/exports-style': 'error',
|
||||
// 'n/file-extension-in-import': 'off',
|
||||
// 'n/global-require': 'error',
|
||||
// 'n/no-mixed-requires': 'error',
|
||||
// 'n/no-process-env': 'error',
|
||||
// 'n/no-restricted-import': 'error',
|
||||
// 'n/no-restricted-require': 'error',
|
||||
// 'n/no-sync': 'error',
|
||||
// 'n/prefer-global/buffer': 'error',
|
||||
// 'n/prefer-global/console': 'error',
|
||||
// 'n/prefer-global/process': 'error',
|
||||
// 'n/prefer-global/text-decoder': 'error',
|
||||
// 'n/prefer-global/text-encoder': 'error',
|
||||
// 'n/prefer-global/url': 'error',
|
||||
// 'n/prefer-global/url-search-params': 'error',
|
||||
// 'n/prefer-promises/dns': 'error',
|
||||
// 'n/prefer-promises/fs': 'error',
|
||||
// promise
|
||||
// 'promise/catch-or-return': 'error',
|
||||
// 'promise/no-return-wrap': 'error',
|
||||
// 'promise/param-names': 'error',
|
||||
// 'promise/always-return': 'error',
|
||||
// 'promise/no-native': 'off',
|
||||
// 'promise/no-nesting': 'warn',
|
||||
// 'promise/no-promise-in-callback': 'warn',
|
||||
// 'promise/no-callback-in-promise': 'warn',
|
||||
// 'promise/avoid-new': 'warn',
|
||||
// 'promise/no-new-statics': 'error',
|
||||
// 'promise/no-return-in-finally': 'warn',
|
||||
// 'promise/valid-params': 'warn',
|
||||
// 'promise/prefer-await-to-callbacks': 'error',
|
||||
// 'promise/no-multiple-resolved': 'error',
|
||||
// eslint comments
|
||||
// '@eslint-community/eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
|
||||
// '@eslint-community/eslint-comments/no-restricted-disable': 'error',
|
||||
// '@eslint-community/eslint-comments/no-use': 'off',
|
||||
// '@eslint-community/eslint-comments/require-description': 'off',
|
||||
},
|
||||
overrides: [
|
||||
// only for ts files
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
extends: [
|
||||
// 'plugin:@typescript-eslint/recommended',
|
||||
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||
// 'plugin:@typescript-eslint/strict',
|
||||
],
|
||||
rules: {
|
||||
// allow explicitly defined dangling promises
|
||||
// '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
|
||||
'no-void': ['error', { allowAsStatement: true }],
|
||||
// ignore prefer-regexp-exec rule to allow string.match(regex)
|
||||
'@typescript-eslint/prefer-regexp-exec': 'off',
|
||||
// this should not run on ts files: https://github.com/import-js/eslint-plugin-import/issues/2215#issuecomment-911245486
|
||||
'import/unambiguous': 'off',
|
||||
// this is not compatible with typeorm, due to joined tables can be null, but are not defined as nullable
|
||||
'@typescript-eslint/no-unnecessary-condition': 'off',
|
||||
},
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: ['./tsconfig.json'],
|
||||
// this is to properly reference the referenced project database without requirement of compiling it
|
||||
// eslint-disable-next-line camelcase
|
||||
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.spec.ts'],
|
||||
plugins: ['jest'],
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
rules: {
|
||||
'jest/no-disabled-tests': 'error',
|
||||
'jest/no-focused-tests': 'error',
|
||||
'jest/no-identical-title': 'error',
|
||||
'jest/prefer-to-have-length': 'error',
|
||||
'jest/valid-expect': 'error',
|
||||
'@typescript-eslint/unbound-method': 'off',
|
||||
// 'jest/unbound-method': 'error',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
"__migrate": "migrate --compiler 'ts:./src/db/compiler.ts' --migrations-dir ./src/db/migrations",
|
||||
"prod:migrate": "migrate --migrations-dir ./build/db/migrations --store ./build/db/migrate/store.js",
|
||||
"start": "node build/",
|
||||
"prod:migrate": "migrate --migrations-dir ./build/src/db/migrations --store ./build/src/db/migrate/store.js",
|
||||
"start": "node build/src/",
|
||||
"build": "tsc && ./scripts/build.copy.files.sh",
|
||||
"dev": "nodemon --exec ts-node src/ -e js,ts,gql",
|
||||
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/ -e js,ts,gql",
|
||||
"lint": "eslint src --config .eslintrc.js",
|
||||
"lint": "eslint --max-warnings=0 --ext .js,.ts ./src",
|
||||
"test": "cross-env NODE_ENV=test NODE_OPTIONS=--max-old-space-size=8192 jest --runInBand --coverage --forceExit --detectOpenHandles",
|
||||
"db:clean": "ts-node src/db/clean.ts",
|
||||
"db:reset": "yarn run db:clean",
|
||||
@ -45,7 +45,6 @@
|
||||
"cheerio": "~1.0.0-rc.3",
|
||||
"cors": "~2.8.5",
|
||||
"cross-env": "~7.0.3",
|
||||
"debug": "~4.1.1",
|
||||
"dotenv": "~8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"graphql": "^14.6.0",
|
||||
@ -97,27 +96,30 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@faker-js/faker": "7.6.0",
|
||||
"@types/jest": "^29.5.2",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/node": "^20.2.5",
|
||||
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
||||
"@typescript-eslint/parser": "^5.57.1",
|
||||
"apollo-server-testing": "~2.11.0",
|
||||
"chai": "~4.2.0",
|
||||
"cucumber": "~6.0.5",
|
||||
"eslint": "~6.8.0",
|
||||
"eslint-config-prettier": "~6.15.0",
|
||||
"eslint-config-standard": "~14.1.1",
|
||||
"eslint-plugin-import": "~2.20.2",
|
||||
"eslint-plugin-jest": "~23.8.2",
|
||||
"eslint-plugin-node": "~11.1.0",
|
||||
"eslint-plugin-prettier": "~3.4.1",
|
||||
"eslint-plugin-promise": "~4.3.1",
|
||||
"eslint-plugin-standard": "~4.0.1",
|
||||
"jest": "29.4",
|
||||
"eslint": "^8.37.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.4",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-n": "^15.7.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"eslint-plugin-security": "^1.7.1",
|
||||
"prettier": "^2.8.7",
|
||||
"jest": "^27.2.4",
|
||||
"nodemon": "~2.0.2",
|
||||
"prettier": "~2.3.2",
|
||||
"rosie": "^2.0.1",
|
||||
"ts-jest": "^29.1.0",
|
||||
"ts-jest": "^27.0.5",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.0.4"
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"**/**/fs-capacitor": "^6.2.0",
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# html files
|
||||
mkdir -p build/middleware/helpers/email/templates/
|
||||
cp -r src/middleware/helpers/email/templates/*.html build/middleware/helpers/email/templates/
|
||||
mkdir -p build/src/middleware/helpers/email/templates/
|
||||
cp -r src/middleware/helpers/email/templates/*.html build/src/middleware/helpers/email/templates/
|
||||
|
||||
mkdir -p build/middleware/helpers/email/templates/en/
|
||||
cp -r src/middleware/helpers/email/templates/en/*.html build/middleware/helpers/email/templates/en/
|
||||
mkdir -p build/src/middleware/helpers/email/templates/en/
|
||||
cp -r src/middleware/helpers/email/templates/en/*.html build/src/middleware/helpers/email/templates/en/
|
||||
|
||||
mkdir -p build/middleware/helpers/email/templates/de/
|
||||
cp -r src/middleware/helpers/email/templates/de/*.html build/middleware/helpers/email/templates/de/
|
||||
mkdir -p build/src/middleware/helpers/email/templates/de/
|
||||
cp -r src/middleware/helpers/email/templates/de/*.html build/src/middleware/helpers/email/templates/de/
|
||||
|
||||
# gql files
|
||||
mkdir -p build/schema/types/
|
||||
cp -r src/schema/types/*.gql build/schema/types/
|
||||
mkdir -p build/src/schema/types/
|
||||
cp -r src/schema/types/*.gql build/src/schema/types/
|
||||
|
||||
mkdir -p build/schema/types/enum/
|
||||
cp -r src/schema/types/enum/*.gql build/schema/types/enum/
|
||||
mkdir -p build/src/schema/types/enum/
|
||||
cp -r src/schema/types/enum/*.gql build/src/schema/types/enum/
|
||||
|
||||
mkdir -p build/schema/types/scalar/
|
||||
cp -r src/schema/types/scalar/*.gql build/schema/types/scalar/
|
||||
mkdir -p build/src/schema/types/scalar/
|
||||
cp -r src/schema/types/scalar/*.gql build/src/schema/types/scalar/
|
||||
|
||||
mkdir -p build/schema/types/type/
|
||||
cp -r src/schema/types/type/*.gql build/schema/types/type/
|
||||
mkdir -p build/src/schema/types/type/
|
||||
cp -r src/schema/types/type/*.gql build/src/schema/types/type/
|
||||
@ -15,7 +15,7 @@ if (require.resolve) {
|
||||
}
|
||||
|
||||
// Use Cypress env or process.env
|
||||
declare var Cypress: any | undefined
|
||||
declare let Cypress: any | undefined
|
||||
const env = typeof Cypress !== 'undefined' ? Cypress.env() : process.env // eslint-disable-line no-undef
|
||||
|
||||
const environment = {
|
||||
@ -95,6 +95,7 @@ Object.entries(required).map((entry) => {
|
||||
if (!entry[1]) {
|
||||
throw new Error(`ERROR: "${entry[0]}" env variable is missing.`)
|
||||
}
|
||||
return entry
|
||||
})
|
||||
|
||||
export default {
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
const tsNode = require('ts-node');
|
||||
module.exports = tsNode.register;
|
||||
const tsNode = require('ts-node')
|
||||
module.exports = tsNode.register
|
||||
|
||||
@ -278,7 +278,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
||||
|
||||
await Promise.all(
|
||||
categories.map(({ icon, name }, index) => {
|
||||
Factory.build('category', {
|
||||
return Factory.build('category', {
|
||||
id: `cat${index + 1}`,
|
||||
slug: name,
|
||||
name,
|
||||
@ -1112,7 +1112,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
||||
const reportAgainstDewey = reports[3]
|
||||
|
||||
// report resource first time
|
||||
|
||||
|
||||
await reportAgainstDagobert.relateTo(jennyRostock, 'filed', {
|
||||
resourceId: 'u7',
|
||||
reasonCategory: 'discrimination_etc',
|
||||
|
||||
@ -2,14 +2,8 @@ import gql from 'graphql-tag'
|
||||
|
||||
export const createMessageMutation = () => {
|
||||
return gql`
|
||||
mutation (
|
||||
$roomId: ID!
|
||||
$content: String!
|
||||
) {
|
||||
CreateMessage(
|
||||
roomId: $roomId
|
||||
content: $content
|
||||
) {
|
||||
mutation ($roomId: ID!, $content: String!) {
|
||||
CreateMessage(roomId: $roomId, content: $content) {
|
||||
id
|
||||
content
|
||||
}
|
||||
@ -19,7 +13,7 @@ export const createMessageMutation = () => {
|
||||
|
||||
export const messageQuery = () => {
|
||||
return gql`
|
||||
query($roomId: ID!) {
|
||||
query ($roomId: ID!) {
|
||||
Message(roomId: $roomId) {
|
||||
_id
|
||||
id
|
||||
|
||||
@ -2,12 +2,8 @@ import gql from 'graphql-tag'
|
||||
|
||||
export const createRoomMutation = () => {
|
||||
return gql`
|
||||
mutation (
|
||||
$userId: ID!
|
||||
) {
|
||||
CreateRoom(
|
||||
userId: $userId
|
||||
) {
|
||||
mutation ($userId: ID!) {
|
||||
CreateRoom(userId: $userId) {
|
||||
id
|
||||
roomId
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import cheerio from 'cheerio'
|
||||
|
||||
export default (content) => {
|
||||
export default (content?) => {
|
||||
if (!content) return []
|
||||
const $ = cheerio.load(content)
|
||||
const userIds = $('a.mention[data-mention-id]')
|
||||
|
||||
@ -50,7 +50,7 @@ beforeAll(async () => {
|
||||
context: () => {
|
||||
return {
|
||||
user: authenticatedUser,
|
||||
neode: neode,
|
||||
neode,
|
||||
driver,
|
||||
}
|
||||
},
|
||||
|
||||
@ -140,16 +140,18 @@ const postAuthorOfComment = async (commentId, { context }) => {
|
||||
|
||||
const notifyOwnersOfGroup = async (groupId, userId, reason, context) => {
|
||||
const cypher = `
|
||||
MATCH (user:User { id: $userId })
|
||||
MATCH (group:Group { id: $groupId })<-[membership:MEMBER_OF]-(owner:User)
|
||||
WHERE membership.role = 'owner'
|
||||
WITH owner, group
|
||||
WITH owner, group, user, membership
|
||||
MERGE (group)-[notification:NOTIFIED {reason: $reason}]->(owner)
|
||||
WITH group, owner, notification
|
||||
WITH group, owner, notification, user, membership
|
||||
SET notification.read = FALSE
|
||||
SET notification.createdAt = COALESCE(notification.createdAt, toString(datetime()))
|
||||
SET notification.updatedAt = toString(datetime())
|
||||
SET notification.relatedUserId = $userId
|
||||
RETURN notification {.*, from: group, to: properties(owner)}
|
||||
WITH owner, group { __typename: 'Group', .*, myRole: membership.roleInGroup } AS finalGroup, user, notification
|
||||
RETURN notification {.*, from: finalGroup, to: properties(owner), relatedUser: properties(user) }
|
||||
`
|
||||
const session = context.driver.session()
|
||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||
@ -173,16 +175,20 @@ const notifyOwnersOfGroup = async (groupId, userId, reason, context) => {
|
||||
const notifyMemberOfGroup = async (groupId, userId, reason, context) => {
|
||||
const { user: owner } = context
|
||||
const cypher = `
|
||||
MATCH (owner:User { id: $ownerId })
|
||||
MATCH (user:User { id: $userId })
|
||||
MATCH (group:Group { id: $groupId })
|
||||
WITH user, group
|
||||
OPTIONAL MATCH (user)-[membership:MEMBER_OF]->(group)
|
||||
WITH user, group, owner, membership
|
||||
MERGE (group)-[notification:NOTIFIED {reason: $reason}]->(user)
|
||||
WITH group, user, notification
|
||||
WITH group, user, notification, owner, membership
|
||||
SET notification.read = FALSE
|
||||
SET notification.createdAt = COALESCE(notification.createdAt, toString(datetime()))
|
||||
SET notification.updatedAt = toString(datetime())
|
||||
SET notification.relatedUserId = $ownerId
|
||||
RETURN notification {.*, from: group, to: properties(user)}
|
||||
WITH group { __typename: 'Group', .*, myRole: membership.roleInGroup } AS finalGroup,
|
||||
notification, user, owner
|
||||
RETURN notification {.*, from: finalGroup, to: properties(user), relatedUser: properties(owner) }
|
||||
`
|
||||
const session = context.driver.session()
|
||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||
@ -242,7 +248,7 @@ const notifyUsersOfMention = async (label, id, idsOfUsers, reason, context) => {
|
||||
SET notification.read = FALSE
|
||||
SET notification.createdAt = COALESCE(notification.createdAt, toString(datetime()))
|
||||
SET notification.updatedAt = toString(datetime())
|
||||
RETURN notification {.*, from: finalResource, to: properties(user)}
|
||||
RETURN notification {.*, from: finalResource, to: properties(user), relatedUser: properties(user) }
|
||||
`
|
||||
const session = context.driver.session()
|
||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||
@ -276,9 +282,14 @@ const notifyUsersOfComment = async (label, commentId, postAuthorId, reason, cont
|
||||
SET notification.read = FALSE
|
||||
SET notification.createdAt = COALESCE(notification.createdAt, toString(datetime()))
|
||||
SET notification.updatedAt = toString(datetime())
|
||||
WITH notification, postAuthor, post,
|
||||
WITH notification, postAuthor, post, commenter,
|
||||
comment {.*, __typename: labels(comment)[0], author: properties(commenter), post: post {.*, author: properties(postAuthor) } } AS finalResource
|
||||
RETURN notification {.*, from: finalResource, to: properties(postAuthor)}
|
||||
RETURN notification {
|
||||
.*,
|
||||
from: finalResource,
|
||||
to: properties(postAuthor),
|
||||
relatedUser: properties(commenter)
|
||||
}
|
||||
`,
|
||||
{ commentId, postAuthorId, reason },
|
||||
)
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import uniqueSlug from './uniqueSlug'
|
||||
|
||||
describe('uniqueSlug', () => {
|
||||
it('slugifies given string', () => {
|
||||
it('slugifies given string', async () => {
|
||||
const string = 'Hello World'
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world')
|
||||
await expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world')
|
||||
})
|
||||
|
||||
it('increments slugified string until unique', () => {
|
||||
it('increments slugified string until unique', async () => {
|
||||
const string = 'Hello World'
|
||||
const isUnique = jest.fn().mockResolvedValueOnce(false).mockResolvedValueOnce(true)
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world-1')
|
||||
await expect(uniqueSlug(string, isUnique)).resolves.toEqual('hello-world-1')
|
||||
})
|
||||
|
||||
it('slugify null string', () => {
|
||||
it('slugify null string', async () => {
|
||||
const string = null
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
expect(uniqueSlug(string, isUnique)).resolves.toEqual('anonymous')
|
||||
await expect(uniqueSlug(string, isUnique)).resolves.toEqual('anonymous')
|
||||
})
|
||||
|
||||
it('Converts umlaut to a two letter equivalent', async () => {
|
||||
|
||||
@ -1,38 +1,29 @@
|
||||
// NOTE: We cannot use `fs` here to clean up the code. Cypress breaks on any npm
|
||||
// module that is not browser-compatible. Node's `fs` module is server-side only
|
||||
declare var Cypress: any | undefined
|
||||
declare let Cypress: any | undefined
|
||||
export default {
|
||||
Image: typeof Cypress !== 'undefined' ? require('./Image') : require('./Image').default,
|
||||
Badge: typeof Cypress !== 'undefined' ? require('./Badge') : require('./Badge').default,
|
||||
User: typeof Cypress !== 'undefined' ? require('./User') : require('./User').default,
|
||||
Group: typeof Cypress !== 'undefined' ? require('./Group') : require('./Group').default,
|
||||
EmailAddress:
|
||||
typeof Cypress !== 'undefined'
|
||||
? require('./EmailAddress')
|
||||
: require('./EmailAddress').default,
|
||||
typeof Cypress !== 'undefined' ? require('./EmailAddress') : require('./EmailAddress').default,
|
||||
UnverifiedEmailAddress:
|
||||
typeof Cypress !== 'undefined'
|
||||
? require('./UnverifiedEmailAddress')
|
||||
: require('./UnverifiedEmailAddress').default,
|
||||
SocialMedia:
|
||||
typeof Cypress !== 'undefined'
|
||||
? require('./SocialMedia')
|
||||
: require('./SocialMedia').default,
|
||||
typeof Cypress !== 'undefined' ? require('./SocialMedia') : require('./SocialMedia').default,
|
||||
Post: typeof Cypress !== 'undefined' ? require('./Post') : require('./Post').default,
|
||||
Comment:
|
||||
typeof Cypress !== 'undefined' ? require('./Comment') : require('./Comment').default,
|
||||
Category:
|
||||
typeof Cypress !== 'undefined' ? require('./Category') : require('./Category').default,
|
||||
Comment: typeof Cypress !== 'undefined' ? require('./Comment') : require('./Comment').default,
|
||||
Category: typeof Cypress !== 'undefined' ? require('./Category') : require('./Category').default,
|
||||
Tag: typeof Cypress !== 'undefined' ? require('./Tag') : require('./Tag').default,
|
||||
Location:
|
||||
typeof Cypress !== 'undefined' ? require('./Location') : require('./Location').default,
|
||||
Location: typeof Cypress !== 'undefined' ? require('./Location') : require('./Location').default,
|
||||
Donations:
|
||||
typeof Cypress !== 'undefined' ? require('./Donations') : require('./Donations').default,
|
||||
Report: typeof Cypress !== 'undefined' ? require('./Report') : require('./Report').default,
|
||||
Migration:
|
||||
typeof Cypress !== 'undefined' ? require('./Migration') : require('./Migration').default,
|
||||
InviteCode:
|
||||
typeof Cypress !== 'undefined'
|
||||
? require('./InviteCode')
|
||||
: require('./InviteCode').default,
|
||||
typeof Cypress !== 'undefined' ? require('./InviteCode') : require('./InviteCode').default,
|
||||
}
|
||||
|
||||
@ -170,6 +170,7 @@ describe('mergeImage', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
it.skip('automatically creates different image sizes', async () => {
|
||||
await expect(
|
||||
mergeImage(post, 'HERO_IMAGE', imageInput, { uploadCallback, deleteCallback }),
|
||||
|
||||
@ -34,43 +34,40 @@ afterAll(async () => {
|
||||
driver.close()
|
||||
})
|
||||
|
||||
|
||||
describe('Message', () => {
|
||||
let roomId: string
|
||||
|
||||
beforeAll(async () => {
|
||||
[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([
|
||||
Factory.build(
|
||||
'user',
|
||||
{
|
||||
id: 'chatting-user',
|
||||
name: 'Chatting User',
|
||||
},
|
||||
),
|
||||
Factory.build(
|
||||
'user',
|
||||
{
|
||||
id: 'other-chatting-user',
|
||||
name: 'Other Chatting User',
|
||||
},
|
||||
),
|
||||
Factory.build(
|
||||
'user',
|
||||
{
|
||||
id: 'not-chatting-user',
|
||||
name: 'Not Chatting User',
|
||||
},
|
||||
),
|
||||
;[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([
|
||||
Factory.build('user', {
|
||||
id: 'chatting-user',
|
||||
name: 'Chatting User',
|
||||
}),
|
||||
Factory.build('user', {
|
||||
id: 'other-chatting-user',
|
||||
name: 'Other Chatting User',
|
||||
}),
|
||||
Factory.build('user', {
|
||||
id: 'not-chatting-user',
|
||||
name: 'Not Chatting User',
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
describe('create message', () => {
|
||||
describe('unauthenticated', () => {
|
||||
it('throws authorization error', async () => {
|
||||
await expect(mutate({ mutation: createMessageMutation(), variables: {
|
||||
roomId: 'some-id', content: 'Some bla bla bla', } })).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createMessageMutation(),
|
||||
variables: {
|
||||
roomId: 'some-id',
|
||||
content: 'Some bla bla bla',
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -81,13 +78,20 @@ describe('Message', () => {
|
||||
|
||||
describe('room does not exist', () => {
|
||||
it('returns null', async () => {
|
||||
await expect(mutate({ mutation: createMessageMutation(), variables: {
|
||||
roomId: 'some-id', content: 'Some bla bla bla', } })).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateMessage: null,
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createMessageMutation(),
|
||||
variables: {
|
||||
roomId: 'some-id',
|
||||
content: 'Some bla bla bla',
|
||||
},
|
||||
})
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateMessage: null,
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -104,20 +108,23 @@ describe('Message', () => {
|
||||
|
||||
describe('user chats in room', () => {
|
||||
it('returns the message', async () => {
|
||||
await expect(mutate({
|
||||
mutation: createMessageMutation(),
|
||||
variables: {
|
||||
roomId,
|
||||
content: 'Some nice message to other chatting user',
|
||||
} })).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateMessage: {
|
||||
id: expect.any(String),
|
||||
content: 'Some nice message to other chatting user',
|
||||
},
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createMessageMutation(),
|
||||
variables: {
|
||||
roomId,
|
||||
content: 'Some nice message to other chatting user',
|
||||
},
|
||||
})
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateMessage: {
|
||||
id: expect.any(String),
|
||||
content: 'Some nice message to other chatting user',
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -125,19 +132,22 @@ describe('Message', () => {
|
||||
beforeAll(async () => {
|
||||
authenticatedUser = await notChattingUser.toJson()
|
||||
})
|
||||
|
||||
|
||||
it('returns null', async () => {
|
||||
await expect(mutate({
|
||||
mutation: createMessageMutation(),
|
||||
variables: {
|
||||
roomId,
|
||||
content: 'I have no access to this room!',
|
||||
} })).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateMessage: null,
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createMessageMutation(),
|
||||
variables: {
|
||||
roomId,
|
||||
content: 'I have no access to this room!',
|
||||
},
|
||||
})
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateMessage: null,
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -151,14 +161,17 @@ describe('Message', () => {
|
||||
})
|
||||
|
||||
it('throws authorization error', async () => {
|
||||
await expect(query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId: 'some-id' }
|
||||
})).resolves.toMatchObject({
|
||||
await expect(
|
||||
query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId: 'some-id',
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('authenticated', () => {
|
||||
@ -168,12 +181,14 @@ describe('Message', () => {
|
||||
|
||||
describe('room does not exists', () => {
|
||||
it('returns null', async () => {
|
||||
await expect(query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId: 'some-id'
|
||||
},
|
||||
})).resolves.toMatchObject({
|
||||
await expect(
|
||||
query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId: 'some-id',
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
Message: [],
|
||||
@ -193,15 +208,17 @@ describe('Message', () => {
|
||||
expect(result).toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
Message: [{
|
||||
id: expect.any(String),
|
||||
_id: result.data.Message[0].id,
|
||||
content: 'Some nice message to other chatting user',
|
||||
senderId: 'chatting-user',
|
||||
username: 'Chatting User',
|
||||
avatar: expect.any(String),
|
||||
date: expect.any(String),
|
||||
}],
|
||||
Message: [
|
||||
{
|
||||
id: expect.any(String),
|
||||
_id: result.data.Message[0].id,
|
||||
content: 'Some nice message to other chatting user',
|
||||
senderId: 'chatting-user',
|
||||
username: 'Chatting User',
|
||||
avatar: expect.any(String),
|
||||
date: expect.any(String),
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
})
|
||||
@ -213,7 +230,7 @@ describe('Message', () => {
|
||||
variables: {
|
||||
roomId,
|
||||
content: 'A nice response message to chatting user',
|
||||
}
|
||||
},
|
||||
})
|
||||
authenticatedUser = await chattingUser.toJson()
|
||||
await mutate({
|
||||
@ -221,49 +238,51 @@ describe('Message', () => {
|
||||
variables: {
|
||||
roomId,
|
||||
content: 'And another nice message to other chatting user',
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('returns the messages', async () => {
|
||||
await expect(query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId,
|
||||
},
|
||||
})).resolves.toMatchObject({
|
||||
})
|
||||
})
|
||||
|
||||
it('returns the messages', async () => {
|
||||
await expect(
|
||||
query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId,
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
Message: [
|
||||
{
|
||||
Message: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
content: 'Some nice message to other chatting user',
|
||||
senderId: 'chatting-user',
|
||||
username: 'Chatting User',
|
||||
avatar: expect.any(String),
|
||||
date: expect.any(String),
|
||||
},
|
||||
{
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
content: 'A nice response message to chatting user',
|
||||
senderId: 'other-chatting-user',
|
||||
username: 'Other Chatting User',
|
||||
avatar: expect.any(String),
|
||||
date: expect.any(String),
|
||||
},
|
||||
{
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
content: 'And another nice message to other chatting user',
|
||||
senderId: 'chatting-user',
|
||||
username: 'Chatting User',
|
||||
avatar: expect.any(String),
|
||||
date: expect.any(String),
|
||||
},
|
||||
],
|
||||
}),
|
||||
]),
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('room exists, authenticated user not in room', () => {
|
||||
@ -272,19 +291,21 @@ describe('Message', () => {
|
||||
})
|
||||
|
||||
it('returns null', async () => {
|
||||
await expect(query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId,
|
||||
},
|
||||
})).resolves.toMatchObject({
|
||||
await expect(
|
||||
query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId,
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
Message: [],
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -25,7 +25,9 @@ export default {
|
||||
Mutation: {
|
||||
CreateMessage: async (_parent, params, context, _resolveInfo) => {
|
||||
const { roomId, content } = params
|
||||
const { user: { id: currentUserId } } = context
|
||||
const {
|
||||
user: { id: currentUserId },
|
||||
} = context
|
||||
const session = context.driver.session()
|
||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||
const createMessageCypher = `
|
||||
@ -37,13 +39,14 @@ export default {
|
||||
})-[:INSIDE]->(room)
|
||||
RETURN message { .* }
|
||||
`
|
||||
const createMessageTxResponse = await transaction.run(
|
||||
createMessageCypher,
|
||||
{ currentUserId, roomId, content }
|
||||
)
|
||||
const createMessageTxResponse = await transaction.run(createMessageCypher, {
|
||||
currentUserId,
|
||||
roomId,
|
||||
content,
|
||||
})
|
||||
const [message] = await createMessageTxResponse.records.map((record) =>
|
||||
record.get('message'),
|
||||
)
|
||||
record.get('message'),
|
||||
)
|
||||
return message
|
||||
})
|
||||
try {
|
||||
@ -53,7 +56,7 @@ export default {
|
||||
throw new Error(error)
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
Message: {
|
||||
@ -61,7 +64,7 @@ export default {
|
||||
hasOne: {
|
||||
author: '<-[:CREATED]-(related:User)',
|
||||
room: '-[:INSIDE]->(related:Room)',
|
||||
}
|
||||
},
|
||||
}),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ describe('given some notifications', () => {
|
||||
variables: { ...variables, read: false },
|
||||
})
|
||||
await expect(response).toMatchObject(expected)
|
||||
await expect(response.data.notifications.length).toEqual(2) // double-check
|
||||
await expect(response.data.notifications).toHaveLength(2) // double-check
|
||||
})
|
||||
|
||||
describe('if a resource gets deleted', () => {
|
||||
|
||||
@ -907,6 +907,7 @@ describe('UpdatePost', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// eslint-disable-next-line jest/no-disabled-tests
|
||||
describe.skip('params.image', () => {
|
||||
describe('is object', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -28,7 +28,7 @@ export default {
|
||||
},
|
||||
SignupVerification: async (_parent, args, context) => {
|
||||
const { termsAndConditionsAgreedVersion } = args
|
||||
const regEx = new RegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/g)
|
||||
const regEx = /^[0-9]+\.[0-9]+\.[0-9]+$/g
|
||||
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
||||
throw new UserInputError('Invalid version format!')
|
||||
}
|
||||
|
||||
@ -728,7 +728,7 @@ describe('file a report on a resource', () => {
|
||||
describe('unauthenticated', () => {
|
||||
it('throws authorization error', async () => {
|
||||
authenticatedUser = null
|
||||
expect(query({ query: reportsQuery })).resolves.toMatchObject({
|
||||
await expect(query({ query: reportsQuery })).resolves.toMatchObject({
|
||||
data: { reports: null },
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
@ -738,7 +738,7 @@ describe('file a report on a resource', () => {
|
||||
describe('authenticated', () => {
|
||||
it('role "user" gets no reports', async () => {
|
||||
authenticatedUser = await currentUser.toJson()
|
||||
expect(query({ query: reportsQuery })).resolves.toMatchObject({
|
||||
await expect(query({ query: reportsQuery })).resolves.toMatchObject({
|
||||
data: { reports: null },
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
|
||||
@ -35,56 +35,55 @@ afterAll(async () => {
|
||||
|
||||
describe('Room', () => {
|
||||
beforeAll(async () => {
|
||||
[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([
|
||||
Factory.build(
|
||||
'user',
|
||||
{
|
||||
id: 'chatting-user',
|
||||
name: 'Chatting User',
|
||||
},
|
||||
),
|
||||
Factory.build(
|
||||
'user',
|
||||
{
|
||||
id: 'other-chatting-user',
|
||||
name: 'Other Chatting User',
|
||||
},
|
||||
),
|
||||
Factory.build(
|
||||
'user',
|
||||
{
|
||||
id: 'not-chatting-user',
|
||||
name: 'Not Chatting User',
|
||||
},
|
||||
),
|
||||
;[chattingUser, otherChattingUser, notChattingUser] = await Promise.all([
|
||||
Factory.build('user', {
|
||||
id: 'chatting-user',
|
||||
name: 'Chatting User',
|
||||
}),
|
||||
Factory.build('user', {
|
||||
id: 'other-chatting-user',
|
||||
name: 'Other Chatting User',
|
||||
}),
|
||||
Factory.build('user', {
|
||||
id: 'not-chatting-user',
|
||||
name: 'Not Chatting User',
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
describe('create room', () => {
|
||||
describe('unauthenticated', () => {
|
||||
it('throws authorization error', async () => {
|
||||
await expect(mutate({ mutation: createRoomMutation(), variables: {
|
||||
userId: 'some-id' } })).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createRoomMutation(),
|
||||
variables: {
|
||||
userId: 'some-id',
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('authenticated', () => {
|
||||
let roomId: string
|
||||
|
||||
|
||||
beforeAll(async () => {
|
||||
authenticatedUser = await chattingUser.toJson()
|
||||
})
|
||||
|
||||
describe('user id does not exist', () => {
|
||||
it('returns null', async () => {
|
||||
await expect(mutate({
|
||||
mutation: createRoomMutation(),
|
||||
variables: {
|
||||
userId: 'not-existing-user',
|
||||
},
|
||||
})).resolves.toMatchObject({
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createRoomMutation(),
|
||||
variables: {
|
||||
userId: 'not-existing-user',
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateRoom: null,
|
||||
@ -92,7 +91,7 @@ describe('Room', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('user id exists', () => {
|
||||
it('returns the id of the room', async () => {
|
||||
const result = await mutate({
|
||||
@ -116,12 +115,14 @@ describe('Room', () => {
|
||||
|
||||
describe('create room with same user id', () => {
|
||||
it('returns the id of the room', async () => {
|
||||
await expect(mutate({
|
||||
mutation: createRoomMutation(),
|
||||
variables: {
|
||||
userId: 'other-chatting-user',
|
||||
},
|
||||
})).resolves.toMatchObject({
|
||||
await expect(
|
||||
mutate({
|
||||
mutation: createRoomMutation(),
|
||||
variables: {
|
||||
userId: 'other-chatting-user',
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
CreateRoom: {
|
||||
@ -130,7 +131,7 @@ describe('Room', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -139,11 +140,11 @@ describe('Room', () => {
|
||||
beforeAll(() => {
|
||||
authenticatedUser = null
|
||||
})
|
||||
|
||||
|
||||
it('throws authorization error', async () => {
|
||||
await expect(query({ query: roomQuery() })).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
errors: [{ message: 'Not Authorized!' }],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -194,7 +195,7 @@ describe('Room', () => {
|
||||
})
|
||||
|
||||
it('returns the room', async () => {
|
||||
const result = await query({ query: roomQuery() })
|
||||
const result = await query({ query: roomQuery() })
|
||||
expect(result).toMatchObject({
|
||||
errors: undefined,
|
||||
data: {
|
||||
@ -241,7 +242,7 @@ describe('Room', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -3,7 +3,7 @@ import Resolver from './helpers/Resolver'
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
Room: async (object, params, context, resolveInfo) => {
|
||||
Room: async (object, params, context, resolveInfo) => {
|
||||
if (!params.filter) params.filter = {}
|
||||
params.filter.users_some = {
|
||||
id: context.user.id,
|
||||
@ -12,7 +12,11 @@ export default {
|
||||
if (resolved) {
|
||||
resolved.forEach((room) => {
|
||||
if (room.users) {
|
||||
// buggy, you must query the username for this to function correctly
|
||||
room.roomName = room.users.filter((user) => user.id !== context.user.id)[0].name
|
||||
room.avatar =
|
||||
room.users.filter((user) => user.id !== context.user.id)[0].avatar?.url ||
|
||||
'default-avatar'
|
||||
room.users.forEach((user) => {
|
||||
user._id = user.id
|
||||
})
|
||||
@ -25,7 +29,9 @@ export default {
|
||||
Mutation: {
|
||||
CreateRoom: async (_parent, params, context, _resolveInfo) => {
|
||||
const { userId } = params
|
||||
const { user: { id: currentUserId } } = context
|
||||
const {
|
||||
user: { id: currentUserId },
|
||||
} = context
|
||||
const session = context.driver.session()
|
||||
const writeTxResultPromise = session.writeTransaction(async (transaction) => {
|
||||
const createRoomCypher = `
|
||||
@ -37,13 +43,11 @@ export default {
|
||||
room.id = apoc.create.uuid()
|
||||
RETURN room { .* }
|
||||
`
|
||||
const createRommTxResponse = await transaction.run(
|
||||
createRoomCypher,
|
||||
{ userId, currentUserId }
|
||||
)
|
||||
const [room] = await createRommTxResponse.records.map((record) =>
|
||||
record.get('room'),
|
||||
)
|
||||
const createRommTxResponse = await transaction.run(createRoomCypher, {
|
||||
userId,
|
||||
currentUserId,
|
||||
})
|
||||
const [room] = await createRommTxResponse.records.map((record) => record.get('room'))
|
||||
return room
|
||||
})
|
||||
try {
|
||||
@ -56,14 +60,14 @@ export default {
|
||||
throw new Error(error)
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
Room: {
|
||||
...Resolver('Room', {
|
||||
hasMany: {
|
||||
users: '<-[:CHATS_IN]-(related:User)',
|
||||
}
|
||||
},
|
||||
}),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ describe('save category settings', () => {
|
||||
beforeEach(async () => {
|
||||
await Promise.all(
|
||||
categories.map(({ icon, name }, index) => {
|
||||
Factory.build('category', {
|
||||
return Factory.build('category', {
|
||||
id: `cat${index + 1}`,
|
||||
slug: name,
|
||||
name,
|
||||
|
||||
@ -144,7 +144,7 @@ export default {
|
||||
params.locationName = params.locationName === '' ? null : params.locationName
|
||||
const { termsAndConditionsAgreedVersion } = params
|
||||
if (termsAndConditionsAgreedVersion) {
|
||||
const regEx = new RegExp(/^[0-9]+\.[0-9]+\.[0-9]+$/g)
|
||||
const regEx = /^[0-9]+\.[0-9]+\.[0-9]+$/g
|
||||
if (!regEx.test(termsAndConditionsAgreedVersion)) {
|
||||
throw new ForbiddenError('Invalid version format!')
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ type Room {
|
||||
|
||||
roomId: String! @cypher(statement: "RETURN this.id")
|
||||
roomName: String! ## @cypher(statement: "MATCH (this)<-[:CHATS_IN]-(user:User) WHERE NOT user.id = $cypherParams.currentUserId RETURN user[0].name")
|
||||
avatar: String! ## @cypher match not own user in users array
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
|
||||
@ -106,6 +106,4 @@
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"exclude": ["./src/**/*.spec.ts"]
|
||||
}
|
||||
|
||||
3441
backend/yarn.lock
3441
backend/yarn.lock
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
||||
/* globals Cypress cy */
|
||||
import "cypress-file-upload";
|
||||
import { GraphQLClient, request } from 'graphql-request'
|
||||
import CONFIG from '../../backend/build/config'
|
||||
import CONFIG from '../../backend/build/src/config'
|
||||
|
||||
const authenticatedHeaders = (variables) => {
|
||||
const mutation = `
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import Factory from '../../backend/build/db/factories'
|
||||
import { getNeode } from '../../backend/build/db/neo4j'
|
||||
import Factory from '../../backend/build/src/db/factories'
|
||||
import { getNeode } from '../../backend/build/src/db/neo4j'
|
||||
|
||||
const neodeInstance = getNeode()
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Given } from "@badeball/cypress-cucumber-preprocessor";
|
||||
import encode from '../../../../backend/build/jwt/encode'
|
||||
import encode from '../../../../backend/build/src/jwt/encode'
|
||||
|
||||
Given("I am logged in as {string}", slug => {
|
||||
cy.neode()
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 3056eec040cf7a052a5d08ab4cac7129355ab652
|
||||
Subproject commit 350237c62dcff1a5c34f1e8d718f89b05ce3d33f
|
||||
@ -15,4 +15,4 @@ echo "Using CONFIGURATION=${CONFIGURATION}"
|
||||
KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml}
|
||||
|
||||
# clean & seed
|
||||
kubectl --kubeconfig=${KUBECONFIG} -n default exec -it $(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node --experimental-repl-await build/db/clean.js && node --experimental-repl-await build/db/seed.js"
|
||||
kubectl --kubeconfig=${KUBECONFIG} -n default exec -it $(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node --experimental-repl-await build/src/db/clean.js && node --experimental-repl-await build/src/db/seed.js"
|
||||
@ -12,9 +12,9 @@ FROM $APP_IMAGE_CODE as code
|
||||
ARG CONFIGURATION=example
|
||||
|
||||
# copy public constants and email templates into the Docker image to brand it
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/emails.js src/config/
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/logos.js src/config/
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/metadata.js src/config/
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/emails.ts src/config/
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/logos.ts src/config/
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/metadata.ts src/config/
|
||||
COPY configurations/${CONFIGURATION}/branding/email/ src/middleware/helpers/email/
|
||||
|
||||
##################################################################################
|
||||
@ -38,7 +38,7 @@ COPY --from=build ${DOCKER_WORKDIR}/build ./build
|
||||
COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules
|
||||
# TODO - externalize the uploads so we can copy the whole folder
|
||||
COPY --from=build ${DOCKER_WORKDIR}/public/img/ ./public/img/
|
||||
COPY --from=build ${DOCKER_WORKDIR}/public/providers.json ./public/providers.json
|
||||
COPY --from=build ${DOCKER_WORKDIR}/public/providers.json ./build/public/providers.json
|
||||
# Copy package.json for script definitions (lock file should not be needed)
|
||||
COPY --from=build ${DOCKER_WORKDIR}/package.json ./package.json
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ ARG CONFIGURATION=example
|
||||
# copy public constants into the Docker image to brand it
|
||||
COPY configurations/${CONFIGURATION}/branding/static/ static/
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/ constants/
|
||||
RUN /bin/sh -c 'cd constants && for f in *.ts; do mv -- "$f" "${f%.ts}.js"; done'
|
||||
|
||||
# locales
|
||||
COPY configurations/${CONFIGURATION}/branding/locales/*.json locales/tmp/
|
||||
|
||||
@ -14,6 +14,7 @@ ARG CONFIGURATION=example
|
||||
# copy public constants into the Docker image to brand it
|
||||
COPY configurations/${CONFIGURATION}/branding/static/ static/
|
||||
COPY configurations/${CONFIGURATION}/branding/constants/ constants/
|
||||
RUN /bin/sh -c 'cd constants && for f in *.ts; do mv -- "$f" "${f%.ts}.js"; done'
|
||||
COPY configurations/${CONFIGURATION}/branding/locales/html/ locales/html/
|
||||
COPY configurations/${CONFIGURATION}/branding/assets/styles/imports/ assets/styles/imports/
|
||||
COPY configurations/${CONFIGURATION}/branding/assets/fonts/ assets/fonts/
|
||||
|
||||
@ -293,7 +293,7 @@ $ kubectl -n default rollout status deployment/ocelot-neo4j --timeout=240s
|
||||
$ kubectl config get-contexts
|
||||
|
||||
# reset and seed Neo4j database via backend for staging
|
||||
$ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node --experimental-repl-await build/db/clean.js && node --experimental-repl-await build/db/seed.js"
|
||||
$ kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node --experimental-repl-await build/src/db/clean.js && node --experimental-repl-await build/src/db/seed.js"
|
||||
|
||||
|
||||
```
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"cucumber": "^6.0.5",
|
||||
"cypress": "^12.14.0",
|
||||
"cypress": "^12.17.0",
|
||||
"cypress-file-upload": "^3.5.3",
|
||||
"cypress-network-idle": "^1.14.2",
|
||||
"date-fns": "^2.25.0",
|
||||
|
||||
259
webapp/components/Chat/Chat.vue
Normal file
259
webapp/components/Chat/Chat.vue
Normal file
@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<div>
|
||||
<client-only>
|
||||
<vue-advanced-chat
|
||||
:theme="theme"
|
||||
:current-user-id="currentUserId"
|
||||
:room-id="null"
|
||||
:template-actions="JSON.stringify(templatesText)"
|
||||
:menu-actions="JSON.stringify(menuActions)"
|
||||
:text-messages="JSON.stringify(textMessages)"
|
||||
:messages="JSON.stringify(messages)"
|
||||
:messages-loaded="messagesLoaded"
|
||||
:rooms="JSON.stringify(rooms)"
|
||||
:room-actions="JSON.stringify(roomActions)"
|
||||
:rooms-loaded="true"
|
||||
show-files="false"
|
||||
show-audio="false"
|
||||
:show-footer="true"
|
||||
@send-message="sendMessage($event.detail[0])"
|
||||
@fetch-messages="fetchMessages($event.detail[0])"
|
||||
:responsive-breakpoint="responsiveBreakpoint"
|
||||
:single-room="singleRoom"
|
||||
@show-demo-options="showDemoOptions = $event"
|
||||
/>
|
||||
</client-only>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { roomQuery, createRoom } from '~/graphql/Rooms'
|
||||
import { messageQuery } from '~/graphql/Messages'
|
||||
|
||||
export default {
|
||||
name: 'Chat',
|
||||
props: {
|
||||
theme: {
|
||||
type: String,
|
||||
},
|
||||
singleRoomId: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentUserId: '1234',
|
||||
menuActions: [
|
||||
/* {
|
||||
name: 'inviteUser',
|
||||
title: 'Invite User',
|
||||
},
|
||||
{
|
||||
name: 'removeUser',
|
||||
title: 'Remove User',
|
||||
},
|
||||
{
|
||||
name: 'deleteRoom',
|
||||
title: 'Delete Room',
|
||||
}, */
|
||||
],
|
||||
messageActions: [
|
||||
{
|
||||
name: 'addMessageToFavorite',
|
||||
title: 'Add To Favorite',
|
||||
},
|
||||
{
|
||||
name: 'shareMessage',
|
||||
title: 'Share Message',
|
||||
},
|
||||
],
|
||||
templatesText: [
|
||||
{
|
||||
tag: 'help',
|
||||
text: 'This is the help',
|
||||
},
|
||||
{
|
||||
tag: 'action',
|
||||
text: 'This is the action',
|
||||
},
|
||||
],
|
||||
textMessages: {
|
||||
ROOMS_EMPTY: 'Aucune conversation',
|
||||
ROOM_EMPTY: 'Aucune conversation sélectionnée',
|
||||
NEW_MESSAGES: 'Nouveaux messages',
|
||||
MESSAGE_DELETED: 'Ce message a été supprimé',
|
||||
MESSAGES_EMPTY: 'Aucun message',
|
||||
CONVERSATION_STARTED: 'La conversation a commencée le :',
|
||||
TYPE_MESSAGE: 'Tapez votre message',
|
||||
SEARCH: 'Rechercher',
|
||||
IS_ONLINE: 'est en ligne',
|
||||
LAST_SEEN: 'dernière connexion ',
|
||||
IS_TYPING: 'est en train de taper...',
|
||||
CANCEL_SELECT_MESSAGE: 'Annuler Sélection',
|
||||
},
|
||||
roomActions: [
|
||||
/*
|
||||
{
|
||||
name: 'archiveRoom',
|
||||
title: 'Archive Room',
|
||||
},
|
||||
{ name: 'inviteUser', title: 'Invite User' },
|
||||
{ name: 'removeUser', title: 'Remove User' },
|
||||
{ name: 'deleteRoom', title: 'Delete Room' },
|
||||
*/
|
||||
],
|
||||
rooms: [],
|
||||
messages: [],
|
||||
messagesLoaded: true,
|
||||
showDemoOptions: true,
|
||||
responsiveBreakpoint: 600,
|
||||
singleRoom: !!this.singleRoomId || false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.singleRoom) {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: createRoom(),
|
||||
variables: {
|
||||
userId: this.singleRoomId,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
this.$apollo.queries.Rooms.refetch()
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toast.error(error)
|
||||
})
|
||||
.finally(() => {
|
||||
// this.loading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchMessages({ room, options = {} }) {
|
||||
// console.log(room, options)
|
||||
this.messagesLoaded = false
|
||||
setTimeout(async () => {
|
||||
if (options.reset) {
|
||||
// console.log('reset messages')
|
||||
this.messages = [] // this.addMessages(true)
|
||||
} else {
|
||||
try {
|
||||
const {
|
||||
data: { Message },
|
||||
} = await this.$apollo.query({
|
||||
query: messageQuery(),
|
||||
variables: {
|
||||
roomId: room.id,
|
||||
},
|
||||
})
|
||||
// console.log('Messages', Message)
|
||||
this.messages = Message
|
||||
} catch (error) {
|
||||
// console.log('Error', error)
|
||||
this.messages = [] // this.addMessages(true)
|
||||
this.$toast.error(error.message)
|
||||
}
|
||||
}
|
||||
this.messagesLoaded = true
|
||||
})
|
||||
},
|
||||
|
||||
/* addMessages(reset) {
|
||||
const messages = []
|
||||
|
||||
for (let i = 0; i < 30; i++) {
|
||||
messages.push({
|
||||
_id: reset ? i : this.messages.length + i,
|
||||
content: `${reset ? '' : 'paginated'} message ${i + 1}`,
|
||||
senderId: '4321',
|
||||
username: 'John Doe',
|
||||
date: '13 November',
|
||||
timestamp: '10:20',
|
||||
})
|
||||
}
|
||||
messages.push({
|
||||
_id: '31',
|
||||
content: `Hallo Welt`,
|
||||
senderId: '1234',
|
||||
username: 'John Doe',
|
||||
date: '13 November',
|
||||
timestamp: '10:20',
|
||||
})
|
||||
|
||||
return messages
|
||||
}, */
|
||||
|
||||
sendMessage(message) {
|
||||
this.messages = [
|
||||
...this.messages,
|
||||
{
|
||||
_id: this.messages.length,
|
||||
content: message.content,
|
||||
senderId: this.currentUserId,
|
||||
timestamp: new Date().toString().substring(16, 21),
|
||||
date: new Date().toDateString(),
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
addNewMessage() {
|
||||
setTimeout(() => {
|
||||
this.messages = [
|
||||
...this.messages,
|
||||
{
|
||||
_id: this.messages.length,
|
||||
content: 'NEW MESSAGE',
|
||||
senderId: '1234',
|
||||
timestamp: new Date().toString().substring(16, 21),
|
||||
date: new Date().toDateString(),
|
||||
},
|
||||
]
|
||||
}, 2000)
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Rooms: {
|
||||
query() {
|
||||
return roomQuery()
|
||||
},
|
||||
update({ Room }) {
|
||||
// console.log('Rooms', Room)
|
||||
if (!Room) {
|
||||
this.rooms = []
|
||||
return
|
||||
}
|
||||
|
||||
// Backend result needs mapping of the following values
|
||||
// room[i].users[j].name -> room[i].users[j].username
|
||||
// room[i].users[j].avatar.url -> room[i].users[j].avatar
|
||||
// also filter rooms for the single room
|
||||
this.rooms = Room.map((r) => {
|
||||
return {
|
||||
...r,
|
||||
users: r.users.map((u) => {
|
||||
return { ...u, username: u.name, avatar: u.avatar?.url }
|
||||
}),
|
||||
}
|
||||
}).filter((r) =>
|
||||
this.singleRoom ? r.users.filter((u) => u.id === this.singleRoomId).length > 0 : true,
|
||||
)
|
||||
|
||||
// console.log(this.rooms)
|
||||
},
|
||||
error(error) {
|
||||
this.rooms = []
|
||||
this.$toast.error(error.message)
|
||||
},
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
body {
|
||||
font-family: 'Quicksand', sans-serif;
|
||||
}
|
||||
</style>
|
||||
140
webapp/components/ChatNotificationMenu/ChatNotificationMenu.vue
Normal file
140
webapp/components/ChatNotificationMenu/ChatNotificationMenu.vue
Normal file
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<nuxt-link v-if="!unreadChatNotificationsCount" class="chat-menu" :to="{ name: 'chat' }">
|
||||
<base-button
|
||||
ghost
|
||||
circle
|
||||
v-tooltip="{
|
||||
content: $t('notifications.headerMenuButton.chat'),
|
||||
placement: 'bottom-start',
|
||||
}"
|
||||
>
|
||||
<img src="/img/empty/chat-bubble.svg" />
|
||||
</base-button>
|
||||
</nuxt-link>
|
||||
<dropdown v-else class="chat-notifications-menu" offset="8">
|
||||
<template #default="{ toggleMenu }">
|
||||
<base-button
|
||||
ghost
|
||||
circle
|
||||
v-tooltip="{
|
||||
content: $t('notifications.headerMenuButton.tooltip'),
|
||||
placement: 'bottom-start',
|
||||
}"
|
||||
@click="toggleMenu"
|
||||
>
|
||||
<counter-icon icon="envelope" :count="unreadChatNotificationsCount" danger />
|
||||
<img src="/img/empty/chat-bubble.svg" />
|
||||
</base-button>
|
||||
</template>
|
||||
<template #popover="{}">
|
||||
<div class="chat-notifications-menu-popover">
|
||||
<div v-for="notification in notifications" v-bind:key="notification.roomid">
|
||||
<ds-space>
|
||||
<div
|
||||
class="chat-notifications-menu-popover-item"
|
||||
@click="
|
||||
$store.commit('chat/SET_OPEN_CHAT', { showChat: true, roomID: notification.roomid })
|
||||
"
|
||||
>
|
||||
<p>{{ notification.name }}</p>
|
||||
{{ notification.title }}
|
||||
</div>
|
||||
</ds-space>
|
||||
</div>
|
||||
<!-- <notification-list :notifications="notifications" /> -->
|
||||
</div>
|
||||
<ds-flex class="chat-notifications-link-container">
|
||||
<ds-flex-item
|
||||
class="chat-notifications-link-container-item"
|
||||
:width="{ base: '100%' }"
|
||||
centered
|
||||
>
|
||||
<nuxt-link :to="{ name: 'chat' }">
|
||||
<base-button ghost primary>All Chat Messages</base-button>
|
||||
</nuxt-link>
|
||||
</ds-flex-item>
|
||||
</ds-flex>
|
||||
</template>
|
||||
</dropdown>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CounterIcon from '~/components/_new/generic/CounterIcon/CounterIcon'
|
||||
import Dropdown from '~/components/Dropdown'
|
||||
// import NotificationList from '../NotificationList/NotificationList'
|
||||
|
||||
export default {
|
||||
name: 'ChatNotificationMenu',
|
||||
components: {
|
||||
CounterIcon,
|
||||
Dropdown,
|
||||
// NotificationList,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
notifications: [
|
||||
{ roomid: 'u1', name: 'Jenny', title: 'last Message from Jenny' },
|
||||
{ roomid: 'u2', name: 'Honey', title: 'last Message from Honey' },
|
||||
{ roomid: 'u3', name: 'Bob der Baumeister', title: 'last Message from Bob der Baumeister' },
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
unreadChatNotificationsCount() {
|
||||
const result = this.notifications.reduce((count, notification) => {
|
||||
return notification.read ? count : count + 1
|
||||
}, 0)
|
||||
return result
|
||||
},
|
||||
hasNotifications() {
|
||||
return this.notifications.length
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.chat-notifications-menu {
|
||||
max-width: 500px;
|
||||
}
|
||||
.vue-popover-theme {
|
||||
z-index: 1000000;
|
||||
}
|
||||
|
||||
.counter-icon {
|
||||
position: relative;
|
||||
|
||||
> .count {
|
||||
position: absolute;
|
||||
top: -$space-xx-small;
|
||||
right: 0;
|
||||
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: $size-icon-base;
|
||||
min-width: $size-icon-base;
|
||||
padding: 3px; // magic number to center count
|
||||
border-radius: 50%;
|
||||
transform: translateX(50%);
|
||||
|
||||
color: $color-neutral-100;
|
||||
background-color: $color-primary;
|
||||
font-size: 10px; // magic number to center count
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
|
||||
&.--danger {
|
||||
background-color: $color-danger;
|
||||
}
|
||||
|
||||
&.--inactive {
|
||||
background-color: $color-neutral-60;
|
||||
}
|
||||
|
||||
&.--soft {
|
||||
background-color: $color-neutral-90;
|
||||
color: $text-color-soft;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -92,6 +92,10 @@
|
||||
<client-only v-if="!isEmpty(this.$env.MAPBOX_TOKEN)">
|
||||
<map-button />
|
||||
</client-only>
|
||||
<!-- chat menü -->
|
||||
<client-only>
|
||||
<chat-notification-menu placement="top" />
|
||||
</client-only>
|
||||
<!-- avatar menu -->
|
||||
<client-only>
|
||||
<avatar-menu placement="top" />
|
||||
@ -265,6 +269,7 @@ import SearchField from '~/components/features/SearchField/SearchField.vue'
|
||||
import NotificationMenu from '~/components/NotificationMenu/NotificationMenu'
|
||||
import links from '~/constants/links.js'
|
||||
import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParamsLink.vue'
|
||||
import ChatNotificationMenu from '~/components/ChatNotificationMenu/ChatNotificationMenu'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -278,6 +283,7 @@ export default {
|
||||
NotificationMenu,
|
||||
PageParamsLink,
|
||||
SearchField,
|
||||
ChatNotificationMenu,
|
||||
},
|
||||
props: {
|
||||
showMobileMenu: { type: Boolean, default: false },
|
||||
|
||||
@ -149,7 +149,7 @@ export default {
|
||||
return {
|
||||
notifications: unionBy(
|
||||
[newNotification],
|
||||
previousResult.notifications,
|
||||
previousResult?.notifications,
|
||||
(notification) => notification.id,
|
||||
).sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt)),
|
||||
}
|
||||
|
||||
15
webapp/graphql/Messages.js
Normal file
15
webapp/graphql/Messages.js
Normal file
@ -0,0 +1,15 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const messageQuery = () => {
|
||||
return gql`
|
||||
query ($roomId: ID!) {
|
||||
Message(roomId: $roomId) {
|
||||
id
|
||||
content
|
||||
author {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
@ -39,6 +39,7 @@ export default () => {
|
||||
deleted
|
||||
postType
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
categories {
|
||||
|
||||
29
webapp/graphql/Rooms.js
Normal file
29
webapp/graphql/Rooms.js
Normal file
@ -0,0 +1,29 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const roomQuery = () => gql`
|
||||
query {
|
||||
Room {
|
||||
id
|
||||
roomId
|
||||
roomName
|
||||
avatar
|
||||
users {
|
||||
_id
|
||||
id
|
||||
name
|
||||
avatar {
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const createRoom = () => gql`
|
||||
mutation ($userId: ID!) {
|
||||
CreateRoom(userId: $userId) {
|
||||
id
|
||||
roomId
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -243,6 +243,7 @@ export const notificationAdded = () => {
|
||||
${userFragment}
|
||||
${commentFragment}
|
||||
${postFragment}
|
||||
${groupFragment}
|
||||
|
||||
subscription notifications($userId: ID!) {
|
||||
notificationAdded(userId: $userId) {
|
||||
@ -251,6 +252,9 @@ export const notificationAdded = () => {
|
||||
reason
|
||||
createdAt
|
||||
updatedAt
|
||||
to {
|
||||
...user
|
||||
}
|
||||
from {
|
||||
__typename
|
||||
... on Post {
|
||||
@ -271,6 +275,12 @@ export const notificationAdded = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
... on Group {
|
||||
...group
|
||||
}
|
||||
}
|
||||
relatedUser {
|
||||
...user
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,9 @@ describe('default.vue', () => {
|
||||
store = new Vuex.Store({
|
||||
getters: {
|
||||
'auth/isLoggedIn': () => true,
|
||||
'chat/showChat': () => {
|
||||
return { showChat: false, roomID: 'u0' }
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@ -13,21 +13,32 @@
|
||||
<client-only>
|
||||
<modal />
|
||||
</client-only>
|
||||
<div v-if="$store.getters['chat/showChat'].showChat" class="chat-modul">
|
||||
<ds-text align="right" class="close">
|
||||
RoomID: {{ $store.getters['chat/showChat'].roomID }}
|
||||
<ds-button @click="$store.commit('chat/SET_OPEN_CHAT', { showChat: false, roomID: 'u0' })">
|
||||
x
|
||||
</ds-button>
|
||||
</ds-text>
|
||||
<chat-module :singleRoomId="$store.getters['chat/showChat'].roomID" />
|
||||
</div>
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import seo from '~/mixins/seo'
|
||||
import mobile from '~/mixins/mobile'
|
||||
import HeaderMenu from '~/components/HeaderMenu/HeaderMenu'
|
||||
import Modal from '~/components/Modal'
|
||||
import PageFooter from '~/components/PageFooter/PageFooter'
|
||||
import ChatModule from '~/components/Chat/Chat.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HeaderMenu,
|
||||
Modal,
|
||||
PageFooter,
|
||||
ChatModule,
|
||||
},
|
||||
mixins: [seo, mobile()],
|
||||
}
|
||||
@ -41,4 +52,19 @@ export default {
|
||||
padding-top: 6rem;
|
||||
padding-bottom: 5rem;
|
||||
}
|
||||
|
||||
.chat-modul {
|
||||
background-color: rgb(233, 228, 228);
|
||||
height: 667px;
|
||||
width: 355px;
|
||||
position: fixed;
|
||||
bottom: 45px;
|
||||
right: 0;
|
||||
z-index: 10000;
|
||||
.close {
|
||||
padding: 10px;
|
||||
color: blue;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -692,6 +692,7 @@
|
||||
},
|
||||
"group": "Beschreibung",
|
||||
"headerMenuButton": {
|
||||
"chat": "Meine Chat",
|
||||
"tooltip": "Meine Benachrichtigungen"
|
||||
},
|
||||
"markAllAsRead": "Markiere alle als gelesen",
|
||||
|
||||
@ -692,6 +692,7 @@
|
||||
},
|
||||
"group": "Description",
|
||||
"headerMenuButton": {
|
||||
"chat": "My Chat",
|
||||
"tooltip": "My notifications"
|
||||
},
|
||||
"markAllAsRead": "Mark all as read",
|
||||
|
||||
@ -127,6 +127,7 @@ export default {
|
||||
{ src: '~/plugins/vue-infinite-loading.js', ssr: false },
|
||||
{ src: '~/plugins/vue-observe-visibility.js', ssr: false },
|
||||
{ src: '~/plugins/v-mapbox.js', mode: 'client' },
|
||||
{ src: '~/plugins/vue-advanced-chat.js', mode: 'client' },
|
||||
],
|
||||
|
||||
router: {
|
||||
@ -248,6 +249,14 @@ export default {
|
||||
** You can extend webpack config here
|
||||
*/
|
||||
extend(config, ctx) {
|
||||
// Add the compilerOptions
|
||||
ctx.loaders.vue.compilerOptions = {
|
||||
// Add your compilerOptions here
|
||||
isCustomElement: (tagName) => {
|
||||
return tagName === 'vue-advanced-chat' || tagName === 'emoji-picker'
|
||||
},
|
||||
}
|
||||
|
||||
if (CONFIG.STYLEGUIDE_DEV) {
|
||||
config.resolve.alias['@@'] = path.resolve(__dirname, `${styleguidePath}/src/system`)
|
||||
config.module.rules.push({
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
"v-mapbox": "^1.11.2",
|
||||
"v-tooltip": "~2.1.3",
|
||||
"validator": "^13.0.0",
|
||||
"vue-advanced-chat": "^2.0.7",
|
||||
"vue-count-to": "~1.0.13",
|
||||
"vue-infinite-loading": "^2.4.5",
|
||||
"vue-izitoast": "^1.2.1",
|
||||
|
||||
11
webapp/pages/chat.vue
Normal file
11
webapp/pages/chat.vue
Normal file
@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<chat />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Chat from '../components/Chat/Chat.vue'
|
||||
|
||||
export default {
|
||||
components: { Chat },
|
||||
}
|
||||
</script>
|
||||
@ -79,6 +79,15 @@
|
||||
@optimistic="optimisticFollow"
|
||||
@update="updateFollow"
|
||||
/>
|
||||
<base-button
|
||||
@click="$store.commit('chat/SET_OPEN_CHAT', { showChat: true, roomID: user.id })"
|
||||
v-tooltip="{
|
||||
content: $t('notifications.headerMenuButton.chat'),
|
||||
placement: 'bottom-start',
|
||||
}"
|
||||
>
|
||||
<img src="/img/empty/chat-bubble.svg" height="20" />
|
||||
</base-button>
|
||||
</div>
|
||||
<template v-if="user.about">
|
||||
<hr />
|
||||
|
||||
6
webapp/plugins/vue-advanced-chat.js
Normal file
6
webapp/plugins/vue-advanced-chat.js
Normal file
@ -0,0 +1,6 @@
|
||||
import { register } from 'vue-advanced-chat'
|
||||
export default ({ app }) => {
|
||||
if (process.client) {
|
||||
register()
|
||||
}
|
||||
}
|
||||
1
webapp/static/img/empty/chat-bubble.svg
Normal file
1
webapp/static/img/empty/chat-bubble.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" id="chat-bubble"><g data-name="Chat"><path fill="#9B9B9B" d="M27.23,24.91A9,9,0,0,0,22.44,9.52,8.57,8.57,0,0,0,21,9.41a8.94,8.94,0,0,0-8.92,10.14c0,.1,0,.2,0,.29a9,9,0,0,0,.22,1l0,.11a8.93,8.93,0,0,0,.38,1l.13.28a9,9,0,0,0,.45.83l.07.14a9.13,9.13,0,0,1-2.94-.36,1,1,0,0,0-.68,0L7,24.13l.54-1.9a1,1,0,0,0-.32-1,9,9,0,0,1,11.27-14,1,1,0,0,0,1.23-1.58A10.89,10.89,0,0,0,13,3.25a11,11,0,0,0-7.5,19l-1,3.34A1,1,0,0,0,5.9,26.82l4.35-1.93a11,11,0,0,0,4.68.16A9,9,0,0,0,21,27.41a8.81,8.81,0,0,0,2.18-.27l3.41,1.52A1,1,0,0,0,28,27.48Zm-1.77-1.1a1,1,0,0,0-.32,1L25.45,26l-1.79-.8a1,1,0,0,0-.41-.09,1,1,0,0,0-.29,0,6.64,6.64,0,0,1-2,.29,7,7,0,0,1,0-14,6.65,6.65,0,0,1,1.11.09,7,7,0,0,1,3.35,12.31Z"></path><path fill="#9B9B9B" d="M17.82 17.08H17a1 1 0 0 0 0 2h.82a1 1 0 0 0 0-2zM21.41 17.08h-.82a1 1 0 0 0 0 2h.82a1 1 0 0 0 0-2zM25 17.08h-.82a1 1 0 0 0 0 2H25a1 1 0 0 0 0-2z"></path></g></svg>
|
||||
|
After Width: | Height: | Size: 942 B |
22
webapp/store/chat.js
Normal file
22
webapp/store/chat.js
Normal file
@ -0,0 +1,22 @@
|
||||
export const state = () => {
|
||||
return {
|
||||
showChat: false,
|
||||
roomID: 'u0',
|
||||
}
|
||||
}
|
||||
|
||||
export const mutations = {
|
||||
SET_OPEN_CHAT(state, ctx) {
|
||||
state.showChat = ctx.showChat || false
|
||||
state.roomID = ctx.roomID || 'u0'
|
||||
},
|
||||
}
|
||||
|
||||
export const getters = {
|
||||
showChat(state) {
|
||||
return state
|
||||
},
|
||||
roomID(state) {
|
||||
return state
|
||||
},
|
||||
}
|
||||
@ -10503,6 +10503,11 @@ emittery@^0.13.1:
|
||||
resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad"
|
||||
integrity sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==
|
||||
|
||||
emoji-picker-element@1.12.1:
|
||||
version "1.12.1"
|
||||
resolved "https://registry.yarnpkg.com/emoji-picker-element/-/emoji-picker-element-1.12.1.tgz#854a9bbae4d9a04fa2b5cd0763845921f4904c83"
|
||||
integrity sha512-F9AY/re8uqZmBcCXLHLGvyy7fxuMQdZl9R8OToLRH8Vnns+WMX8RYUbI2nSJklzl5+82qzpYWeus1/puDepWcQ==
|
||||
|
||||
emoji-regex@^7.0.1:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
|
||||
@ -14729,6 +14734,11 @@ linkify-it@~3.0.2:
|
||||
dependencies:
|
||||
uc.micro "^1.0.1"
|
||||
|
||||
linkifyjs@2.1.9:
|
||||
version "2.1.9"
|
||||
resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-2.1.9.tgz#af06e45a2866ff06c4766582590d098a4d584702"
|
||||
integrity sha512-74ivurkK6WHvHFozVaGtQWV38FzBwSTGNmJolEgFp7QgR2bl6ArUWlvT4GcHKbPe1z3nWYi+VUdDZk16zDOVug==
|
||||
|
||||
listr-silent-renderer@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz#924b5a3757153770bf1a8e3fbf74b8bbf3f9242e"
|
||||
@ -21951,6 +21961,14 @@ vt-pbf@^3.1.1:
|
||||
"@mapbox/vector-tile" "^1.3.1"
|
||||
pbf "^3.2.1"
|
||||
|
||||
vue-advanced-chat@^2.0.7:
|
||||
version "2.0.7"
|
||||
resolved "https://registry.yarnpkg.com/vue-advanced-chat/-/vue-advanced-chat-2.0.7.tgz#bd35830c19fc5eb4e26545dc554d88e7808913cc"
|
||||
integrity sha512-s+6v+KtVT46lFM8YohneLLS/vN10sSTAPfZiqAczXf13Q8vQWD9rSeWAokL0zuJeQ+jguNgFI6oN2wbI/RC1iw==
|
||||
dependencies:
|
||||
emoji-picker-element "1.12.1"
|
||||
linkifyjs "2.1.9"
|
||||
|
||||
vue-apollo@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/vue-apollo/-/vue-apollo-3.0.2.tgz#b198ecfa3765850a0b9f2b84ffaa7fbd8ec15f52"
|
||||
|
||||
18
yarn.lock
18
yarn.lock
@ -3164,10 +3164,10 @@ cypress-network-idle@^1.14.2:
|
||||
resolved "https://registry.yarnpkg.com/cypress-network-idle/-/cypress-network-idle-1.14.2.tgz#0837100861feeb5a18f4c2d9815be079f8590f4d"
|
||||
integrity sha512-xAdR8dH58KFPv8eCDWjviScITrJOcUpuMXYfYTc175nk2/NvnJ+I6ylSn1CM7yZmoV/gLbFa36QLiH5NfNEaLQ==
|
||||
|
||||
cypress@^12.14.0:
|
||||
version "12.14.0"
|
||||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.14.0.tgz#37a19b85f5e9d881995e9fee1ddf41b3d3a623dd"
|
||||
integrity sha512-HiLIXKXZaIT1RT7sw1sVPt+qKtis3uYNm6KwC4qoYjabwLKaqZlyS/P+uVvvlBNcHIwL/BC6nQZajpbUd7hOgQ==
|
||||
cypress@^12.17.0:
|
||||
version "12.17.0"
|
||||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-12.17.0.tgz#3a907a41c4afbb44be7b84e822e4914d734a6bb0"
|
||||
integrity sha512-nq0ug8Zrjq/2khHU1PTNxg+3/n1oqtmAFCxwQhS6QzkQ4mR6RLitX+cGIOuIMfnEbDAtVub0hZh661FOA16JxA==
|
||||
dependencies:
|
||||
"@cypress/request" "^2.88.10"
|
||||
"@cypress/xvfb" "^1.2.4"
|
||||
@ -3206,7 +3206,7 @@ cypress@^12.14.0:
|
||||
pretty-bytes "^5.6.0"
|
||||
proxy-from-env "1.0.0"
|
||||
request-progress "^3.0.0"
|
||||
semver "^7.3.2"
|
||||
semver "^7.5.3"
|
||||
supports-color "^8.1.1"
|
||||
tmp "~0.2.1"
|
||||
untildify "^4.0.0"
|
||||
@ -5358,10 +5358,10 @@ semver@^6.1.1, semver@^6.1.2, semver@^6.3.0:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||
|
||||
semver@^7.3.2, semver@^7.3.5:
|
||||
version "7.5.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.1.tgz#c90c4d631cf74720e46b21c1d37ea07edfab91ec"
|
||||
integrity sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==
|
||||
semver@^7.3.5, semver@^7.5.3:
|
||||
version "7.5.4"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
|
||||
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user