|
@ -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 } }) |
|
|
|
|
|
if(chat) { |
|
|
await chat.update({ seen: true }); |
|
|
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) => { |
|
|