backend-manager 5.0.168 → 5.0.170
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TODO-2.md +21 -0
- package/package.json +1 -1
- package/src/manager/cron/daily/ghostii-auto-publisher.js +1 -1
- package/src/manager/cron/frequent/abandoned-carts.js +2 -2
- package/src/manager/helpers/middleware.js +3 -1
- package/src/manager/helpers/usage.js +3 -2
- package/src/manager/routes/payments/dispute-alert/post.js +3 -3
package/TODO-2.md
CHANGED
|
@@ -10,6 +10,27 @@ payments/reactivate
|
|
|
10
10
|
payments/upgrade
|
|
11
11
|
* takes a subscription id and a new plan id and upgrades the user's subscription to the new plan. this can only be done if the user has an active subscription.
|
|
12
12
|
|
|
13
|
+
-------
|
|
14
|
+
UPSELL
|
|
15
|
+
* products in BEM can have an UPSELL where you link another product ID and it allows you to add it to your cart OR shows you after checkout?
|
|
16
|
+
|
|
17
|
+
-------
|
|
18
|
+
USER OBJECT UPDGRADE --> INSTANCE?
|
|
19
|
+
|
|
20
|
+
const User = require('backend-manager/src/manager/helpers/user');
|
|
21
|
+
+
|
|
22
|
+
User.resolveSubscription(self.request.user);
|
|
23
|
+
-->
|
|
24
|
+
one object that cna do resolveSubscription(), getAccount(), etc
|
|
25
|
+
|
|
26
|
+
since you changed some things, do all tests in all projects align still?
|
|
27
|
+
|
|
28
|
+
after that, udpate README, CLAUDE.md and ANY TOPLEVLE CLAUDE SKILLS so that we never make this mistake again
|
|
29
|
+
|
|
30
|
+
including
|
|
31
|
+
|
|
32
|
+
---------
|
|
33
|
+
|
|
13
34
|
TEST NEWSLETTER
|
|
14
35
|
POST /admin/cron { id: 'daily/marketing-newsletter-generate' }
|
|
15
36
|
|
package/package.json
CHANGED
|
@@ -235,7 +235,7 @@ function uploadPost(assistant, settings, article) {
|
|
|
235
235
|
author: settings.author,
|
|
236
236
|
categories: article.categories,
|
|
237
237
|
tags: article.keywords,
|
|
238
|
-
|
|
238
|
+
postPath: 'ghostii',
|
|
239
239
|
githubUser: settings.brand.github.user,
|
|
240
240
|
githubRepo: settings.brand.github.repo,
|
|
241
241
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const powertools = require('node-powertools');
|
|
2
2
|
const { REMINDER_DELAYS, COLLECTION } = require('../../libraries/abandoned-cart-config.js');
|
|
3
|
+
const User = require('../../helpers/user.js');
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Abandoned cart reminder cron job
|
|
@@ -49,8 +50,7 @@ module.exports = async ({ Manager, assistant, context, libraries }) => {
|
|
|
49
50
|
const userDoc = userSnap.data();
|
|
50
51
|
|
|
51
52
|
// Belt-and-suspenders: skip if user already has active paid subscription
|
|
52
|
-
if (userDoc.
|
|
53
|
-
&& userDoc.subscription?.product?.id !== 'basic') {
|
|
53
|
+
if (User.resolveSubscription(userDoc).active) {
|
|
54
54
|
assistant.log(`User ${uid} now has active subscription, marking cart completed`);
|
|
55
55
|
await markCompleted(doc, admin, nowUNIX);
|
|
56
56
|
skipped++;
|
|
@@ -7,6 +7,7 @@ const path = require('path');
|
|
|
7
7
|
const powertools = require('node-powertools');
|
|
8
8
|
const { merge } = require('lodash');
|
|
9
9
|
const JSON5 = require('json5');
|
|
10
|
+
const User = require('./user.js');
|
|
10
11
|
|
|
11
12
|
function Middleware(m, req, res) {
|
|
12
13
|
const self = this;
|
|
@@ -126,7 +127,8 @@ Middleware.prototype.run = function (libPath, options) {
|
|
|
126
127
|
|
|
127
128
|
// Log working user
|
|
128
129
|
const workingUser = assistant.getUser();
|
|
129
|
-
|
|
130
|
+
const resolvedSub = User.resolveSubscription(workingUser);
|
|
131
|
+
assistant.log(`Middleware.process(): User (${workingUser.auth.uid}, ${workingUser.auth.email}, ${workingUser.subscription.product.id}=${workingUser.subscription.status} (resolved: ${resolvedSub.plan})):`, safeStringify(workingUser));
|
|
130
132
|
|
|
131
133
|
// Setup analytics
|
|
132
134
|
if (options.setupAnalytics) {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const moment = require('moment');
|
|
9
9
|
const _ = require('lodash');
|
|
10
10
|
const hcaptcha = require('hcaptcha');
|
|
11
|
+
const User = require('./user.js');
|
|
11
12
|
|
|
12
13
|
function Usage(m) {
|
|
13
14
|
const self = this;
|
|
@@ -319,8 +320,8 @@ Usage.prototype.getProduct = function (id) {
|
|
|
319
320
|
|
|
320
321
|
const products = Manager.config.payment?.products || [];
|
|
321
322
|
|
|
322
|
-
// Look up by provided ID, or fall back to user's
|
|
323
|
-
id = id || self.user.
|
|
323
|
+
// Look up by provided ID, or fall back to user's resolved plan
|
|
324
|
+
id = id || User.resolveSubscription(self.user).plan;
|
|
324
325
|
|
|
325
326
|
return products.find(p => p.id === id)
|
|
326
327
|
|| products.find(p => p.id === 'basic')
|
|
@@ -2,12 +2,12 @@ const path = require('path');
|
|
|
2
2
|
const powertools = require('node-powertools');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* POST /payments/dispute-alert?
|
|
5
|
+
* POST /payments/dispute-alert?provider=chargeblast&key=XXX
|
|
6
6
|
* Receives dispute alert webhooks (e.g., from Chargeblast), validates them,
|
|
7
7
|
* and saves to Firestore for async processing via onWrite trigger
|
|
8
8
|
*
|
|
9
9
|
* Query params:
|
|
10
|
-
* -
|
|
10
|
+
* - provider: alert provider name (default: 'chargeblast')
|
|
11
11
|
* - key: must match BACKEND_MANAGER_KEY
|
|
12
12
|
*/
|
|
13
13
|
module.exports = async ({ assistant, Manager, libraries }) => {
|
|
@@ -22,7 +22,7 @@ module.exports = async ({ assistant, Manager, libraries }) => {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Determine alert provider (default: chargeblast)
|
|
25
|
-
const provider = query.
|
|
25
|
+
const provider = query.provider || 'chargeblast';
|
|
26
26
|
|
|
27
27
|
// Load the processor module
|
|
28
28
|
let processorModule;
|