@xuda.io/account_module 1.2.749 → 1.2.750

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 +35 -14
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -8,7 +8,28 @@ import { countryCodeEmoji } from 'country-code-emoji';
8
8
  // Convert exec to a promise for cleaner async/await usage
9
9
  // const execAsync = util.promisify(exec);
10
10
 
11
- const account_info_properties = ['account_type', 'business_name', 'bio', 'tel', 'address', 'city', 'state', 'zip', 'country', 'email', 'first_name', 'last_name', 'mainCategory', 'subCategory', 'profile_picture', 'username', 'website', 'auto_respond', 'auto_respond_mode', 'auto_respond_agents'];
11
+ const account_info_properties = [
12
+ 'account_type',
13
+ 'business_name',
14
+ 'bio',
15
+ 'phone_number',
16
+ 'address',
17
+ 'city',
18
+ 'state',
19
+ 'zip',
20
+ 'country',
21
+ 'email',
22
+ 'first_name',
23
+ 'last_name',
24
+ 'mainCategory',
25
+ 'subCategory',
26
+ 'profile_picture',
27
+ 'username',
28
+ 'website',
29
+ 'auto_respond',
30
+ 'auto_respond_mode',
31
+ 'auto_respond_agents',
32
+ ];
12
33
 
13
34
  global._conf = (
14
35
  await import(path.join(process.env.XUDA_HOME, process.env.XUDA_CONFIG), {
@@ -84,7 +105,7 @@ export const update_account_info = async function (req, job_id, headers) {
84
105
 
85
106
  if (account_obj.account_info.account_type === 'business') {
86
107
  if (key === 'business_name' && validate_input(val, 150, true, false) < 0) {
87
- error[key] = 'Invalid company';
108
+ error[key] = 'Invalid business_name';
88
109
  }
89
110
  }
90
111
  if (key === 'first_name' && !validate_input(val, 35, true, false)) {
@@ -98,8 +119,8 @@ export const update_account_info = async function (req, job_id, headers) {
98
119
  if (key === 'email' && (!validator.isEmail(val) || !val || val.length < 2)) {
99
120
  error[key] = 'Invalid email';
100
121
  }
101
- // if (key === 'tel' && (!/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/.test(val) || !val || val.length < 2)) {
102
- // // if (key === "tel" && (!preg_match("/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/", $val) || !$val || count($val) < 2)) {
122
+ // if (key === 'phone_number' && (!/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/.test(val) || !val || val.length < 2)) {
123
+ // // if (key === "phone_number" && (!preg_match("/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/", $val) || !$val || count($val) < 2)) {
103
124
  // error[key] = 'Invalid phone number';
104
125
  // }
105
126
  if (key === 'address' && !/^[a-z0-9- ]+$/i.test(val)) {
@@ -554,7 +575,7 @@ export const get_account_name = async function (req) {
554
575
  first_name: '',
555
576
  last_name: '',
556
577
  email: '',
557
- phone: '',
578
+ phone_number: '',
558
579
  profile_picture: '',
559
580
  username: '',
560
581
  membership_plan,
@@ -563,14 +584,14 @@ export const get_account_name = async function (req) {
563
584
  date_created_ts,
564
585
  };
565
586
  if (data.data.account_info) {
566
- const { first_name, last_name, email, tel: phone, profile_picture, profile_avatar, username, website, country, bio, industry, account_type, address, city, state, zip, business_name, auto_respond, auto_respond_mode, auto_respond_agents } = data.data.account_info;
587
+ const { first_name, last_name, email, phone_number, profile_picture, profile_avatar, username, website, country, bio, industry, account_type, address, city, state, zip, business_name, auto_respond, auto_respond_mode, auto_respond_agents } = data.data.account_info;
567
588
 
568
589
  obj = {
569
590
  _id: data.data._id,
570
591
  first_name,
571
592
  last_name,
572
593
  email,
573
- phone,
594
+ phone_number,
574
595
  profile_picture,
575
596
  profile_avatar,
576
597
  username,
@@ -873,7 +894,7 @@ export const search_users = async function (req) {
873
894
  },
874
895
  },
875
896
  {
876
- 'account_info.tel': {
897
+ 'account_info.phone_number': {
877
898
  $regex: `(?i)${search}`,
878
899
  },
879
900
  },
@@ -898,7 +919,7 @@ export const search_users = async function (req) {
898
919
 
899
920
  const opt = {
900
921
  selector,
901
- fields: ['_id', 'account_info.first_name', 'account_info.last_name', 'account_info.username', 'account_info.profile_avatar', 'account_info.profile_picture', 'socket_id', 'account_info.country', 'account_info.bio', 'account_info.company'],
922
+ fields: ['_id', 'account_info.first_name', 'account_info.last_name', 'account_info.username', 'account_info.profile_avatar', 'account_info.profile_picture', 'socket_id', 'account_info.country', 'account_info.bio', 'account_info.business_name'],
902
923
  limit: limit ? limit : 99999,
903
924
  };
904
925
 
@@ -1324,12 +1345,12 @@ export const get_contact_info = async function (uid, contact_doc, _id) {
1324
1345
  //membership_plan
1325
1346
  doc.name = `${account_info_ret.data.first_name} ${account_info_ret.data.last_name}`;
1326
1347
 
1327
- if (account_info_ret.data.phone) {
1348
+ if (account_info_ret.data.phone_number) {
1328
1349
  try {
1329
- doc.telephone = formatPhoneWithFlag(account_info_ret.data.phone, account_info_ret.data.country);
1350
+ doc.phone_number = formatPhoneWithFlag(account_info_ret.data.phone_number, account_info_ret.data.country);
1330
1351
  } catch (err) {
1331
1352
  console.error(err);
1332
- doc.telephone = account_info_ret.data.phone;
1353
+ doc.phone_number = account_info_ret.data.phone_number;
1333
1354
  }
1334
1355
  }
1335
1356
 
@@ -1345,7 +1366,7 @@ export const get_contact_info = async function (uid, contact_doc, _id) {
1345
1366
 
1346
1367
  doc.icon_pattern = await get_contact_pattern(doc);
1347
1368
  doc.username = account_info_ret.data.username;
1348
- doc.company = account_info_ret.data.business_name;
1369
+ doc.business_name = account_info_ret.data.business_name;
1349
1370
  doc.address = account_info_ret.data.address;
1350
1371
  doc.city = account_info_ret.data.city;
1351
1372
  doc.state = account_info_ret.data.state;
@@ -2073,7 +2094,7 @@ export const update_contacts_with_account_changes = async function (uid, changes
2073
2094
  export const get_user_card = async function (uid, uid_query) {
2074
2095
  if (uid === uid_query) return await get_user_contact(uid, uid_query);
2075
2096
 
2076
- let user_contact_obj; // = { border, card_background, contact_uid, date_created, docType, icon_pattern, name, company, profile_avatar, connection_stat, username, bio, notifications, email, phone };
2097
+ let user_contact_obj; // = { border, card_background, contact_uid, date_created, docType, icon_pattern, name, business_name, profile_avatar, connection_stat, username, bio, notifications, email, phone_number };
2077
2098
 
2078
2099
  const contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [uid, uid_query] });
2079
2100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.749",
3
+ "version": "1.2.750",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {