Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit 307dfe8

Browse files
author
bhasher
committed
Backend necessary bugfix
1 parent 2319f1a commit 307dfe8

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/db/MongoDB.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class MongoDB {
110110

111111
async newLine (documentLink, previousUuid, uuid, content) {
112112
// Insert a line at the right place
113-
//TODO is it possible in one operation ?
113+
//TODO is it possible in one operation ?
114114
// TODO is it possible to implement with bulk?
115115
try {
116116
let doc = await this.documentsCollection.findOne({documentLink: documentLink});
@@ -206,17 +206,18 @@ class MongoDB {
206206
for (let request of requests) {
207207
let requestType = request.type;
208208
let data = request.data;
209+
let results = ""
209210
switch (requestType) {
210211
case 'set-line':
211-
let results = await this.setLine(documentLink, data.id, data.content);
212+
results = await this.setLine(documentLink, data.id, data.content);
212213
if (!results) success = false;
213214
break;
214215
case 'new-line':
215-
let results = await this.newLine(documentLink, data.previous, data.id, data.content);
216+
results = await this.newLine(documentLink, data.previous, data.id, data.content);
216217
if (!results) success = false;
217218
break;
218219
case 'delete-line':
219-
let results = await this.deleteLine(documentLink, data.id);
220+
results = await this.deleteLine(documentLink, data.id);
220221
if (!results) success = false;
221222
break;
222223
}

src/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Alexandre Dewilde
44
* @date 15/11/2020
55
* @version 1.0.0
6-
*
6+
*
77
*/
88
const fs = require('fs');
99
const path = require('path');
@@ -15,7 +15,7 @@ const port = configs.PORT;
1515
const DEBUG = configs.DEBUG;
1616
const ssl = configs.SSL;
1717
const sslKeyPath = configs.KEY_FILE_SSL;
18-
const sslCertPath = configs.CERT_FILE_SSL;
18+
const sslCertPath = configs.CERT_FILE_SSL;
1919

2020
const options = ssl ? {
2121
key: fs.readFileSync(sslKeyPath.startsWith('/') ? sslKeyPath : path.join(__dirname, sslKeyPath), 'utf8'),
@@ -29,7 +29,7 @@ const http = ssl ? require('https') : require('http');
2929
const server = http.createServer(options, app);
3030
if (configs.METRICS) {
3131
const {metricsApp} = require('./metricsApp');
32-
var metricsServer = http.createServer(metricsApp);
32+
var metricsServer = require('http').createServer(metricsApp);
3333
}
3434

3535
// config websockets

src/socket/socket.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ module.exports = function (wss) {
6666
broadcastRoomExceptSender(data, 'uuid', data.uuid);
6767
const succesUpdatingDate = db.updateLastViewedDate(data.room);
6868
const succesUpdate = db.applyRequests(data.room, data.data);
69-
if (!succesUpdatingDate || !succesUpdate) socket.send(JSON.stringify({event: 'update', success: false}));
69+
// /!\ Bad event
70+
// if (!succesUpdatingDate || !succesUpdate) socket.send(JSON.stringify({event: 'update', success: false}));
7071
} catch (err) {
7172
if (config.DEBUG) {
7273
console.error(err);
@@ -82,7 +83,7 @@ module.exports = function (wss) {
8283
rooms[data.room][uuid] = socket;
8384
}
8485
break;
85-
86+
8687
case 'language':
8788
try {
8889
broadcastRoomExceptSender(data, 'language', data.language);

0 commit comments

Comments
 (0)