[BREAK] Stop sending audio notifications via stream (#23108)
parent
f7cce00d77
commit
6ab8225078
@ -1,49 +0,0 @@ |
||||
import { metrics } from '../../../../metrics'; |
||||
import { settings } from '../../../../settings'; |
||||
import { Notifications } from '../../../../notifications'; |
||||
|
||||
export function shouldNotifyAudio({ |
||||
disableAllMessageNotifications, |
||||
status, |
||||
statusConnection, |
||||
audioNotifications, |
||||
hasMentionToAll, |
||||
hasMentionToHere, |
||||
isHighlighted, |
||||
hasMentionToUser, |
||||
hasReplyToThread, |
||||
roomType, |
||||
isThread, |
||||
}) { |
||||
if (disableAllMessageNotifications && audioNotifications == null && !isHighlighted && !hasMentionToUser && !hasReplyToThread) { |
||||
return false; |
||||
} |
||||
|
||||
if (statusConnection === 'offline' || status === 'busy' || audioNotifications === 'nothing') { |
||||
return false; |
||||
} |
||||
|
||||
if (!audioNotifications) { |
||||
if (settings.get('Accounts_Default_User_Preferences_audioNotifications') === 'all' && (!isThread || hasReplyToThread)) { |
||||
return true; |
||||
} |
||||
if (settings.get('Accounts_Default_User_Preferences_audioNotifications') === 'nothing') { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return (roomType === 'd' || (!disableAllMessageNotifications && (hasMentionToAll || hasMentionToHere)) || isHighlighted || audioNotifications === 'all' || hasMentionToUser) && (!isThread || hasReplyToThread); |
||||
} |
||||
|
||||
export function notifyAudioUser(userId, message, room) { |
||||
metrics.notificationsSent.inc({ notification_type: 'audio' }); |
||||
Notifications.notifyUser(userId, 'audioNotification', { |
||||
payload: { |
||||
_id: message._id, |
||||
rid: message.rid, |
||||
sender: message.u, |
||||
type: room.t, |
||||
name: room.name, |
||||
}, |
||||
}); |
||||
} |
@ -0,0 +1,34 @@ |
||||
import { Migrations } from '../../../app/migrations/server'; |
||||
import { Settings, Subscriptions, Users } from '../../../app/models/server'; |
||||
|
||||
Migrations.add({ |
||||
version: 235, |
||||
up() { |
||||
Settings.removeById('Accounts_Default_User_Preferences_audioNotifications'); |
||||
|
||||
// delete field from subscriptions
|
||||
Subscriptions.update({ |
||||
audioNotifications: { |
||||
$exists: true, |
||||
}, |
||||
}, { |
||||
$unset: { |
||||
audioNotifications: 1, |
||||
audioPrefOrigin: 1, |
||||
}, |
||||
}, { multi: true }); |
||||
|
||||
Subscriptions.tryDropIndex({ audioNotifications: 1 }); |
||||
|
||||
// delete field from users
|
||||
Users.update({ |
||||
'settings.preferences.audioNotifications': { |
||||
$exists: true, |
||||
}, |
||||
}, { |
||||
$unset: { |
||||
'settings.preferences.audioNotifications': 1, |
||||
}, |
||||
}, { multi: true }); |
||||
}, |
||||
}); |
Loading…
Reference in new issue