diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/config/default.js | 4 | ||||
-rw-r--r-- | lib/config/defaultSSL.js | 2 | ||||
-rw-r--r-- | lib/config/dockerSecret.js | 3 | ||||
-rw-r--r-- | lib/config/environment.js | 4 | ||||
-rw-r--r-- | lib/config/index.js | 11 | ||||
-rw-r--r-- | lib/migrations/20171009121200-longtext-for-mysql.js | 16 | ||||
-rw-r--r-- | lib/models/note.js | 2 | ||||
-rw-r--r-- | lib/models/revision.js | 10 | ||||
-rw-r--r-- | lib/realtime.js | 8 | ||||
-rw-r--r-- | lib/response.js | 2 |
10 files changed, 45 insertions, 17 deletions
diff --git a/lib/config/default.js b/lib/config/default.js index 8d36db02..000c154a 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -16,6 +16,7 @@ module.exports = { protocolusessl: false, usecdn: true, allowanonymous: true, + allowanonymousedits: false, allowfreeurl: false, defaultpermission: 'editable', dburl: '', @@ -81,7 +82,8 @@ module.exports = { }, dropbox: { clientID: undefined, - clientSecret: undefined + clientSecret: undefined, + appKey: undefined }, google: { clientID: undefined, diff --git a/lib/config/defaultSSL.js b/lib/config/defaultSSL.js index 1f1d5590..362c62a1 100644 --- a/lib/config/defaultSSL.js +++ b/lib/config/defaultSSL.js @@ -12,6 +12,6 @@ function getFile (path) { module.exports = { sslkeypath: getFile('/run/secrets/key.pem'), sslcertpath: getFile('/run/secrets/cert.pem'), - sslcapath: getFile('/run/secrets/ca.pem'), + sslcapath: getFile('/run/secrets/ca.pem') !== undefined ? [getFile('/run/secrets/ca.pem')] : [], dhparampath: getFile('/run/secrets/dhparam.pem') } diff --git a/lib/config/dockerSecret.js b/lib/config/dockerSecret.js index ac54fd19..b9116cd3 100644 --- a/lib/config/dockerSecret.js +++ b/lib/config/dockerSecret.js @@ -44,7 +44,8 @@ if (fs.existsSync(basePath)) { }, dropbox: { clientID: getSecret('dropbox_clientID'), - clientSecret: getSecret('dropbox_clientSecret') + clientSecret: getSecret('dropbox_clientSecret'), + appKey: getSecret('dropbox_appKey') }, google: { clientID: getSecret('google_clientID'), diff --git a/lib/config/environment.js b/lib/config/environment.js index 27e63591..eedd4913 100644 --- a/lib/config/environment.js +++ b/lib/config/environment.js @@ -18,6 +18,7 @@ module.exports = { alloworigin: toArrayConfig(process.env.HMD_ALLOW_ORIGIN), usecdn: toBooleanConfig(process.env.HMD_USECDN), allowanonymous: toBooleanConfig(process.env.HMD_ALLOW_ANONYMOUS), + allowanonymousedits: toBooleanConfig(process.env.HMD_ALLOW_ANONYMOUS_EDITS), allowfreeurl: toBooleanConfig(process.env.HMD_ALLOW_FREEURL), defaultpermission: process.env.HMD_DEFAULT_PERMISSION, dburl: process.env.HMD_DB_URL, @@ -56,7 +57,8 @@ module.exports = { }, dropbox: { clientID: process.env.HMD_DROPBOX_CLIENTID, - clientSecret: process.env.HMD_DROPBOX_CLIENTSECRET + clientSecret: process.env.HMD_DROPBOX_CLIENTSECRET, + appKey: process.env.HMD_DROPBOX_APPKEY }, google: { clientID: process.env.HMD_GOOGLE_CLIENTID, diff --git a/lib/config/index.js b/lib/config/index.js index 3ac3de53..3d22c3c3 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -13,8 +13,10 @@ const debugConfig = { debug: (env === Environment.development) } +const {version} = require(path.join(appRootPath, 'package.json')) + const packageConfig = { - version: '0.5.1', + version: version, minimumCompatibleVersion: '0.5.0' } @@ -47,7 +49,7 @@ if (config.ldap.tlsca) { // Permission config.permission = Permission -if (!config.allowanonymous) { +if (!config.allowanonymous && !config.allowanonymousedits) { delete config.permission.freely } if (!(config.defaultpermission in config.permission)) { @@ -96,7 +98,10 @@ config.isSAMLEnable = config.saml.idpSsoUrl config.isPDFExportEnable = config.allowpdfexport // generate correct path -config.sslcapath = path.join(appRootPath, config.sslcapath) +config.sslcapath.forEach(function (capath, i, array) { + array[i] = path.resolve(appRootPath, capath) +}) + config.sslcertpath = path.join(appRootPath, config.sslcertpath) config.sslkeypath = path.join(appRootPath, config.sslkeypath) config.dhparampath = path.join(appRootPath, config.dhparampath) diff --git a/lib/migrations/20171009121200-longtext-for-mysql.js b/lib/migrations/20171009121200-longtext-for-mysql.js new file mode 100644 index 00000000..61b409ca --- /dev/null +++ b/lib/migrations/20171009121200-longtext-for-mysql.js @@ -0,0 +1,16 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + queryInterface.changeColumn('Notes', 'content', {type: Sequelize.TEXT('long')}) + queryInterface.changeColumn('Revisions', 'patch', {type: Sequelize.TEXT('long')}) + queryInterface.changeColumn('Revisions', 'content', {type: Sequelize.TEXT('long')}) + queryInterface.changeColumn('Revisions', 'latContent', {type: Sequelize.TEXT('long')}) + }, + + down: function (queryInterface, Sequelize) { + queryInterface.changeColumn('Notes', 'content', {type: Sequelize.TEXT}) + queryInterface.changeColumn('Revisions', 'patch', {type: Sequelize.TEXT}) + queryInterface.changeColumn('Revisions', 'content', {type: Sequelize.TEXT}) + queryInterface.changeColumn('Revisions', 'latContent', {type: Sequelize.TEXT}) + } +} diff --git a/lib/models/note.js b/lib/models/note.js index c0ef1374..33dde80d 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -60,7 +60,7 @@ module.exports = function (sequelize, DataTypes) { } }, content: { - type: DataTypes.TEXT, + type: DataTypes.TEXT('long'), get: function () { return sequelize.processData(this.getDataValue('content'), '') }, diff --git a/lib/models/revision.js b/lib/models/revision.js index 225a95d4..170931b8 100644 --- a/lib/models/revision.js +++ b/lib/models/revision.js @@ -58,7 +58,7 @@ module.exports = function (sequelize, DataTypes) { defaultValue: Sequelize.UUIDV4 }, patch: { - type: DataTypes.TEXT, + type: DataTypes.TEXT('long'), get: function () { return sequelize.processData(this.getDataValue('patch'), '') }, @@ -67,7 +67,7 @@ module.exports = function (sequelize, DataTypes) { } }, lastContent: { - type: DataTypes.TEXT, + type: DataTypes.TEXT('long'), get: function () { return sequelize.processData(this.getDataValue('lastContent'), '') }, @@ -76,7 +76,7 @@ module.exports = function (sequelize, DataTypes) { } }, content: { - type: DataTypes.TEXT, + type: DataTypes.TEXT('long'), get: function () { return sequelize.processData(this.getDataValue('content'), '') }, @@ -237,8 +237,8 @@ module.exports = function (sequelize, DataTypes) { // if no revision available Revision.create({ noteId: note.id, - lastContent: note.content, - length: note.content.length, + lastContent: note.content ? note.content : '', + length: note.content ? note.content.length : 0, authorship: note.authorship }).then(function (revision) { Revision.finishSaveNoteRevision(note, revision, callback) diff --git a/lib/realtime.js b/lib/realtime.js index 361bbf09..c731e5b0 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -709,7 +709,7 @@ function connection (socket) { return failConnection(404, 'note id not found', socket) } - if (isDuplicatedInSocketQueue(socket, connectionSocketQueue)) return + if (isDuplicatedInSocketQueue(connectionSocketQueue, socket)) return // store noteId in this socket session socket.noteId = noteId @@ -723,8 +723,8 @@ function connection (socket) { var maxrandomcount = 10 var found = false do { - Object.keys(notes[noteId].users).forEach(function (user) { - if (user.color === color) { + Object.keys(notes[noteId].users).forEach(function (userId) { + if (notes[noteId].users[userId].color === color) { found = true } }) @@ -781,7 +781,7 @@ function connection (socket) { var note = notes[noteId] // Only owner can change permission if (note.owner && note.owner === socket.request.user.id) { - if (permission === 'freely' && !config.allowanonymous) return + if (permission === 'freely' && !config.allowanonymous && !config.allowanonymousedits) return note.permission = permission models.Note.update({ permission: permission diff --git a/lib/response.js b/lib/response.js index 2e8924b7..1c04f9f6 100644 --- a/lib/response.js +++ b/lib/response.js @@ -60,6 +60,7 @@ function showIndex (req, res, next) { url: config.serverurl, useCDN: config.usecdn, allowAnonymous: config.allowanonymous, + allowAnonymousEdits: config.allowanonymousedits, facebook: config.isFacebookEnable, twitter: config.isTwitterEnable, github: config.isGitHubEnable, @@ -93,6 +94,7 @@ function responseHackMD (res, note) { title: title, useCDN: config.usecdn, allowAnonymous: config.allowanonymous, + allowAnonymousEdits: config.allowanonymousedits, facebook: config.isFacebookEnable, twitter: config.isTwitterEnable, github: config.isGitHubEnable, |