mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
add ability to unsubscribe from a single event using a dedicated link
This commit is contained in:
@@ -99,6 +99,7 @@
|
||||
"remindersToLogin": "Reminders to check in to HabitRPG",
|
||||
"unsubscribeAllEmails": "Check to Unsubscribe from Emails",
|
||||
"unsubscribeAllEmailsText": "By checking this box, I certify that I understand that by unsubscribing from all emails, HabitRPG will never be able to notify me via email about important changes to the site or my account.",
|
||||
"correctlyUnsubscribedEmailType": "Correctly unsubscribed from \"<%= emailType %>\" emails.",
|
||||
"subscriptionRateText": "Recurring $<%= price %> every <%= months %> months",
|
||||
"benefits": "Benefits",
|
||||
"coupon": "Coupon",
|
||||
|
||||
@@ -15,6 +15,27 @@ habitrpg.controller('SettingsCtrl',
|
||||
// });
|
||||
// }
|
||||
|
||||
// A simple object to map the key stored in the db (user.preferences.emailNotification[key])
|
||||
// to its string but ONLY when the preferences' key and the string key don't match
|
||||
var mapPrefToEmailString = {
|
||||
'importantAnnouncements': 'inactivityEmails'
|
||||
};
|
||||
|
||||
// If ?unsubFrom param is passed with valid email type,
|
||||
// automatically unsubscribe users from that email and
|
||||
// show an alert
|
||||
$timeout(function(){
|
||||
var unsubFrom = $location.search().unsubFrom;
|
||||
if(unsubFrom){
|
||||
var emailPrefKey = 'preferences.emailNotifications.' + qs.unsubFrom;
|
||||
var emailTypeString = env.t(mapPrefToEmailString[qs.unsubFrom] || qs.unsubFrom);
|
||||
User.set({emailPrefKey: false});
|
||||
User.user.preferences.emailNotifications[qs.unsubFrom] = false;
|
||||
Notification.text(env.t('correctlyUnsubscribedEmailType', {emailType: emailTypeString}));
|
||||
$location.search({});
|
||||
}
|
||||
}, 500);
|
||||
|
||||
$scope.hideHeader = function(){
|
||||
User.set({"preferences.hideHeader":!User.user.preferences.hideHeader})
|
||||
if (User.user.preferences.hideHeader && User.user.preferences.stickyHeader){
|
||||
|
||||
@@ -56,8 +56,7 @@ module.exports.getUserInfo = getUserInfo;
|
||||
module.exports.txnEmail = function(mailingInfoArray, emailType, variables){
|
||||
var mailingInfoArray = Array.isArray(mailingInfoArray) ? mailingInfoArray : [mailingInfoArray];
|
||||
var variables = [
|
||||
{name: 'BASE_URL', content: baseUrl},
|
||||
{name: 'EMAIL_SETTINGS_URL', content: baseUrl + '/#/options/settings/notifications'}
|
||||
{name: 'BASE_URL', content: baseUrl}
|
||||
].concat(variables || []);
|
||||
|
||||
// It's important to pass at least a user with its `preferences` as we need to check if he unsubscribed
|
||||
|
||||
Reference in New Issue
Block a user