@xuda.io/account_module 1.2.1517 → 1.2.1519
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 +0 -69
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1470,11 +1470,6 @@ export const update_contact = async function (req) {
|
|
|
1470
1470
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
1471
1471
|
|
|
1472
1472
|
var contact_ret;
|
|
1473
|
-
// if (email) {
|
|
1474
|
-
// contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_user_email_address', { key: [account_profile_info.uid, email] });
|
|
1475
|
-
// } else if (contact_uid) {
|
|
1476
|
-
// contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [account_profile_info.uid, contact_uid] });
|
|
1477
|
-
// }
|
|
1478
1473
|
|
|
1479
1474
|
let opt = {
|
|
1480
1475
|
selector: {
|
|
@@ -1707,58 +1702,11 @@ export const get_user_name = async function (uid) {
|
|
|
1707
1702
|
}
|
|
1708
1703
|
};
|
|
1709
1704
|
|
|
1710
|
-
// TBD
|
|
1711
|
-
export const update_contacts_with_account_changes = async function (uid, changes = []) {
|
|
1712
|
-
try {
|
|
1713
|
-
if (!changes.length) return;
|
|
1714
|
-
const ret = await db_module.get_couch_doc('xuda_accounts', uid);
|
|
1715
|
-
var account_obj = ret.data;
|
|
1716
|
-
account_obj.ts = Date.now();
|
|
1717
|
-
|
|
1718
|
-
// update all uid contacts with the new avatar
|
|
1719
|
-
const opt = {
|
|
1720
|
-
selector: { contact_uid: uid, docType: 'contact' },
|
|
1721
|
-
};
|
|
1722
|
-
debugger;
|
|
1723
|
-
let changes_made;
|
|
1724
|
-
var contacts = await db_module.find_couch_query('xuda_contacts', opt);
|
|
1725
|
-
for (let doc of contacts.docs) {
|
|
1726
|
-
if (changes.includes('profile_picture')) {
|
|
1727
|
-
changes_made = true;
|
|
1728
|
-
doc.profile_picture = account_obj.account_info.profile_picture;
|
|
1729
|
-
}
|
|
1730
|
-
if (changes.includes('profile_avatar')) {
|
|
1731
|
-
changes_made = true;
|
|
1732
|
-
doc.profile_avatar = account_obj.account_info.profile_avatar;
|
|
1733
|
-
}
|
|
1734
|
-
if (changes.includes('email')) {
|
|
1735
|
-
changes_made = true;
|
|
1736
|
-
doc.email = account_obj.account_info.email;
|
|
1737
|
-
}
|
|
1738
|
-
if (changes.includes('first_name') || changes.includes('last_name')) {
|
|
1739
|
-
changes_made = true;
|
|
1740
|
-
doc.name = `${account_obj.account_info.first_name} ${account_obj.account_info.last_name}`;
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
console.log(doc);
|
|
1744
|
-
}
|
|
1745
|
-
if (contacts.docs && changes_made) {
|
|
1746
|
-
await db_module.save_couch_bulk_docs('xuda_contacts', contacts.docs);
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
return username;
|
|
1750
|
-
} catch (err) {
|
|
1751
|
-
return 'unknown';
|
|
1752
|
-
}
|
|
1753
|
-
};
|
|
1754
|
-
|
|
1755
1705
|
export const get_user_card = async function (uid, uid_query) {
|
|
1756
1706
|
if (uid === uid_query) return await get_user_contact(uid, uid_query);
|
|
1757
1707
|
|
|
1758
1708
|
let user_contact_obj;
|
|
1759
1709
|
|
|
1760
|
-
// const contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [uid, uid_query] });
|
|
1761
|
-
|
|
1762
1710
|
const opt = {
|
|
1763
1711
|
selector: {
|
|
1764
1712
|
docType: 'contact',
|
|
@@ -1967,11 +1915,6 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
1967
1915
|
const { account_profile_obj } = account_profile_info;
|
|
1968
1916
|
|
|
1969
1917
|
const ai_module = await import(`${module_path}/ai_module/index.mjs`);
|
|
1970
|
-
// const contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_user_email_address', { key: [account_profile_info.uid, email] });
|
|
1971
|
-
|
|
1972
|
-
// if (contact_ret.rows.length) {
|
|
1973
|
-
// throw new Error('contact already exist active or deleted');
|
|
1974
|
-
// }
|
|
1975
1918
|
|
|
1976
1919
|
//////////////////
|
|
1977
1920
|
const opt = {
|
|
@@ -2012,18 +1955,6 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
2012
1955
|
|
|
2013
1956
|
const is_business = await ai_module.is_business_contact(uid, email, name, metadata.subject, metadata.summarized_body, account_profile_info);
|
|
2014
1957
|
account_type = is_business ? 'business' : 'personal';
|
|
2015
|
-
// const existing_contacts_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_email_address', { key: email });
|
|
2016
|
-
// for (const contact of existing_contacts_ret.rows) {
|
|
2017
|
-
// if (contact.value.profile_avatar) {
|
|
2018
|
-
// profile_avatar = contact.value.profile_avatar;
|
|
2019
|
-
// profile_avatar_obj == contact.value.profile_avatar_obj;
|
|
2020
|
-
// }
|
|
2021
|
-
// }
|
|
2022
|
-
|
|
2023
|
-
// if (!is_spam) {
|
|
2024
|
-
// profile_picture_obj = await ai_module.get_profile_picture(uid, account_type, name, { email, context, metadata }, account_profile_info, job_id, headers);
|
|
2025
|
-
// profile_picture = profile_picture_obj.url;
|
|
2026
|
-
// }
|
|
2027
1958
|
}
|
|
2028
1959
|
|
|
2029
1960
|
const d = Date.now();
|