Skip to content

Commit

Permalink
VPN-2452 Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jps-moz committed Dec 20, 2022
1 parent 2c26d86 commit d68600c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/message_subscription_expiring/contactSupportLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
((api) => {
api.urlOpener.openLink(api.urlOpener.LinkHelpSupport);
});
11 changes: 11 additions & 0 deletions addons/message_subscription_expiring/isExpiring.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(function(api, condition) {
//Show message only if within 1 week of expiring.
let weekBeforeExpireSecs = (api.subscriptionData.expiresOn / 1000) - 7*24*60*60;
if (Date.now() < api.subscriptionData.expiresOn &&
Date.now() > weekBeforeExpireSecs*1000) {
api.addon.date = weekBeforeExpireSecs;
condition.enable();
} else {
condition.disable();
}
})
3 changes: 3 additions & 0 deletions addons/message_subscription_expiring/manageAccountLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
((api) => {
api.urlOpener.openLink(api.urlOpener.LinkAccount);
});
36 changes: 36 additions & 0 deletions addons/message_subscription_expiring/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"api_version": "0.1",
"id": "message_subscription_expiring",
"name": "Subscription expiring message",
"type": "message",
"conditions": {
"javascript": "isExpiring.js"
},
"message": {
"id": "message_subscription_expiring",
"title": "Your subscription is ending soon",
"subtitle": "Your Mozilla VPN subscription will end in one week. After that, you’ll no longer be able to use Mozilla VPN.",
"badge": "warning",
"blocks": [
{
"id": "c_1",
"type": "text",
"content": "Don’t lose your subscription — please go to your account page to renew your access to Mozilla VPN. If you’re having any issues, please contact support to get help."
},
{
"id": "c_2",
"type": "button",
"style": "primary",
"content": "Manage account",
"javascript": "manageAccountLink.js"
},
{
"id": "c_3",
"type": "button",
"style": "link",
"content": "Contact support",
"javascript": "contactSupportLink.js"
}
]
}
}

0 comments on commit d68600c

Please sign in to comment.