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

Commit ea21062

Browse files
switched to channels and deleted filters
1 parent e6f4e44 commit ea21062

File tree

23 files changed

+36
-125
lines changed

23 files changed

+36
-125
lines changed

server/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ app.configure(socketio());
6060
// Configure Database Seeder
6161
app.configure(seeder());
6262

63-
app.configure(channels);
64-
6563
app.configure(authentication);
6664

6765
// Set up our services (see `services/index.js`)
6866
app.configure(services);
67+
app.configure(channels);
6968

7069
if (process.env.NODE_ENV !== 'production') {
7170
app.configure(profiler({

server/channels.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ module.exports = function (app) {
1414
// real-time connection, e.g. when logging in via REST
1515
if (connection) {
1616
// Obtain the logged in user from the connection
17-
// const user = connection.user;
17+
const user = connection.user;
1818

1919
// The connection is no longer anonymous, remove it
2020
app.channel('anonymous').leave(connection);
2121

2222
// Add it to the authenticated user channel
2323
app.channel('authenticated').join(connection);
2424

25+
if (user.role === 'moderator') { app.channel('moderators').join(connection); }
26+
if (user.role === 'admin') { app.channel('admins').join(connection); }
27+
2528
// Channels can be named anything and joined on any condition
2629

2730
// E.g. to send real-time events only to admins use
@@ -36,13 +39,38 @@ module.exports = function (app) {
3639
}
3740
});
3841

39-
app.publish((data, hook) => { // eslint-disable-line no-unused-vars
40-
// Here you can add event publishers to channels set up in `channels.js`
41-
// To publish only for a specific event use `app.publish(eventname, () => {})`
42+
// app.publish((data, hook) => { // eslint-disable-line no-unused-vars
43+
// // Here you can add event publishers to channels set up in `channels.js`
44+
// // To publish only for a specific event use `app.publish(eventname, () => {})`
45+
// // e.g. to publish all service events to all authenticated users use
46+
// return app.channel('authenticated');
47+
// });
4248

43-
// e.g. to publish all service events to all authenticated users use
44-
return app.channel('authenticated');
45-
});
49+
app.service('contributions').publish('patched', () => app.channel('authenticated'));
50+
51+
app.service('categories').publish(() => app.channel('anonymous', 'authenticated'));
52+
app.service('comments').publish(() => app.channel('authenticated'));
53+
app.service('follows').publish(() => app.channel('authenticated'));
54+
app.service('users-candos').publish(() => app.channel('authenticated'));
55+
app.service('notifications').publish(() => app.channel('authenticated'));
56+
app.service('system-notifications').publish(() => app.channel('authenticated'));
57+
58+
app.service('users').publish(() => app.channel('admins'));
59+
app.service('organizations').publish(() => app.channel('admins', 'moderators'));
60+
61+
// app.service('contributions').publish((data) => {
62+
// return [
63+
// // app.channel('anonymous'),
64+
// // app.channel('authenticated')
65+
// app.channel(`contributions/${data._id}`)
66+
// ];
67+
// });
68+
// app.service('contributions').publish((data) => {
69+
// return app.channel(`contributions/${data.slug}`);
70+
// });
71+
// app.service('comments').publish((data) => {
72+
// return app.channel(`contributions/${data.slug}`);
73+
// });
4674

4775
// Here you can also add service specific event publishers
4876
// e..g the publish the `users` service `created` event to the `admins` channel

server/services/admin/admin.filters.js

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

server/services/badges/badges.filters.js

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

server/services/categories/categories.filters.js

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

server/services/comments/comments.filters.js

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

server/services/contributions/contributions.filters.js

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

server/services/emotions/emotions.filters.js

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

server/services/follows/follows.filters.js

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

server/services/images/images.filters.js

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

0 commit comments

Comments
 (0)