Browse Source

changes for push

push-params
Evan Feenstra 5 years ago
parent
commit
47b3c6ee0b
  1. 12
      api/controllers/messages.ts
  2. 7
      api/hub.ts
  3. 12
      dist/api/controllers/messages.js
  4. 2
      dist/api/controllers/messages.js.map
  5. 6
      dist/api/hub.js
  6. 2
      dist/api/hub.js.map

12
api/controllers/messages.ts

@ -274,7 +274,7 @@ export const readMessages = async (req, res) => {
const owner = await models.Contact.findOne({ where: { isOwner: true }})
models.Message.update({ seen: true }, {
await models.Message.update({ seen: true }, {
where: {
sender: {
[Op.ne]: owner.id
@ -282,14 +282,16 @@ export const readMessages = async (req, res) => {
chatId: chat_id
}
});
models.Chat.update({ seen: true }, {
where: {id:chat_id}
});
const chat = await models.Chat.findOne({ where: { id: chat_id } })
chat.update({ seen: true });
success(res, {})
const chat = await models.Chat.findOne({ where: { id: chat_id } })
sendNotification(chat, '', 'badge')
socket.sendJson({
type: 'chat_seen',
response: jsonUtils.chatToJson(chat)
})
}
export const clearMessages = (req, res) => {

7
api/hub.ts

@ -206,11 +206,6 @@ const sendNotification = async (chat, name, type:NotificationType) => {
console.log('[send notification]', { chat_id:chat.id, message })
if (chat.isMuted && type!=='badge') {
console.log('[send notification] skipping. chat is muted.')
return
}
const owner = await models.Contact.findOne({ where: { isOwner: true }})
if (!owner.deviceId) {
@ -220,7 +215,7 @@ const sendNotification = async (chat, name, type:NotificationType) => {
const device_id = owner.deviceId
let unseenMessages=0
if(type!=='badge' && type!=='invite') {
if(!chat.isMuted || type!=='invite') {
unseenMessages = await models.Message.count({ where: { sender: { [Op.ne]: owner.id }, seen: false } })
}

12
dist/api/controllers/messages.js

@ -241,7 +241,7 @@ exports.receiveDeleteMessage = (payload) => __awaiter(void 0, void 0, void 0, fu
exports.readMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const chat_id = req.params.chat_id;
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
models_1.models.Message.update({ seen: true }, {
yield models_1.models.Message.update({ seen: true }, {
where: {
sender: {
[sequelize_1.Op.ne]: owner.id
@ -249,12 +249,14 @@ exports.readMessages = (req, res) => __awaiter(void 0, void 0, void 0, function*
chatId: chat_id
}
});
models_1.models.Chat.update({ seen: true }, {
where: { id: chat_id }
});
res_1.success(res, {});
const chat = yield models_1.models.Chat.findOne({ where: { id: chat_id } });
chat.update({ seen: true });
res_1.success(res, {});
hub_1.sendNotification(chat, '', 'badge');
socket.sendJson({
type: 'chat_seen',
response: jsonUtils.chatToJson(chat)
});
});
exports.clearMessages = (req, res) => {
models_1.models.Message.destroy({ where: {}, truncate: true });

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

File diff suppressed because one or more lines are too long

6
dist/api/hub.js

@ -199,10 +199,6 @@ const sendNotification = (chat, name, type) => __awaiter(void 0, void 0, void 0,
message += ` on ${chat.name}`;
}
console.log('[send notification]', { chat_id: chat.id, message });
if (chat.isMuted && type !== 'badge') {
console.log('[send notification] skipping. chat is muted.');
return;
}
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
if (!owner.deviceId) {
console.log('[send notification] skipping. owner.deviceId not set.');
@ -210,7 +206,7 @@ const sendNotification = (chat, name, type) => __awaiter(void 0, void 0, void 0,
}
const device_id = owner.deviceId;
let unseenMessages = 0;
if (type !== 'badge' && type !== 'invite') {
if (!chat.isMuted || type !== 'invite') {
unseenMessages = yield models_1.models.Message.count({ where: { sender: { [sequelize_1.Op.ne]: owner.id }, seen: false } });
}
const params = { device_id };

2
dist/api/hub.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save