@xuda.io/account_module 1.2.2250 → 1.2.2252

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.
Files changed (2) hide show
  1. package/index.mjs +24 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1719,7 +1719,7 @@ export const validate_account_topup = async function (uid, items = []) {
1719
1719
  }
1720
1720
 
1721
1721
  if (data?.balance?.past_due) {
1722
- let err = new Error(`past due ${data.balance.past_due / 100}`);
1722
+ let err = new Error(`past due ${data.balance.past_due}`);
1723
1723
  err.code = -91;
1724
1724
  err.billing_problem = true;
1725
1725
  err.topup = topup + data.balance.past_due;
@@ -1752,9 +1752,32 @@ export const validate_account_topup = async function (uid, items = []) {
1752
1752
  throw err;
1753
1753
  }
1754
1754
 
1755
+ await release_account_billing_hold_if_current(uid);
1756
+
1755
1757
  return true;
1756
1758
  };
1757
1759
 
1760
+ const release_account_billing_hold_if_current = async function (uid) {
1761
+ const account_ret = await db_module.get_couch_doc('xuda_accounts', uid);
1762
+ if (account_ret.code < 0 || !account_ret.data?.account_billing_hold_status) {
1763
+ return;
1764
+ }
1765
+
1766
+ const account_obj = account_ret.data;
1767
+ account_obj.account_billing_hold_status = 0;
1768
+ account_obj.account_billing_hold_date = Date.now();
1769
+ await db_module.save_couch_doc('xuda_accounts', account_obj);
1770
+
1771
+ ws_dashboard_msa.emit_message_to_dashboard({
1772
+ service: 'account_billing_hold_released',
1773
+ to: [uid],
1774
+ data: {
1775
+ account_billing_hold_status: 0,
1776
+ account_billing_hold_date: account_obj.account_billing_hold_date,
1777
+ },
1778
+ });
1779
+ };
1780
+
1758
1781
  const get_prices = function (uid, item) {
1759
1782
  let price;
1760
1783
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.2250",
3
+ "version": "1.2.2252",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {