Browse Source

fix unhandled exception

loopout2 1.0.10
Evan Feenstra 5 years ago
parent
commit
740f0b8eda
  1. 6
      .babelrc
  2. BIN
      binaries/node_sqlite3.node
  3. 19
      dist/src/controllers/messages.js
  4. 2
      dist/src/controllers/messages.js.map
  5. 22
      src/controllers/messages.ts

6
.babelrc

@ -1,6 +0,0 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}

BIN
binaries/node_sqlite3.node

Binary file not shown.

19
dist/src/controllers/messages.js

@ -257,13 +257,18 @@ exports.readMessages = (req, res) => __awaiter(void 0, void 0, void 0, function*
} }
}); });
const chat = yield models_1.models.Chat.findOne({ where: { id: chat_id } }); const chat = yield models_1.models.Chat.findOne({ where: { id: chat_id } });
yield chat.update({ seen: true }); if (chat) {
res_1.success(res, {}); yield chat.update({ seen: true });
hub_1.sendNotification(chat, '', 'badge'); res_1.success(res, {});
socket.sendJson({ hub_1.sendNotification(chat, '', 'badge');
type: 'chat_seen', socket.sendJson({
response: jsonUtils.chatToJson(chat) type: 'chat_seen',
}); response: jsonUtils.chatToJson(chat)
});
}
else {
res_1.failure(res, 'no chat');
}
}); });
exports.clearMessages = (req, res) => { exports.clearMessages = (req, res) => {
models_1.models.Message.destroy({ where: {}, truncate: true }); models_1.models.Message.destroy({ where: {}, truncate: true });

2
dist/src/controllers/messages.js.map

File diff suppressed because one or more lines are too long

22
src/controllers/messages.ts

@ -5,7 +5,7 @@ import { sendNotification } from '../hub'
import * as socket from '../utils/socket' import * as socket from '../utils/socket'
import * as jsonUtils from '../utils/json' import * as jsonUtils from '../utils/json'
import * as helpers from '../helpers' import * as helpers from '../helpers'
import { success } from '../utils/res' import { failure, success } from '../utils/res'
import * as timers from '../utils/timers' import * as timers from '../utils/timers'
import {sendConfirmation} from './confirmations' import {sendConfirmation} from './confirmations'
import * as network from '../network' import * as network from '../network'
@ -288,15 +288,17 @@ export const readMessages = async (req, res) => {
} }
}); });
const chat = await models.Chat.findOne({ where: { id: chat_id } }) const chat = await models.Chat.findOne({ where: { id: chat_id } })
await chat.update({ seen: true }); if(chat) {
await chat.update({ seen: true });
success(res, {}) success(res, {})
sendNotification(chat, '', 'badge')
sendNotification(chat, '', 'badge') socket.sendJson({
socket.sendJson({ type: 'chat_seen',
type: 'chat_seen', response: jsonUtils.chatToJson(chat)
response: jsonUtils.chatToJson(chat) })
}) } else {
failure(res, 'no chat')
}
} }
export const clearMessages = (req, res) => { export const clearMessages = (req, res) => {

Loading…
Cancel
Save