@xuda.io/account_module 1.2.806 → 1.2.808

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 +43 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1653,6 +1653,49 @@ export const archive_contact = async function (req) {
1653
1653
  }
1654
1654
  };
1655
1655
 
1656
+ export const delete_contact = async function (req) {
1657
+ const { contact_id } = req;
1658
+ try {
1659
+ var contact_doc = await db_module.get_couch_doc_native('xuda_contacts', contact_id);
1660
+ contact_doc.stat = 4;
1661
+ contact_doc.stat_ts = Date.now();
1662
+ contact_doc.stat_reason = 'deleted by the user';
1663
+
1664
+ const contact_save_ret = await db_module.save_couch_doc('xuda_contacts', contact_doc);
1665
+
1666
+ return contact_save_ret;
1667
+ } catch (err) {
1668
+ return {
1669
+ code: -22,
1670
+ data: err.message,
1671
+ };
1672
+ }
1673
+ };
1674
+
1675
+ export const unarchive_contact = async function (req) {
1676
+ const { contact_id } = req;
1677
+ try {
1678
+ var contact_doc = await db_module.get_couch_doc_native('xuda_contacts', contact_id);
1679
+
1680
+ if (conversation_doc.stat !== 5) {
1681
+ throw new Error('contact is not archived');
1682
+ }
1683
+
1684
+ contact_doc.stat = 3;
1685
+ contact_doc.stat_ts = Date.now();
1686
+ contact_doc.stat_reason = 'archived by the user';
1687
+
1688
+ const contact_save_ret = await db_module.save_couch_doc('xuda_contacts', contact_doc);
1689
+
1690
+ return contact_save_ret;
1691
+ } catch (err) {
1692
+ return {
1693
+ code: -22,
1694
+ data: err.message,
1695
+ };
1696
+ }
1697
+ };
1698
+
1656
1699
  export const unfriend_contact = async function (req) {
1657
1700
  const { contact_id } = req;
1658
1701
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.806",
3
+ "version": "1.2.808",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {