Browse Source

notify: check android, fix sound logic

push-params
Evan Feenstra 5 years ago
parent
commit
a7732f4583
  1. 11
      api/hub.ts
  2. 13
      dist/api/hub.js
  3. 2
      dist/api/hub.js.map

11
api/hub.ts

@ -213,19 +213,22 @@ const sendNotification = async (chat, name, type:NotificationType) => {
return return
} }
const device_id = owner.deviceId const device_id = owner.deviceId
const isIOS = device_id.length===64
const isAndroid = !isIOS
let unseenMessages=await models.Message.count({ where: { sender: { [Op.ne]: owner.id }, seen: false } }) let unseenMessages=await models.Message.count({ where: { sender: { [Op.ne]: owner.id }, seen: false } })
const params:{[k:string]:any} = {device_id} const params:{[k:string]:any} = {device_id}
const notification:{[k:string]:any} = { const notification:{[k:string]:any} = {
chat_id: chat.id, chat_id: chat.id,
badge: unseenMessages badge: unseenMessages,
sound: ''
} }
if(type!=='badge' && !chat.isMuted) { if(type!=='badge' && !chat.isMuted) {
notification.message = message notification.message = message
if(owner.notificationSound) { notification.sound = owner.notificationSound || 'default'
notification.sound = owner.notificationSound } else {
} if(isAndroid) return // skip on Android if no actual message
} }
params.notification = notification params.notification = notification

13
dist/api/hub.js

@ -205,17 +205,22 @@ const sendNotification = (chat, name, type) => __awaiter(void 0, void 0, void 0,
return; return;
} }
const device_id = owner.deviceId; const device_id = owner.deviceId;
const isIOS = device_id.length === 64;
const isAndroid = !isIOS;
let unseenMessages = yield models_1.models.Message.count({ where: { sender: { [sequelize_1.Op.ne]: owner.id }, seen: false } }); let unseenMessages = yield models_1.models.Message.count({ where: { sender: { [sequelize_1.Op.ne]: owner.id }, seen: false } });
const params = { device_id }; const params = { device_id };
const notification = { const notification = {
chat_id: chat.id, chat_id: chat.id,
badge: unseenMessages badge: unseenMessages,
sound: ''
}; };
if (type !== 'badge' && !chat.isMuted) { if (type !== 'badge' && !chat.isMuted) {
notification.message = message; notification.message = message;
if (owner.notificationSound) { notification.sound = owner.notificationSound || 'default';
notification.sound = owner.notificationSound; }
} else {
if (isAndroid)
return; // skip on Android if no actual message
} }
params.notification = notification; params.notification = notification;
if (type === 'message' && chat.type == constants.chat_types.tribe) { if (type === 'message' && chat.type == constants.chat_types.tribe) {

2
dist/api/hub.js.map

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