@xuda.io/account_module 1.2.1611 → 1.2.1613
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 +10 -10
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1921,7 +1921,7 @@ setTimeout(async () => {
|
|
|
1921
1921
|
// ret = _design.views.ai_chat_usage;
|
|
1922
1922
|
// console.log(_design.views.ai_chat_usage);
|
|
1923
1923
|
// ret = await set_contact_profile_picture(uid, 'cnt_2d21d55f8f0cdaf65a7a69f69617f532', {}, null, {});
|
|
1924
|
-
// ret = await
|
|
1924
|
+
// ret = await get_xuda_cache(uid, 'chat_thumbnail', 'word five title');
|
|
1925
1925
|
// add_ai_credits_to_active_accounts();
|
|
1926
1926
|
|
|
1927
1927
|
console.log(ret);
|
|
@@ -2023,7 +2023,7 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
|
|
2025
2025
|
const save_ret = await save_contact(uid, contact_obj);
|
|
2026
|
-
|
|
2026
|
+
save_xuda_cache(uid, 'contact', contact_obj.email, null, contact_obj);
|
|
2027
2027
|
if (!is_spam) {
|
|
2028
2028
|
set_contact_profile_picture(uid, contact_obj._id, metadata, job_id, headers);
|
|
2029
2029
|
}
|
|
@@ -2137,13 +2137,13 @@ const set_contact_profile_picture = async function (uid, contact_id, metadata, j
|
|
|
2137
2137
|
}
|
|
2138
2138
|
await update_contact_profile_picture_status(uid, contact_id, 2);
|
|
2139
2139
|
if (!contact_obj.profile_picture) {
|
|
2140
|
-
const cache = await
|
|
2140
|
+
const cache = await get_xuda_cache(uid, 'profile_picture', contact_obj.email, contact_obj.name);
|
|
2141
2141
|
let file_ret = { code: 1, data: cache };
|
|
2142
2142
|
|
|
2143
2143
|
if (!cache) {
|
|
2144
2144
|
file_ret = await ai_module.get_profile_picture(uid, contact_obj.account_type, contact_obj.name, { email: contact_obj.email, metadata }, account_profile_info, job_id, headers);
|
|
2145
|
-
|
|
2146
|
-
|
|
2145
|
+
save_xuda_cache(uid, 'profile_picture', contact_obj.name, file_ret.data, { account_type: contact_obj.account_type, type: 'contact' });
|
|
2146
|
+
save_xuda_cache(uid, 'profile_picture', contact_obj.email, file_ret.data, { account_type: contact_obj.account_type, type: 'contact' });
|
|
2147
2147
|
}
|
|
2148
2148
|
if (file_ret.code < 0) {
|
|
2149
2149
|
throw new Error(file_ret.data);
|
|
@@ -2160,7 +2160,7 @@ const set_contact_profile_picture = async function (uid, contact_id, metadata, j
|
|
|
2160
2160
|
}
|
|
2161
2161
|
|
|
2162
2162
|
if (!contact_obj.profile_avatar) {
|
|
2163
|
-
const cache = await
|
|
2163
|
+
const cache = await get_xuda_cache(uid, 'profile_avatar', contact_obj.email, contact_obj.name);
|
|
2164
2164
|
let file_ret = { code: 1, data: cache };
|
|
2165
2165
|
|
|
2166
2166
|
if (!cache) {
|
|
@@ -2179,8 +2179,8 @@ const set_contact_profile_picture = async function (uid, contact_id, metadata, j
|
|
|
2179
2179
|
job_id,
|
|
2180
2180
|
headers,
|
|
2181
2181
|
);
|
|
2182
|
-
|
|
2183
|
-
|
|
2182
|
+
save_xuda_cache(uid, 'profile_avatar', contact_obj.name, file_ret.data, { account_type: contact_obj.account_type, type: 'contact' });
|
|
2183
|
+
save_xuda_cache(uid, 'profile_avatar', contact_obj.email, file_ret.data, { account_type: contact_obj.account_type, type: 'contact' });
|
|
2184
2184
|
}
|
|
2185
2185
|
if (file_ret.code < 0) {
|
|
2186
2186
|
throw new Error(file_ret.data);
|
|
@@ -3020,7 +3020,7 @@ export const find_contact_query = async function (uid, opt) {
|
|
|
3020
3020
|
return ret;
|
|
3021
3021
|
};
|
|
3022
3022
|
|
|
3023
|
-
export const
|
|
3023
|
+
export const save_xuda_cache = async function (uid, docType, name, file, metadata = {}) {
|
|
3024
3024
|
let doc = {
|
|
3025
3025
|
_id: await _common.xuda_get_uuid('cache'),
|
|
3026
3026
|
name,
|
|
@@ -3035,7 +3035,7 @@ export const save_picture_cache = async function (uid, docType, name, file, meta
|
|
|
3035
3035
|
return save_ret;
|
|
3036
3036
|
};
|
|
3037
3037
|
|
|
3038
|
-
export const
|
|
3038
|
+
export const get_xuda_cache = async function (uid, docType, name, email) {
|
|
3039
3039
|
let ret = await db_module.find_couch_query('xuda_cache', {
|
|
3040
3040
|
selector: { docType, name: email.trim() },
|
|
3041
3041
|
limit: 1,
|