basic import functionality; dockerfile fixes; session and cookie handling fixes
This commit is contained in:
@@ -53,7 +53,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
}, function(err, data) {
|
||||
if(err) console.log('Email not sent:', err);
|
||||
if (err) console.error("Error sending email:", err);
|
||||
else console.log("Email sent.");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,31 +32,36 @@ module.exports = {
|
||||
};
|
||||
|
||||
phantom.create({ path: require('phantomjs-prebuilt').path }, function (err, browser) {
|
||||
return browser.createPage(function (err, page) {
|
||||
console.log("page created, opening ",space_url);
|
||||
if(err){
|
||||
console.log(err);
|
||||
}else{
|
||||
return browser.createPage(function (err, page) {
|
||||
console.log("page created, opening ",space_url);
|
||||
|
||||
if (type=="pdf") {
|
||||
var psz = {
|
||||
width: space.advanced.width+"px",
|
||||
height: space.advanced.height+"px"
|
||||
};
|
||||
page.set('paperSize', psz);
|
||||
}
|
||||
if (type=="pdf") {
|
||||
var psz = {
|
||||
width: space.advanced.width+"px",
|
||||
height: space.advanced.height+"px"
|
||||
};
|
||||
page.set('paperSize', psz);
|
||||
}
|
||||
|
||||
page.set('settings.resourceTimeout',timeout);
|
||||
page.set('settings.javascriptEnabled',false);
|
||||
page.set('settings.resourceTimeout',timeout);
|
||||
page.set('settings.javascriptEnabled',false);
|
||||
|
||||
return page.open(space_url, function (err,status) {
|
||||
page.render(export_path, function() {
|
||||
on_success_called = true;
|
||||
if (on_success) {
|
||||
on_success(export_path);
|
||||
}
|
||||
page.close();
|
||||
browser.exit();
|
||||
return page.open(space_url, function (err,status) {
|
||||
page.render(export_path, function() {
|
||||
on_success_called = true;
|
||||
if (on_success) {
|
||||
on_success(export_path);
|
||||
}
|
||||
page.close();
|
||||
browser.exit();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}, {
|
||||
onExit: on_exit
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
|
||||
// this is a mock version of the Redis API,
|
||||
// emulating Redis if it is not available locally
|
||||
var notRedis = {
|
||||
@@ -92,7 +94,12 @@ var notRedis = {
|
||||
|
||||
module.exports = {
|
||||
connectRedis: function() {
|
||||
this.connection = notRedis;
|
||||
if (config.get("redis_mock")) {
|
||||
this.connection = notRedis;
|
||||
} else {
|
||||
const redisHost = process.env.REDIS_PORT_6379_TCP_ADDR || 'sync';
|
||||
this.connection = new RedisConnection(6379, redisHost);
|
||||
}
|
||||
},
|
||||
getConnection: function() {
|
||||
this.connectRedis();
|
||||
|
||||
@@ -2,21 +2,40 @@
|
||||
|
||||
var fs = require('fs');
|
||||
var config = require('config');
|
||||
var s3 = null;
|
||||
|
||||
// use AWS S3 or local folder depending on config
|
||||
if (config.get("storage_local_path")) {
|
||||
var AWS = require('mock-aws-s3');
|
||||
AWS.config.basePath = config.get("storage_local_path");
|
||||
s3 = new AWS.S3();
|
||||
} else {
|
||||
var AWS = require('aws-sdk');
|
||||
AWS.config.region = config.get("storage_region");
|
||||
var storage_endpoint = config.get("storage_endpoint");
|
||||
const ep = new AWS.Endpoint(storage_endpoint);
|
||||
|
||||
AWS.config.update(new AWS.Config({
|
||||
accessKeyId: process.env.MINIO_ACCESS_KEY,
|
||||
secretAccessKey: process.env.MINIO_SECRET_KEY,
|
||||
region: config.get("storage_region"),
|
||||
s3ForcePathStyle: true,
|
||||
signatureVersion: 'v4'
|
||||
}));
|
||||
s3 = new AWS.S3({
|
||||
endpoint: ep
|
||||
});
|
||||
}
|
||||
|
||||
s3.createBucket({
|
||||
Bucket: config.get("storage_bucket"),
|
||||
ACL: "public-read",
|
||||
GrantRead: "*"
|
||||
}, (err,res) => {
|
||||
console.log("createBucket",err,res);
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
removeFile: (path, callback) => {
|
||||
const s3 = new AWS.S3({
|
||||
region: config.get("storage_region")
|
||||
});
|
||||
const bucket = config.get("storage_bucket");
|
||||
s3.deleteObject({
|
||||
Bucket: bucket, Key: path
|
||||
@@ -34,7 +53,7 @@ module.exports = {
|
||||
callback({error:"missing path"}, null);
|
||||
return;
|
||||
}
|
||||
console.log("[s3] uploading", localFilePath, " to ", fileName);
|
||||
console.log("[storage] uploading", localFilePath, " to ", fileName);
|
||||
|
||||
const bucket = config.get("storage_bucket");
|
||||
const fileStream = fs.createReadStream(localFilePath);
|
||||
@@ -45,10 +64,6 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
fileStream.on('open', function () {
|
||||
var s3 = new AWS.S3({
|
||||
region: config.get("storage_region")
|
||||
});
|
||||
|
||||
s3.putObject({
|
||||
Bucket: bucket,
|
||||
Key: fileName,
|
||||
@@ -58,7 +73,7 @@ module.exports = {
|
||||
if (err){
|
||||
console.error(err);
|
||||
callback(err);
|
||||
}else {
|
||||
} else {
|
||||
const url = config.get("storage_cdn") + "/" + fileName;
|
||||
console.log("[s3]" + localFilePath + " to " + url);
|
||||
callback(null, url);
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
'use strict';
|
||||
require('../models/schema');
|
||||
|
||||
const config = require('config');
|
||||
|
||||
const WebSocketServer = require('ws').Server;
|
||||
|
||||
const RedisConnection = require('ioredis');
|
||||
const async = require('async');
|
||||
const _ = require("underscore");
|
||||
const mongoose = require("mongoose");
|
||||
const crypto = require('crypto');
|
||||
|
||||
var redis = require("./redis.js");
|
||||
const redisMock = require("./redis.js");
|
||||
|
||||
module.exports = {
|
||||
startWebsockets: function(server) {
|
||||
this.setupSubscription();
|
||||
this.state = redis.getConnection();
|
||||
|
||||
if(!this.current_websockets) {
|
||||
if (!this.current_websockets) {
|
||||
if (config.get("redis_mock")) {
|
||||
this.state = redisMock.getConnection();
|
||||
} else {
|
||||
this.state = new RedisConnection(6379, process.env.REDIS_PORT_6379_TCP_ADDR || config.get("redis_host"));
|
||||
}
|
||||
this.current_websockets = [];
|
||||
}
|
||||
|
||||
@@ -118,9 +125,17 @@ module.exports = {
|
||||
},
|
||||
|
||||
setupSubscription: function() {
|
||||
this.cursorSubscriber = redis.getConnection().subscribe(['cursors', 'users', 'updates'], function (err, count) {
|
||||
console.log("[redis] websockets to " + count + " topics." );
|
||||
});
|
||||
if (config.get("redis_mock")) {
|
||||
this.cursorSubscriber = redisMock.getConnection().subscribe(['cursors', 'users', 'updates'], function (err, count) {
|
||||
console.log("[redis-mock] websockets subscribed to " + count + " topics." );
|
||||
});
|
||||
} else {
|
||||
this.cursorSubscriber = new RedisConnection(6379, process.env.REDIS_PORT_6379_TCP_ADDR || config.get("redis_host"));
|
||||
this.cursorSubscriber.subscribe(['cursors', 'users', 'updates'], function (err, count) {
|
||||
console.log("[redis] websockets subscribed to " + count + " topics." );
|
||||
});
|
||||
}
|
||||
|
||||
this.cursorSubscriber.on('message', function (channel, rawMessage) {
|
||||
const msg = JSON.parse(rawMessage);
|
||||
const spaceId = msg.space_id;
|
||||
|
||||
Reference in New Issue
Block a user