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