@xuda.io/account_module 1.2.1623 → 1.2.1624

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 +23 -16
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2003,31 +2003,38 @@ export const add_contact = async function (req, job_id, headers) {
2003
2003
  account_profiles: [account_profile_obj._id],
2004
2004
  account_type,
2005
2005
  };
2006
+ if (_.isEmpty(cached_contact)) {
2007
+ if (account_type === 'business' && !is_spam) {
2008
+ const business_info = await ai_module.get_business_info(uid, contact_obj.name, contact_obj.email, account_profile_info);
2009
+ const { business_size, business_category, business_sub_category, business_country, business_bio, business_name } = business_info;
2010
+ contact_obj.mainCategory = business_category;
2011
+ contact_obj.subCategory = business_sub_category;
2012
+ contact_obj.business_size = business_size;
2013
+ contact_obj.country = business_country;
2014
+ contact_obj.bio = business_bio;
2015
+ contact_obj.business_name = business_name;
2016
+
2017
+ if (!contact_obj.name) {
2018
+ contact_obj.name = business_name;
2019
+ }
2020
+ }
2006
2021
 
2007
- if (account_type === 'business' && !is_spam) {
2008
- const business_info = await ai_module.get_business_info(uid, contact_obj.name, contact_obj.email, account_profile_info);
2009
- const { business_size, business_category, business_sub_category, business_country, business_bio, business_name } = business_info;
2010
- contact_obj.mainCategory = business_category;
2022
+ if (account_type === 'personal') {
2023
+ if (!contact_obj.name) {
2024
+ contact_obj.name = await ai_module.get_name_from_email_addr(uid, contact_obj.email, account_profile_info);
2025
+ }
2026
+ }
2027
+ } else {
2028
+ contact_obj.mainCategory = cached_contact.mainCategory;
2011
2029
  contact_obj.subCategory = business_sub_category;
2012
2030
  contact_obj.business_size = business_size;
2013
2031
  contact_obj.country = business_country;
2014
2032
  contact_obj.bio = business_bio;
2015
2033
  contact_obj.business_name = business_name;
2016
-
2017
- if (!contact_obj.name) {
2018
- contact_obj.name = business_name;
2019
- }
2020
2034
  }
2021
-
2022
- if (account_type === 'personal') {
2023
- if (!contact_obj.name) {
2024
- contact_obj.name = await ai_module.get_name_from_email_addr(uid, contact_obj.email, account_profile_info);
2025
- }
2026
- }
2027
-
2028
2035
  const save_ret = await save_contact(uid, contact_obj);
2029
2036
  save_xuda_cache(uid, 'contact', contact_obj.email, null, contact_obj);
2030
- if (!is_spam) {
2037
+ if (!contact_obj.is_spam) {
2031
2038
  set_contact_profile_picture(uid, contact_obj._id, metadata, job_id, headers);
2032
2039
  }
2033
2040
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1623",
3
+ "version": "1.2.1624",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {