@xuda.io/account_module 1.2.5 → 1.2.15
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/index.js +75 -59
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -277,6 +277,9 @@ exports.increment_account_usage = async function (req) {
|
|
|
277
277
|
});
|
|
278
278
|
if (size_ret.code > -1)
|
|
279
279
|
account_data.plugins_drive_size += size_ret.data;
|
|
280
|
+
|
|
281
|
+
// db data
|
|
282
|
+
account_data.project_data_size += 0;
|
|
280
283
|
}
|
|
281
284
|
|
|
282
285
|
const usage_id = await _common.xuda_get_uuid("usage");
|
|
@@ -418,6 +421,7 @@ exports.increment_account_usage = async function (req) {
|
|
|
418
421
|
account_data.workspace_drive_size = 0;
|
|
419
422
|
account_data.plugins_drive_size = 0;
|
|
420
423
|
account_data.builds_drive_size = 0;
|
|
424
|
+
account_data.project_data_size = 0;
|
|
421
425
|
|
|
422
426
|
await run_account_apps(account_data);
|
|
423
427
|
await run_account_drive(account_data);
|
|
@@ -427,75 +431,87 @@ exports.increment_account_usage = async function (req) {
|
|
|
427
431
|
account_data.studio_drive_size +
|
|
428
432
|
account_data.workspace_drive_size +
|
|
429
433
|
account_data.plugins_drive_size +
|
|
430
|
-
account_data.builds_drive_size
|
|
434
|
+
account_data.builds_drive_size +
|
|
435
|
+
account_data.project_data_size;
|
|
431
436
|
await db_module.save_couch_doc("xuda_accounts", account_data);
|
|
432
437
|
}
|
|
433
438
|
};
|
|
434
439
|
|
|
435
440
|
exports.get_account_data = async function (req) {
|
|
436
441
|
var { uid, enforce_usage } = req;
|
|
437
|
-
const get_info = async function () {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
442
|
+
// const get_info = async function () {
|
|
443
|
+
// const get_stripe_subscription = async function (subscription_id) {
|
|
444
|
+
// if (!subscription_id) {
|
|
445
|
+
// return { code: -1, data: "subscription_id missing" };
|
|
446
|
+
// }
|
|
447
|
+
// try {
|
|
448
|
+
// const ret = await stripe.subscriptions.retrieve(subscription_id);
|
|
449
|
+
|
|
450
|
+
// return { code: 1, data: ret };
|
|
451
|
+
// } catch (err) {
|
|
452
|
+
// return { code: -400, data: err };
|
|
453
|
+
// }
|
|
454
|
+
// };
|
|
444
455
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
456
|
+
try {
|
|
457
|
+
const { data: acc_obj } = await db_module.get_couch_doc(
|
|
458
|
+
"xuda_accounts",
|
|
459
|
+
uid
|
|
460
|
+
);
|
|
461
|
+
// const account_obj= account_ret.data
|
|
462
|
+
var ret = { code: 1 };
|
|
463
|
+
ret.data = {
|
|
464
|
+
_id: acc_obj._id,
|
|
465
|
+
account_info: acc_obj.account_info,
|
|
466
|
+
usage: acc_obj.activity_usage,
|
|
467
|
+
plan: acc_obj.plan,
|
|
468
|
+
plan_changed: acc_obj.plan_changed,
|
|
469
|
+
plan_info: acc_obj.plan_info,
|
|
470
|
+
support_plan: acc_obj.support_plan,
|
|
471
|
+
support_plan_changed: acc_obj.support_plan_changed,
|
|
472
|
+
storage_plan: acc_obj.storage_plan,
|
|
473
|
+
storage_plan_changed: acc_obj.storage_plan_changed,
|
|
474
|
+
|
|
475
|
+
prices_info: acc_obj.prices_info,
|
|
476
|
+
activity_usage: acc_obj.activity_usage,
|
|
477
|
+
uid: acc_obj._id,
|
|
478
|
+
stat: acc_obj.stat,
|
|
479
|
+
preferences: acc_obj.preferences || {},
|
|
480
|
+
billing_status: {
|
|
481
|
+
account_suspension_status: acc_obj.account_suspension_status,
|
|
482
|
+
account_suspension_data: acc_obj.account_suspension_data,
|
|
483
|
+
account_billing_hold_status: acc_obj.account_billing_hold_status,
|
|
484
|
+
account_billing_hold_data: acc_obj.account_billing_hold_date,
|
|
485
|
+
account_termination_status: acc_obj.account_termination_status,
|
|
486
|
+
account_termination_data: acc_obj.account_termination_data,
|
|
487
|
+
},
|
|
488
|
+
drive_usage: {
|
|
489
|
+
user_drive_size: acc_obj.user_drive_size || 0,
|
|
490
|
+
studio_drive_size: acc_obj.studio_drive_size || 0,
|
|
491
|
+
workspace_drive_size: acc_obj.workspace_drive_size || 0,
|
|
492
|
+
plugins_drive_size: acc_obj.plugins_drive_size || 0,
|
|
493
|
+
builds_drive_size: acc_obj.builds_drive_size || 0,
|
|
494
|
+
project_data_size: acc_obj.project_data_size || 0,
|
|
495
|
+
total_drive_size: acc_obj.total_drive_size || 0,
|
|
496
|
+
},
|
|
497
|
+
};
|
|
482
498
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
499
|
+
// if (account_ret.data.stripe_membership_subscription_id) {
|
|
500
|
+
// const subscription_ret = await get_stripe_subscription(
|
|
501
|
+
// account_ret.data.stripe_membership_subscription_id
|
|
502
|
+
// );
|
|
487
503
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
};
|
|
504
|
+
// if (subscription_ret.code > 0) {
|
|
505
|
+
// ret.data.stripe_membership_subscription_id = subscription_ret.data.id;
|
|
506
|
+
// }
|
|
507
|
+
// }
|
|
508
|
+
return ret;
|
|
509
|
+
} catch (error) {
|
|
510
|
+
return { code: -1, data: error };
|
|
511
|
+
}
|
|
512
|
+
// };
|
|
497
513
|
|
|
498
|
-
return get_info();
|
|
514
|
+
// return get_info();
|
|
499
515
|
};
|
|
500
516
|
|
|
501
517
|
exports.get_user_projects = async function (req) {
|