The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-sandstorm/server/lib.js

40 lines
1.1 KiB

import Future from 'fibers/future';
import { RocketChat } from 'meteor/rocketchat:lib';
import { UploadFS } from 'meteor/jalik:ufs';
RocketChat.Sandstorm = {};
export let getHttpBridge;
export let waitPromise;
if (process.env.SANDSTORM === '1') {
const Capnp = require('capnp');
const { SandstormHttpBridge } = Capnp.importSystem('sandstorm/sandstorm-http-bridge.capnp');
let capnpConnection = null;
let httpBridge = null;
getHttpBridge = function() {
if (!httpBridge) {
capnpConnection = Capnp.connect('unix:/tmp/sandstorm-api');
httpBridge = capnpConnection.restore(null, SandstormHttpBridge);
}
return httpBridge;
};
const promiseToFuture = function(promise) {
const result = new Future();
promise.then(result.return.bind(result), result.throw.bind(result));
return result;
};
waitPromise = function(promise) {
return promiseToFuture(promise).wait();
};
// This usual implementation of this method returns an absolute URL that is invalid
// under Sandstorm.
UploadFS.Store.prototype.getURL = function(path) {
return this.getRelativeURL(path);
};
}