Browse Source

notify: check android, fix sound logic

push-params
Evan Feenstra 5 years ago
parent
commit
a7732f4583
  1. 11
      api/hub.ts
  2. 11
      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
}
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 } })
const params:{[k:string]:any} = {device_id}
const notification:{[k:string]:any} = {
chat_id: chat.id,
badge: unseenMessages
badge: unseenMessages,
sound: ''
}
if(type!=='badge' && !chat.isMuted) {
notification.message = message
if(owner.notificationSound) {
notification.sound = owner.notificationSound
}
notification.sound = owner.notificationSound || 'default'
} else {
if(isAndroid) return // skip on Android if no actual message
}
params.notification = notification

11
dist/api/hub.js

@ -205,17 +205,22 @@ const sendNotification = (chat, name, type) => __awaiter(void 0, void 0, void 0,
return;
}
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 } });
const params = { device_id };
const notification = {
chat_id: chat.id,
badge: unseenMessages
badge: unseenMessages,
sound: ''
};
if (type !== 'badge' && !chat.isMuted) {
notification.message = message;
if (owner.notificationSound) {
notification.sound = owner.notificationSound;
notification.sound = owner.notificationSound || 'default';
}
else {
if (isAndroid)
return; // skip on Android if no actual message
}
params.notification = notification;
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