@xuda.io/account_module 1.2.1515 → 1.2.1517

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 +15 -92
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2614,6 +2614,9 @@ export const get_account_profile_info = async function (uid, contact_profile_doc
2614
2614
  if (!doc.profile_avatar) {
2615
2615
  doc.profile_avatar = account_info_ret.data.profile_avatar;
2616
2616
  }
2617
+ if (!doc.profile_picture) {
2618
+ doc.profile_picture = account_info_ret.data.profile_picture;
2619
+ }
2617
2620
 
2618
2621
  const get_pattern = async function (doc) {
2619
2622
  let ret = `default-pattern.png`;
@@ -3062,100 +3065,20 @@ export const save_picture_cache = async function (uid, docType, name, file, meta
3062
3065
  return save_ret;
3063
3066
  };
3064
3067
 
3065
- // export const get_picture_cache = async function (uid, docType, name) {
3066
- // let opt = { selector: { docType, name }, limit: 1 };
3067
-
3068
- // const ret = await db_module.find_couch_query('xuda_cache', opt);
3069
-
3070
- // if (ret.docs.length) {
3071
- // return ret.docs[0].file;
3072
- // }
3073
-
3074
- // function findAnyThreeWords(str) {
3075
- // // 1. Extract all words (letters + digits + underscore)
3076
- // const words = str.match(/\b\w+\b/g) || [];
3077
-
3078
- // // 2. If less than 3 words → no match
3079
- // if (words.length < 3) return [];
3080
-
3081
- // // 3. Generate all possible combinations of 3 different words
3082
- // const result = [];
3083
-
3084
- // for (let i = 0; i < words.length - 2; i++) {
3085
- // for (let j = i + 1; j < words.length - 1; j++) {
3086
- // for (let k = j + 1; k < words.length; k++) {
3087
- // result.push([words[i], words[j], words[k]]);
3088
- // }
3089
- // }
3090
- // }
3091
-
3092
- // // Optional: format as strings in any order you like
3093
- // return result.map((arr) => arr.join(' '));
3094
- // }
3095
- // if (name.split(' ').length < 3) return;
3096
- // let file;
3097
- // const words_combinations_arr = findAnyThreeWords(name);
3098
-
3099
- // for await (const phrase of words_combinations_arr) {
3100
- // const words_arr = phrase.split(' ');
3101
- // opt.selector = { docType, $and: [{ name: { $regex: `(?i)\\b${words_arr[0]}\\b` } }, { name: { $regex: `(?i)\\b${words_arr[1]}\\b` } }, { name: { $regex: `(?i)\\b${words_arr[2]}\\b` } }] };
3102
- // const ret = await db_module.find_couch_query('xuda_cache', opt);
3103
- // if (ret.docs.length) {
3104
- // file = ret.docs[0].file;
3105
- // break;
3106
- // }
3107
- // }
3108
- // return file;
3109
- // };
3110
-
3111
- export const get_picture_cache = async function (uid, docType, name) {
3112
- if (!name || typeof name !== 'string') return null;
3113
-
3114
- const words = name
3115
- .trim()
3116
- .toLowerCase()
3117
- .split(/\s+/)
3118
- .filter((w) => w.length > 1); // ignore very short words
3119
-
3120
- if (words.length < 3) {
3121
- // Direct exact match for short names
3122
- const ret = await db_module.find_couch_query('xuda_cache', {
3123
- selector: { docType, name: name.trim() },
3124
- limit: 1,
3125
- });
3126
-
3068
+ export const get_picture_cache = async function (uid, docType, name, email) {
3069
+ let ret = await db_module.find_couch_query('xuda_cache', {
3070
+ selector: { docType, name: email.trim() },
3071
+ limit: 1,
3072
+ });
3073
+ if (ret.docs.length) {
3127
3074
  return ret.docs[0]?.file ?? null;
3128
3075
  }
3129
3076
 
3130
- // Try combinations of 3 words — but **limit** the number of attempts
3131
- const MAX_ATTEMPTS = 15; // prevent explosion on long names
3132
- const combinations = [];
3133
-
3134
- for (let i = 0; i < words.length - 2 && combinations.length < MAX_ATTEMPTS; i++) {
3135
- for (let j = i + 1; j < words.length - 1 && combinations.length < MAX_ATTEMPTS; j++) {
3136
- for (let k = j + 1; k < words.length && combinations.length < MAX_ATTEMPTS; k++) {
3137
- combinations.push([words[i], words[j], words[k]]);
3138
- }
3139
- }
3140
- }
3141
-
3142
- for (const threeWords of combinations) {
3143
- const query = {
3144
- selector: {
3145
- docType,
3146
- $and: threeWords.map((word) => ({
3147
- name: { $regex: `(?i)\\b${word}\\b` },
3148
- })),
3149
- },
3150
- limit: 1,
3151
- };
3152
-
3153
- const ret = await db_module.find_couch_query('xuda_cache', query);
3154
-
3155
- if (ret.docs.length > 0) {
3156
- return ret.docs[0].file;
3157
- }
3077
+ ret = await db_module.find_couch_query('xuda_cache', {
3078
+ selector: { docType, name: name.trim() },
3079
+ limit: 1,
3080
+ });
3081
+ if (ret.docs.length) {
3082
+ return ret.docs[0]?.file ?? null;
3158
3083
  }
3159
-
3160
- return null;
3161
3084
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1515",
3
+ "version": "1.2.1517",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {