@xuda.io/account_module 1.2.2224 → 1.2.2230
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.
- package/index.mjs +46 -38
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -189,12 +189,12 @@ export const update_account_info = async function (req, job_id, headers) {
|
|
|
189
189
|
return save_ret;
|
|
190
190
|
};
|
|
191
191
|
export const update_account_preferences = async function (req) {
|
|
192
|
-
const { uid, hide_create_button, default_dashboard, sidebar_style } = req;
|
|
192
|
+
const { uid, hide_create_button, default_dashboard, sidebar_style, enable_thumbnail_avatar_generation } = req;
|
|
193
193
|
try {
|
|
194
194
|
let account_doc = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
195
195
|
account_doc.ts = Date.now();
|
|
196
196
|
|
|
197
|
-
account_doc.preferences = { hide_create_button, default_dashboard, sidebar_style };
|
|
197
|
+
account_doc.preferences = { hide_create_button, default_dashboard, sidebar_style, enable_thumbnail_avatar_generation };
|
|
198
198
|
|
|
199
199
|
const save_ret = await db_module.save_couch_doc('xuda_accounts', account_doc);
|
|
200
200
|
if (save_ret.code < 0) {
|
|
@@ -1730,7 +1730,7 @@ export const get_account_default_project_id = async function (uid) {
|
|
|
1730
1730
|
|
|
1731
1731
|
export const get_user_name = async function (uid) {
|
|
1732
1732
|
try {
|
|
1733
|
-
const account_info = await get_account_name({ uid });
|
|
1733
|
+
const { data: account_info } = await get_account_name({ uid });
|
|
1734
1734
|
let username = 'unknown';
|
|
1735
1735
|
if (account_info) {
|
|
1736
1736
|
username = account_info.first_name + ' ' + account_info.last_name;
|
|
@@ -2366,50 +2366,50 @@ export const get_contacts = async function (req, job_id, headers) {
|
|
|
2366
2366
|
|
|
2367
2367
|
let contact_docs = { docs: [], total_docs: contacts.total_docs };
|
|
2368
2368
|
|
|
2369
|
-
const chat_conversation_count = async function () {
|
|
2370
|
-
|
|
2369
|
+
// const chat_conversation_count = async function () {
|
|
2370
|
+
// // const account_profile_info = await get_active_account_profile_info(uid);
|
|
2371
2371
|
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2372
|
+
// const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'conversations_item_counts', {
|
|
2373
|
+
// reduce: true,
|
|
2374
|
+
// group_level: 999,
|
|
2375
2375
|
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2376
|
+
// startkey: ['contacts', '', ''],
|
|
2377
|
+
// endkey: ['contacts', 'zzzzzz', 'zzzzzz'],
|
|
2378
|
+
// });
|
|
2379
2379
|
|
|
2380
|
-
|
|
2380
|
+
// // return counts_ret?.rows?.[0]?.value || 0;
|
|
2381
2381
|
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2382
|
+
// let counts = {};
|
|
2383
|
+
// for (const val of counts_ret?.rows) {
|
|
2384
|
+
// if (!counts[val.key[1]]) {
|
|
2385
|
+
// counts[val.key[1]] = 0;
|
|
2386
|
+
// }
|
|
2387
2387
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2388
|
+
// counts[val.key[1]] += val.value;
|
|
2389
|
+
// }
|
|
2390
2390
|
|
|
2391
|
-
|
|
2392
|
-
};
|
|
2393
|
-
const chat_conversation_read = async function () {
|
|
2394
|
-
|
|
2391
|
+
// return counts;
|
|
2392
|
+
// };
|
|
2393
|
+
// const chat_conversation_read = async function () {
|
|
2394
|
+
// // const account_profile_info = await get_active_account_profile_info(uid);
|
|
2395
2395
|
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2396
|
+
// const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_read', {
|
|
2397
|
+
// reduce: true,
|
|
2398
|
+
// group_level: 999,
|
|
2399
2399
|
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2400
|
+
// startkey: [uid, '', ''],
|
|
2401
|
+
// endkey: [uid, 'zzzzzz', 'zzzzzz'],
|
|
2402
|
+
// });
|
|
2403
2403
|
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
};
|
|
2404
|
+
// let counts = {};
|
|
2405
|
+
// for (const val of counts_ret?.rows) {
|
|
2406
|
+
// if (!counts[val.key[1]]) {
|
|
2407
|
+
// counts[val.key[1]] = 0;
|
|
2408
|
+
// }
|
|
2409
|
+
// counts[val.key[1]] += val.value;
|
|
2410
|
+
// }
|
|
2411
|
+
// return counts;
|
|
2412
|
+
// };
|
|
2413
2413
|
|
|
2414
2414
|
// const contact_chat_conversation_count_ret = await chat_conversation_count();
|
|
2415
2415
|
// const contact_chat_conversation_read_ret = await chat_conversation_read();
|
|
@@ -3376,6 +3376,13 @@ export const save_xuda_cache = async function (uid, docType, key, file, metadata
|
|
|
3376
3376
|
const cache = await get_xuda_cache(uid, docType, key);
|
|
3377
3377
|
if (cache) return;
|
|
3378
3378
|
|
|
3379
|
+
const keyWords = key
|
|
3380
|
+
.trim()
|
|
3381
|
+
.toLowerCase()
|
|
3382
|
+
.split(/\s+/)
|
|
3383
|
+
.filter((w) => w.length > 1)
|
|
3384
|
+
.filter((w, i, arr) => arr.indexOf(w) === i); // deduplicate
|
|
3385
|
+
|
|
3379
3386
|
let doc = {
|
|
3380
3387
|
_id: await _common.xuda_get_uuid('cache'),
|
|
3381
3388
|
key: key.toLowerCase().trim(),
|
|
@@ -3385,6 +3392,7 @@ export const save_xuda_cache = async function (uid, docType, key, file, metadata
|
|
|
3385
3392
|
date_created_ts: Date.now(),
|
|
3386
3393
|
metadata,
|
|
3387
3394
|
hits: 0,
|
|
3395
|
+
keyWords,
|
|
3388
3396
|
};
|
|
3389
3397
|
const save_ret = await db_module.save_couch_doc('xuda_cache', doc);
|
|
3390
3398
|
return save_ret;
|