mirror of
https://github.com/pockethost/pockethost.git
synced 2025-11-23 22:15:49 +00:00
fix(pockethost): only unsubscribe if quantity is 0 and currently premium subscriber
This commit is contained in:
parent
7d442912c1
commit
82dbfb4d02
@ -679,9 +679,14 @@ const HandleLemonSqueezySale = (c) => {
|
||||
audit(`LS`, `Signup processed.`, context);
|
||||
};
|
||||
const signup_canceller = () => {
|
||||
userRec.set(`subscription`, `free`);
|
||||
userRec.set(`subscription_quantity`, 0);
|
||||
userRec.set(`subscription_interval`, ``);
|
||||
if (userRec.get(`subscription`) !== `premium`) return;
|
||||
const currentQuantity = userRec.get(`subscription_quantity`);
|
||||
const newQuantity = Math.max(currentQuantity - (context.quantity || 1), 0);
|
||||
userRec.set(`subscription_quantity`, newQuantity);
|
||||
if (newQuantity === 0) {
|
||||
userRec.set(`subscription`, `free`);
|
||||
userRec.set(`subscription_interval`, ``);
|
||||
}
|
||||
dao.saveRecord(userRec);
|
||||
log(`saved user`);
|
||||
audit(`LS`, `Signup cancelled.`, context);
|
||||
|
||||
@ -9,9 +9,6 @@ routerAdd("POST", "/api/instance", (c) => {
|
||||
routerAdd("DELETE", "/api/instance/:id", (c) => {
|
||||
return require(`${__hooks}/mothership`).HandleInstanceDelete(c);
|
||||
}, $apis.requireRecordAuth());
|
||||
routerAdd("POST", "/api/instance/:id/webhook/test", (c) => {
|
||||
return require(`${__hooks}/mothership`).HandleInstanceWebhookTest(c);
|
||||
}, $apis.requireRecordAuth());
|
||||
routerAdd("GET", "/api/instance/resolve", (c) => {
|
||||
return require(`${__hooks}/mothership`).HandleInstanceResolve(c);
|
||||
}, $apis.requireAdminAuth());
|
||||
|
||||
@ -265,9 +265,17 @@ export const HandleLemonSqueezySale = (c: echo.Context) => {
|
||||
}
|
||||
|
||||
const signup_canceller = () => {
|
||||
userRec.set(`subscription`, `free`)
|
||||
userRec.set(`subscription_quantity`, 0)
|
||||
userRec.set(`subscription_interval`, ``)
|
||||
if (userRec.get(`subscription`) !== `premium`) {
|
||||
return
|
||||
}
|
||||
const currentQuantity = userRec.get(`subscription_quantity`)
|
||||
const newQuantity = Math.max(currentQuantity - (context.quantity || 1), 0)
|
||||
userRec.set(`subscription_quantity`, newQuantity)
|
||||
|
||||
if (newQuantity === 0) {
|
||||
userRec.set(`subscription`, `free`)
|
||||
userRec.set(`subscription_interval`, ``)
|
||||
}
|
||||
dao.saveRecord(userRec)
|
||||
log(`saved user`)
|
||||
audit(`LS`, `Signup cancelled.`, context)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user