@xuda.io/account_module 1.2.325 → 1.2.326
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 +29 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1558,3 +1558,32 @@ export const get_user_name = async function (uid) {
|
|
|
1558
1558
|
return 'unknown';
|
|
1559
1559
|
}
|
|
1560
1560
|
};
|
|
1561
|
+
|
|
1562
|
+
export const update_contacts_with_account_changes = async function (uid, changes = []) {
|
|
1563
|
+
try {
|
|
1564
|
+
const account_info = await get_account_name({ uid });
|
|
1565
|
+
let username = 'unknown';
|
|
1566
|
+
if (account_info) {
|
|
1567
|
+
username = account_info.first_name + ' ' + account_info.last_name;
|
|
1568
|
+
|
|
1569
|
+
if (!username) {
|
|
1570
|
+
username = +account_info.email;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// update all uid contacts with the new avatar
|
|
1575
|
+
const opt = {
|
|
1576
|
+
selector: { contact_uid: db_doc._id, docType: 'contact' },
|
|
1577
|
+
};
|
|
1578
|
+
debugger;
|
|
1579
|
+
var contacts = await db_module.find_couch_query('xuda_contacts', opt);
|
|
1580
|
+
for (let doc of contacts.docs) {
|
|
1581
|
+
doc.profile_avatar = db_doc.account_info.profile_avatar;
|
|
1582
|
+
console.log(doc);
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
return username;
|
|
1586
|
+
} catch (err) {
|
|
1587
|
+
return 'unknown';
|
|
1588
|
+
}
|
|
1589
|
+
};
|