-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/sc 3033 reconnect #50
base: develop
Are you sure you want to change the base?
Changes from all commits
d26eb99
9db3047
ceedf90
aae7ab8
752a009
08ac2c3
34513e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
{ | ||
"host": "localhost", | ||
"port": 4001, | ||
"protocol": "http", | ||
"mongodb": "mongodb://localhost:27017/schulcloud-editor", | ||
"routes": { | ||
"server": { | ||
"baseURL": "http://localhost:3030", | ||
"coursePermissionsUri": "/courses/:courseId/userPermissions", | ||
"meUri": "/me", | ||
"courseMembersUri": "/courses/:courseId/members" | ||
}, | ||
"timeout": "30000" | ||
}, | ||
"testsecret": "secret", | ||
"redis": "REDIS_URI", | ||
"redis_key": "REDIS_KEY" | ||
} | ||
{ | ||
"host": "api.edtr.l", | ||
"port": 4001, | ||
"protocol": "http", | ||
"mongodb": "mongodb://mongodb:27017/schulcloud-editor", | ||
"routes": { | ||
"server": { | ||
"baseURL": "http://server:3030", | ||
"coursePermissionsUri": "/courses/:courseId/userPermissions", | ||
"meUri": "/me", | ||
"courseMembersUri": "/courses/:courseId/members" | ||
}, | ||
"timeout": "30000" | ||
}, | ||
"testsecret": "secret", | ||
"redis": "REDIS_URI", | ||
"redis_key": "REDIS_KEY" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ exports.before = { | |
const after = { | ||
// todo select is better but need more stable implementations | ||
all: [iff(isProvider('external'), | ||
filterOutResults('__v', 'createdAt', 'updatedAt')), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change this? @CordlessWool There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its a long time ago, I could not remember, but its filter out before sending it to the client? For the client the data are not necassery |
||
filterOutResults('__v', 'createdBy', 'updatedBy')), | ||
], | ||
find: [], | ||
get: [], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ module.exports = app => app.configure( | |
socketio((io) => { | ||
io.on('connection', (socket) => { | ||
// do some authorization things | ||
app.channel('anonymous').join(socket.feathers); | ||
// app.channel('anonymous').join(socket.feathers); | ||
Comment on lines
7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. der Change ist von @CordlessWool , gebe die Frage weiter :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ich glaube er wollte ein channel für alle haben. Ich würde es erst mal auskommentiert lassen, bis wir es benötigen. |
||
|
||
socket.on('authorization', (data) => { | ||
const { token } = data; | ||
|
@@ -14,6 +14,7 @@ module.exports = app => app.configure( | |
}); | ||
}); | ||
|
||
|
||
// socketJwtHandler(io); | ||
|
||
io.use((socket, next) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
exports.diffToMongo = require('./diffToMongo'); | ||
const { filterManyByHashes, filterStateByHash } = require('./versionHashes'); | ||
const diffToMongo = require('./diffToMongo'); | ||
|
||
module.exports = { diffToMongo, filterManyByHashes, filterStateByHash }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { BadRequest } = require('@feathersjs/errors'); | ||
|
||
/** | ||
* if the hash matches the hash of the section, this function filters any data that is not required by the client | ||
* (since he already has the most recent version of the section) | ||
* @param {Object} section a section | ||
* @param {String} hash string, representing a hash of a version of the section | ||
*/ | ||
const filterStateByHash = (section, hash) => { | ||
const clientAlreadyHasNewestState = hash && hash === section.hash; | ||
if (clientAlreadyHasNewestState) { | ||
return { | ||
_id: section._id, | ||
permissions: section.permissions, | ||
title: section.title, | ||
hash: section.hash, | ||
}; | ||
} | ||
return section; | ||
}; | ||
|
||
/** | ||
* applies filterStateByHash on an array of sections, using a map of hashes | ||
* @param {Array} sections an array of sections. | ||
* @param {stringified JSON} hashes Object with sectionIds as keys, and hashes as values. | ||
*/ | ||
const filterManyByHashes = (sections, hashes) => { | ||
if (hashes) { | ||
try { | ||
// eslint-disable-next-line no-param-reassign | ||
hashes = JSON.parse(hashes); | ||
} catch (err) { | ||
throw new BadRequest('hashes should be valid stringified JSON'); | ||
} | ||
return sections.map((section) => filterStateByHash(section, hashes[section._id.toString()])); | ||
} | ||
return sections; | ||
}; | ||
|
||
module.exports = { filterManyByHashes, filterStateByHash }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you set this file to default please.