-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression: Fix email notification preference not showing correct sel…
…ected value (#10847) * Fix email notification preference not showing correct selected value Closes #10844 * Save email notification preferences correctly Closes #10787 * Create room with user notification preferences * Add back the uploaded file message on push notifications
- Loading branch information
1 parent
888e2d9
commit e1ef24b
Showing
9 changed files
with
103 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
RocketChat.getDefaultSubscriptionPref = function _getDefaultSubscriptionPref(userPref) { | ||
const subscription = {}; | ||
|
||
const { | ||
desktopNotifications, | ||
mobileNotifications, | ||
emailNotificationMode, | ||
highlights | ||
} = (userPref.settings && userPref.settings.preferences) || {}; | ||
|
||
if (Array.isArray(highlights) && highlights.length) { | ||
subscription.userHighlights = highlights; | ||
} | ||
|
||
if (desktopNotifications && desktopNotifications !== 'default') { | ||
subscription.desktopNotifications = desktopNotifications; | ||
subscription.desktopPrefOrigin = 'user'; | ||
} | ||
|
||
if (mobileNotifications && mobileNotifications !== 'default') { | ||
subscription.mobilePushNotifications = mobileNotifications; | ||
subscription.mobilePrefOrigin = 'user'; | ||
} | ||
|
||
if (emailNotificationMode && emailNotificationMode !== 'default') { | ||
subscription.emailNotifications = emailNotificationMode; | ||
subscription.emailPrefOrigin = 'user'; | ||
} | ||
|
||
return subscription; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
RocketChat.Migrations.add({ | ||
version: 121, | ||
up() { | ||
|
||
// set user preferences on subscriptions | ||
RocketChat.models.Users.find({ | ||
$or: [ | ||
{ 'settings.preferences.desktopNotifications': { $exists: true } }, | ||
{ 'settings.preferences.mobileNotifications': { $exists: true } }, | ||
{ 'settings.preferences.emailNotificationMode': { $exists: true } } | ||
] | ||
}).forEach(user => { | ||
if (user.settings.preferences.desktopNotifications && user.settings.preferences.desktopNotifications !== 'default') { | ||
RocketChat.models.Subscriptions.update({ | ||
'u._id': user._id, | ||
desktopPrefOrigin: { $exists: false } | ||
}, { | ||
$set: { | ||
desktopNotifications: user.settings.preferences.desktopNotifications, | ||
desktopPrefOrigin: 'user' | ||
} | ||
}, { | ||
multi: true | ||
}); | ||
} | ||
|
||
if (user.settings.preferences.mobileNotifications && user.settings.preferences.mobileNotifications !== 'default') { | ||
RocketChat.models.Subscriptions.update({ | ||
'u._id': user._id, | ||
mobilePrefOrigin: { $exists: false } | ||
}, { | ||
$set: { | ||
mobileNotifications: user.settings.preferences.mobileNotifications, | ||
mobilePrefOrigin: 'user' | ||
} | ||
}, { | ||
multi: true | ||
}); | ||
} | ||
|
||
if (user.settings.preferences.emailNotificationMode && user.settings.preferences.emailNotificationMode !== 'default') { | ||
RocketChat.models.Subscriptions.update({ | ||
'u._id': user._id, | ||
emailPrefOrigin: { $exists: false } | ||
}, { | ||
$set: { | ||
emailNotifications: user.settings.preferences.emailNotificationMode === 'disabled' || user.settings.preferences.emailNotificationMode === 'nothing' ? 'nothing' : 'mentions', | ||
emailPrefOrigin: 'user' | ||
} | ||
}, { | ||
multi: true | ||
}); | ||
} | ||
}); | ||
} | ||
}); |