Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit ff7d9fc

Browse files
committed
Merge remote-tracking branch 'origin/own-data-managing' into own-data-managing
# Conflicts: # server/services/comments/comments.hooks.js
2 parents 64a4f69 + a7290a9 commit ff7d9fc

22 files changed

+512
-9116
lines changed

package-lock.json

Lines changed: 0 additions & 9032 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"dev:debug": "npm run clear && concurrently '$npm_package_config_mongoDev' 'wait-on tcp:27017 && NODE_ENV=development nodemon --inspect server/'",
4242
"dev": "npm run clear && concurrently '$npm_package_config_mongoDev' 'wait-on tcp:27017 && NODE_ENV=development DEBUG=feathers nodemon server/'",
4343
"dev:noseed": "concurrently 'mongod --dbpath data' 'wait-on tcp:27017 && NODE_ENV=development DEBUG=feathers nodemon server/'",
44-
"dev:win": "npm run clear && concurrently \"mongod --dbpath /data/db\" \"wait-on tcp:27017&& cross-env NODE_ENV=development&& cross-env DEBUG=feathers&& nodemon --inspect server/\"",
44+
"dev:win": "npm run clear && concurrently \"mongod --dbpath /data/db\" \"wait-on tcp:27017&&cross-env NODE_ENV=development&&cross-env DEBUG=feathers&& nodemon --inspect server/\"",
4545
"mocha": "npm run clear && $npm_package_config_concurrently '$npm_package_config_mongoDev &>/dev/null' 'wait-on tcp:27017 && NODE_ENV=test $npm_package_config_mocha'",
4646
"coverage": "npm run clear && $npm_package_config_concurrently '$npm_package_config_mongoDev &>/dev/null' 'wait-on tcp:27017 && NODE_ENV=test istanbul cover $npm_package_config_mochaCoverage'"
4747
},
@@ -56,7 +56,6 @@
5656
"cheerio": "^1.0.0-rc.2",
5757
"compression": "~1.7.2",
5858
"cors": "~2.8.4",
59-
"cross-env": "^5.1.5",
6059
"crypto": "~1.0.1",
6160
"crypto-js": "^3.1.9-1",
6261
"dauria": "~2.0.0",
@@ -72,7 +71,7 @@
7271
"feathers-errors": "~2.9.2",
7372
"feathers-hooks": "~2.1.2",
7473
"feathers-hooks-common": "~3.10.0",
75-
"feathers-logger": "~0.2.3",
74+
"feathers-logger": "0.2.3",
7675
"feathers-mailer": "~2.0.0",
7776
"feathers-memory": "~1.3.1",
7877
"feathers-mongodb": "~3.0.0",
@@ -106,9 +105,10 @@
106105
"devDependencies": {
107106
"babel-eslint": "~8.2.3",
108107
"concurrently": "~3.5.1",
109-
"eslint": "~4.16.0",
108+
"cross-env": "^5.1.5",
109+
"eslint": "~4.19.1",
110110
"istanbul": "1.1.0-alpha.1",
111-
"mocha": "~5.1.1",
111+
"mocha": "~5.2.0",
112112
"nodemon": "~1.17.4",
113113
"shx": "^0.2.2",
114114
"wait-on": "~2.1.0"

server/hooks/create-slug.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const slug = require('slug');
33
const getUniqueSlug = require('../helper/get-unique-slug');
44
const { isEmpty } = require('lodash');
55

6-
module.exports = function (options = { field: null, overwrite: false }) {
6+
module.exports = function (options = { field: null, overwrite: false, unique: true }) {
77
return function (hook) {
88
if (!options.field || !hook.data[options.field]) return hook;
99

@@ -16,11 +16,16 @@ module.exports = function (options = { field: null, overwrite: false }) {
1616
const titleSlug = slug(hook.data[options.field], {
1717
lower: true
1818
});
19-
getUniqueSlug(hook.service, titleSlug, null, hook.id)
20-
.then((uniqueSlug) => {
21-
hook.data.slug = uniqueSlug;
22-
resolve(hook);
23-
});
19+
if (options.unique) {
20+
getUniqueSlug(hook.service, titleSlug, null, hook.id)
21+
.then((uniqueSlug) => {
22+
hook.data.slug = uniqueSlug;
23+
resolve(hook);
24+
});
25+
} else {
26+
hook.data.slug = titleSlug;
27+
resolve(hook);
28+
}
2429
});
2530
};
2631
};

server/models/pages.model.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// pages-model.js - A mongoose model
2+
//
3+
// See http://mongoosejs.com/docs/models.html
4+
// for more of what you can do here.
5+
module.exports = function (app) {
6+
const mongooseClient = app.get('mongooseClient');
7+
const pages = new mongooseClient.Schema({
8+
title: { type: String, required: true },
9+
slug: { type: String, required: true },
10+
type: { type: String, required: true, default: 'page' },
11+
key: { type: String, required: true },
12+
content: { type: String, required: true },
13+
language: { type: String, required: true, index: true },
14+
active: { type: Boolean, default: true, index: true },
15+
createdAt: { type: Date, default: Date.now },
16+
updatedAt: { type: Date, default: Date.now },
17+
wasSeeded: { type: Boolean }
18+
});
19+
20+
pages.index(
21+
{ slug: 1, language: 1 },
22+
{ unique: true }
23+
);
24+
25+
return mongooseClient.model('pages', pages);
26+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// system-notifications-model.js - A mongoose model
2+
//
3+
// See http://mongoosejs.com/docs/models.html
4+
// for more of what you can do here.
5+
module.exports = function (app) {
6+
const mongooseClient = app.get('mongooseClient');
7+
const systemNotifications = new mongooseClient.Schema({
8+
type: { type: String, default: 'info', required: true, index: true },
9+
title: { type: String, required: true },
10+
content: { type: String, required: true },
11+
slot: { type: String, required: true, index: true },
12+
language: { type: String, required: true, index: true },
13+
permanent: { type: Boolean, default: false },
14+
requireConfirmation: { type: Boolean, default: false },
15+
active: { type: Boolean, default: true, index: true },
16+
totalCount: { type: Number, default: 0 },
17+
createdAt: { type: Date, default: Date.now },
18+
updatedAt: { type: Date, default: Date.now },
19+
wasSeeded: { type: Boolean }
20+
});
21+
22+
return mongooseClient.model('systemNotifications', systemNotifications);
23+
};

server/models/users.model.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ module.exports = function (app) {
4444
resetExpires: { type: Date },
4545
wasSeeded: { type: Boolean },
4646
wasInvited: { type: Boolean },
47-
language: { type: String, default: 'en' }
47+
language: { type: String, default: 'en' },
48+
termsAndConditionsAccepted: { type: Date }, // we display the terms and conditions on registration
49+
systemNotificationsSeen: { type: Array, default: [] }
4850
});
4951

5052
users.index({

server/seeder/base/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = function () {
55
// Add your seeder configs here
66
return [
77
require('./categories'),
8+
require('./pages'),
89
require('./badges')
910
];
1011
};

server/seeder/base/pages.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Database Seeder Config
2+
3+
// See https://www.npmjs.com/package/feathers-seeder
4+
// Using faker models https://github.com/marak/Faker.js/
5+
6+
// eslint-disable-next-line no-unused-vars
7+
module.exports = (seederstore) => {
8+
return {
9+
services: [
10+
{
11+
path: 'pages',
12+
template: {
13+
title: 'Terms and Condition',
14+
type: 'termsAndConditions',
15+
key: 'terms-and-conditions',
16+
content: '<strong>ADD TERMS AND CONDITIONS!</strong>',
17+
language: 'en'
18+
}
19+
},
20+
{
21+
path: 'pages',
22+
template: {
23+
title: 'Nutzungsbedingungen',
24+
type: 'termsAndConditions',
25+
key: 'terms-and-conditions',
26+
content: '<strong>FÜGE AGB`s HINZU!</strong>',
27+
language: 'de'
28+
}
29+
},
30+
{
31+
path: 'pages',
32+
template: {
33+
title: 'Data Privacy',
34+
type: 'dataPrivacy',
35+
key: 'data-privacy',
36+
content: '<strong>ADD PRIVACY POLICY!</strong>',
37+
language: 'en'
38+
}
39+
},
40+
{
41+
path: 'pages',
42+
template: {
43+
title: 'Datenschutzerklärung',
44+
type: 'dataPrivacy',
45+
key: 'data-privacy',
46+
content: '<strong>FÜGE DATENSCHUTZRICHTLINIEN HINZU!</strong>',
47+
language: 'de'
48+
}
49+
},
50+
{
51+
path: 'pages',
52+
template: {
53+
title: 'Imprint',
54+
type: 'imprint',
55+
key: 'imprint',
56+
content: '<strong>ADD IMPRINT!</strong>',
57+
language: 'en'
58+
}
59+
},
60+
{
61+
path: 'pages',
62+
template: {
63+
title: 'Impressum',
64+
type: 'imprint',
65+
key: 'imprint',
66+
content: '<strong>FÜGE EIN IMPRESSUM HINZU!</strong>',
67+
language: 'de'
68+
}
69+
}
70+
]
71+
};
72+
};

server/services/comments/comments.hooks.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
const {authenticate} = require('feathers-authentication').hooks;
2-
const {unless, isProvider, populate, discard, softDelete, setNow} = require('feathers-hooks-common');
1+
const { authenticate } = require('feathers-authentication').hooks;
2+
const { unless, isProvider, populate, discard, softDelete, setNow } = require('feathers-hooks-common');
33
const {
44
//queryWithCurrentUser,
55
associateCurrentUser,
66
// restrictToAuthenticated,
77
restrictToOwner
88
} = require('feathers-authentication-hooks');
9-
const {isVerified} = require('feathers-authentication-management').hooks;
9+
const { isVerified } = require('feathers-authentication-management').hooks;
1010
const createExcerpt = require('../../hooks/create-excerpt');
1111
const patchDeletedData = require('../../hooks/patch-deleted-data');
1212
const keepDeletedDataFields = require('../../hooks/keep-deleted-data-fields');
1313
const createNotifications = require('./hooks/create-notifications');
1414
const createMentionNotifications = require('./hooks/create-mention-notifications');
15+
const isModerator = require('../../hooks/is-moderator-boolean');
1516
const _ = require('lodash');
1617
const xss = require('../../hooks/xss');
1718

@@ -30,7 +31,7 @@ const xssFields = ['content', 'contentExcerpt'];
3031
module.exports = {
3132
before: {
3233
all: [
33-
xss({fields: xssFields})
34+
xss({ fields: xssFields })
3435
],
3536
find: [],
3637
get: [
@@ -43,7 +44,7 @@ module.exports = {
4344
isVerified()
4445
),
4546
associateCurrentUser(),
46-
createExcerpt({length: 180}),
47+
createExcerpt({ length: 180 }),
4748
softDelete()
4849
],
4950
update: [
@@ -52,7 +53,7 @@ module.exports = {
5253
isVerified(),
5354
restrictToOwner()
5455
),
55-
createExcerpt({length: 180}),
56+
createExcerpt({ length: 180 }),
5657
softDelete(),
5758
setNow('updatedAt')
5859
],
@@ -66,11 +67,11 @@ module.exports = {
6667
// the data has to be the exact copy of the valid object
6768
const valid = {$inc: {upvoteCount: 1}};
6869
return (!_.difference(_.keys(valid), _.keys(hook.data)).length) &&
69-
(!_.difference(_.keys(valid.$inc), _.keys(hook.data.$inc)).length) &&
70-
(!_.difference(_.values(valid.$inc), _.values(hook.data.$inc)).length);
70+
(!_.difference(_.keys(valid.$inc), _.keys(hook.data.$inc)).length) &&
71+
(!_.difference(_.values(valid.$inc), _.values(hook.data.$inc)).length);
7172
}, restrictToOwner())
7273
),
73-
createExcerpt({length: 180}),
74+
createExcerpt({ length: 180 }),
7475
softDelete(),
7576
setNow('updatedAt'),
7677
// SoftDelete uses patch to delete items
@@ -85,17 +86,19 @@ module.exports = {
8586
remove: [
8687
authenticate('jwt'),
8788
unless(isProvider('server'),
88-
isVerified(),
89-
restrictToOwner()
89+
unless(isModerator(),
90+
isVerified(),
91+
restrictToOwner()
92+
)
9093
),
9194
softDelete()
9295
]
9396
},
9497

9598
after: {
9699
all: [
97-
populate({schema: userSchema}),
98-
xss({fields: xssFields}),
100+
populate({ schema: userSchema }),
101+
xss({ fields: xssFields }),
99102
keepDeletedDataFields()
100103
],
101104
find: [

server/services/contributions/contributions.hooks.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ module.exports = {
168168
],
169169
remove: [
170170
authenticate('jwt'),
171-
isVerified(),
172171
unless(isModerator(),
173-
excludeDisabled(),
174172
restrictToOwner()
175173
),
176174
softDelete()

0 commit comments

Comments
 (0)