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

Commit 6b5813f

Browse files
Merge pull request #63 from Human-Connection/feature/system-notifications
System Notifications & DSVGO
2 parents 139d9ac + a363315 commit 6b5813f

17 files changed

+400
-9082
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.3.0",
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: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
wasSeeded: true
19+
}
20+
},
21+
{
22+
path: 'pages',
23+
template: {
24+
title: 'Nutzungsbedingungen',
25+
type: 'termsAndConditions',
26+
key: 'terms-and-conditions',
27+
content: '<strong>FÜGE AGB`s HINZU!</strong>',
28+
language: 'de',
29+
wasSeeded: true
30+
}
31+
},
32+
{
33+
path: 'pages',
34+
template: {
35+
title: 'Data Privacy',
36+
type: 'dataPrivacy',
37+
key: 'data-privacy',
38+
content: '<strong>ADD PRIVACY POLICY!</strong>',
39+
language: 'en',
40+
wasSeeded: true
41+
}
42+
},
43+
{
44+
path: 'pages',
45+
template: {
46+
title: 'Datenschutzerklärung',
47+
type: 'dataPrivacy',
48+
key: 'data-privacy',
49+
content: '<strong>FÜGE DATENSCHUTZRICHTLINIEN HINZU!</strong>',
50+
language: 'de',
51+
wasSeeded: true
52+
}
53+
},
54+
{
55+
path: 'pages',
56+
template: {
57+
title: 'Imprint',
58+
type: 'imprint',
59+
key: 'imprint',
60+
content: '<strong>ADD IMPRINT!</strong>',
61+
language: 'en',
62+
wasSeeded: true
63+
}
64+
},
65+
{
66+
path: 'pages',
67+
template: {
68+
title: 'Impressum',
69+
type: 'imprint',
70+
key: 'imprint',
71+
content: '<strong>FÜGE EIN IMPRESSUM HINZU!</strong>',
72+
language: 'de',
73+
wasSeeded: true
74+
}
75+
}
76+
]
77+
};
78+
};

server/services/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const invites = require('./invites/invites.service.js');
1919
const usersCandos = require('./users-candos/users-candos.service.js');
2020
const search = require('./search/search.service.js');
2121
const usersettings = require('./usersettings/usersettings.service.js');
22+
const pages = require('./pages/pages.service.js');
23+
const systemNotifications = require('./system-notifications/system-notifications.service.js');
2224

2325
module.exports = function () {
2426
const app = this; // eslint-disable-line no-unused-vars
@@ -43,4 +45,6 @@ module.exports = function () {
4345
app.configure(usersCandos);
4446
app.configure(search);
4547
app.configure(usersettings);
48+
app.configure(pages);
49+
app.configure(systemNotifications);
4650
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint no-console: 1 */
2+
console.warn('You are using the default filter for the pages service. For more information about event filters see https://docs.feathersjs.com/api/events.html#event-filtering'); // eslint-disable-line no-console
3+
4+
module.exports = function (data, connection, hook) { // eslint-disable-line no-unused-vars
5+
return data;
6+
};

0 commit comments

Comments
 (0)