@xuda.io/account_module 1.2.1703 → 1.2.1705

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 -11
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2094,6 +2094,11 @@ export const add_contact = async function (req, job_id, headers) {
2094
2094
  } else {
2095
2095
  // contact without use account
2096
2096
  cached_contact = await get_xuda_cache(uid, 'contact', email, 'metadata');
2097
+ if (_.isEmpty(cached_contact) && account_type === 'business') {
2098
+ const domain = email.includes('@') ? email.split('@')[1] : '';
2099
+ cached_contact = await get_xuda_cache(uid, 'contact', domain, 'metadata');
2100
+ }
2101
+
2097
2102
  if (_.isEmpty(cached_contact)) {
2098
2103
  if (metadata.subject && !metadata.is_sent) {
2099
2104
  is_spam = await ai_module.is_spam_email(uid, email, metadata.subject, account_profile_info);
@@ -2126,9 +2131,13 @@ export const add_contact = async function (req, job_id, headers) {
2126
2131
  account_profiles: [account_profile_obj._id],
2127
2132
  account_type: cached_contact?.account_type || account_type,
2128
2133
  };
2129
- if (_.isEmpty(cached_contact)) {
2134
+ if (!_.isEmpty(cached_contact?.business_info)) {
2135
+ contact_obj.business_info = _.cloneDeep(cached_contact.business_info);
2136
+ } else {
2130
2137
  if (account_type === 'business' && !is_spam) {
2131
2138
  contact_obj.business_info = await ai_module.get_business_info(uid, contact_obj.name, contact_obj.email, account_profile_info);
2139
+ save_xuda_cache(uid, 'contact', contact_obj.domain, null, contact_obj);
2140
+
2132
2141
  // const business_info = await ai_module.get_business_info(uid, contact_obj.name, contact_obj.email, account_profile_info);
2133
2142
  // if (business_info) {
2134
2143
  // const { business_size, business_category, business_sub_category, business_country, business_bio, business_name } = business_info;
@@ -2154,19 +2163,23 @@ export const add_contact = async function (req, job_id, headers) {
2154
2163
  contact_obj.name = await ai_module.get_name_from_email_addr(uid, contact_obj.email, account_profile_info);
2155
2164
  }
2156
2165
  }
2157
- } else {
2158
- // get from cache
2159
- contact_obj.business_info = _.cloneDeep(cached_contact.business_info);
2160
- // contact_obj.mainCategory = cached_contact.mainCategory;
2161
- // contact_obj.subCategory = cached_contact.subCategory;
2162
- // contact_obj.business_size = cached_contact.business_size;
2163
- // contact_obj.country = cached_contact.country;
2164
- // contact_obj.bio = cached_contact.bio;
2165
- // contact_obj.business_name = cached_contact.business_name;
2166
- // // contact_obj.is_spam = cached_contact.is_spam;
2167
2166
  }
2167
+ // else {
2168
+ // // get from cache
2169
+
2170
+ // contact_obj.business_info = _.cloneDeep(cached_contact.business_info);
2171
+
2172
+ // // contact_obj.mainCategory = cached_contact.mainCategory;
2173
+ // // contact_obj.subCategory = cached_contact.subCategory;
2174
+ // // contact_obj.business_size = cached_contact.business_size;
2175
+ // // contact_obj.country = cached_contact.country;
2176
+ // // contact_obj.bio = cached_contact.bio;
2177
+ // // contact_obj.business_name = cached_contact.business_name;
2178
+ // // // contact_obj.is_spam = cached_contact.is_spam;
2179
+ // }
2168
2180
  const save_ret = await save_contact(uid, contact_obj);
2169
2181
  save_xuda_cache(uid, 'contact', contact_obj.email, null, contact_obj);
2182
+
2170
2183
  if (!contact_obj.is_spam && contact_obj.name) {
2171
2184
  set_contact_profile_picture(uid, contact_obj._id, metadata, job_id, headers);
2172
2185
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1703",
3
+ "version": "1.2.1705",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {