chore: Remove WEBSOCKETS_ENABLED flag (#1383)

* chore: Remove WEBSOCKETS_ENALBED flag

* lint
This commit is contained in:
Tom Moor
2020-07-22 22:44:24 -07:00
committed by GitHub
parent 2cc6d7add8
commit 109efcaa27
7 changed files with 141 additions and 157 deletions

View File

@ -18,7 +18,6 @@ PORT=3000
FORCE_HTTPS=true FORCE_HTTPS=true
ENABLE_UPDATES=true ENABLE_UPDATES=true
WEBSOCKETS_ENABLED=true
DEBUG=cache,presenters,events DEBUG=cache,presenters,events
# Third party signin credentials (at least one is required) # Third party signin credentials (at least one is required)

View File

@ -39,11 +39,6 @@
"value": "true", "value": "true",
"required": true "required": true
}, },
"WEBSOCKETS_ENABLED": {
"value": "true",
"required": true,
"description": "Allow realtime data to be pushed to clients over websockets"
},
"URL": { "URL": {
"description": "https://{your app name}.herokuapp.com", "description": "https://{your app name}.herokuapp.com",
"required": true "required": true

View File

@ -13,7 +13,6 @@ import PoliciesStore from "stores/PoliciesStore";
import ViewsStore from "stores/ViewsStore"; import ViewsStore from "stores/ViewsStore";
import AuthStore from "stores/AuthStore"; import AuthStore from "stores/AuthStore";
import UiStore from "stores/UiStore"; import UiStore from "stores/UiStore";
import env from "env";
export const SocketContext: any = React.createContext(); export const SocketContext: any = React.createContext();
@ -35,8 +34,6 @@ class SocketProvider extends React.Component<Props> {
@observable socket; @observable socket;
componentDidMount() { componentDidMount() {
if (!env.WEBSOCKETS_ENABLED) return;
this.socket = io(window.location.origin, { this.socket = io(window.location.origin, {
path: "/realtime", path: "/realtime",
}); });

View File

@ -62,12 +62,6 @@ if (!process.env.REDIS_URL) {
process.exit(1); process.exit(1);
} }
if (!process.env.WEBSOCKETS_ENABLED) {
console.log(
"WARNING: Websockets are disabled. Set WEBSOCKETS_ENABLED env variable to true to enable"
);
}
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
console.log("\n\x1b[33m%s\x1b[0m", "Running Outline in production mode."); console.log("\n\x1b[33m%s\x1b[0m", "Running Outline in production mode.");
} else if (process.env.NODE_ENV === "development") { } else if (process.env.NODE_ENV === "development") {

View File

@ -7,6 +7,5 @@ export default {
SLACK_KEY: process.env.SLACK_KEY, SLACK_KEY: process.env.SLACK_KEY,
SLACK_APP_ID: process.env.SLACK_APP_ID, SLACK_APP_ID: process.env.SLACK_APP_ID,
SUBDOMAINS_ENABLED: process.env.SUBDOMAINS_ENABLED === "true", SUBDOMAINS_ENABLED: process.env.SUBDOMAINS_ENABLED === "true",
WEBSOCKETS_ENABLED: process.env.WEBSOCKETS_ENABLED === "true",
GOOGLE_ANALYTICS_ID: process.env.GOOGLE_ANALYTICS_ID, GOOGLE_ANALYTICS_ID: process.env.GOOGLE_ANALYTICS_ID,
}; };

View File

@ -12,23 +12,22 @@ import policy from "./policies";
const server = http.createServer(app.callback()); const server = http.createServer(app.callback());
let io; let io;
if (process.env.WEBSOCKETS_ENABLED === "true") { const { can } = policy;
const { can } = policy;
io = IO(server, { io = IO(server, {
path: "/realtime", path: "/realtime",
serveClient: false, serveClient: false,
cookie: false, cookie: false,
}); });
io.adapter( io.adapter(
socketRedisAdapter({ socketRedisAdapter({
pubClient: client, pubClient: client,
subClient: subscriber, subClient: subscriber,
}) })
); );
SocketAuth(io, { SocketAuth(io, {
authenticate: async (socket, data, callback) => { authenticate: async (socket, data, callback) => {
const { token } = data; const { token } = data;
@ -172,8 +171,7 @@ if (process.env.WEBSOCKETS_ENABLED === "true") {
} }
}); });
}, },
}); });
}
server.on("error", err => { server.on("error", err => {
throw err; throw err;

View File

@ -13,7 +13,9 @@ import subHours from "date-fns/sub_hours";
export default class Websockets { export default class Websockets {
async on(event: Event) { async on(event: Event) {
if (process.env.WEBSOCKETS_ENABLED !== "true" || !socketio) return; if (!socketio) {
return;
}
switch (event.name) { switch (event.name) {
case "documents.publish": case "documents.publish":