@juzi/wechaty-puppet-service 1.0.14 → 1.0.16

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.
@@ -1492,281 +1492,235 @@ function puppetImplementation (
1492
1492
  }
1493
1493
  },
1494
1494
 
1495
- tagContactAdd: async (call, callback) => {
1496
- log.verbose('PuppetServiceImpl', 'tagContactAdd()')
1495
+ /**
1496
+ *
1497
+ * tag section
1498
+ *
1499
+ */
1500
+
1501
+ tagContactTagAdd: async (call, callback) => {
1502
+ log.verbose('PuppetServiceImpl', 'tagContactTagAdd()')
1497
1503
 
1498
1504
  try {
1499
- const tagId = call.request.getId()
1505
+ const tagGroupId = call.request.getTagGroupId()
1506
+ const tagId = call.request.getTagId()
1500
1507
  const contactId = call.request.getContactId()
1501
1508
 
1502
- await puppet.tagContactAdd(tagId, contactId)
1503
-
1504
- return callback(null, new grpcPuppet.TagContactAddResponse())
1509
+ await puppet.tagContactTagAdd(tagGroupId, tagId, contactId)
1505
1510
 
1511
+ return callback(null, new grpcPuppet.TagContactTagAddResponse())
1506
1512
  } catch (e) {
1507
- return grpcError('tagContactAdd', e, callback)
1513
+ return grpcError('tagContactTagAdd', e, callback)
1508
1514
  }
1509
1515
  },
1510
1516
 
1511
- tagContactDelete: async (call, callback) => {
1512
- log.verbose('PuppetServiceImpl', 'tagContactDelete()')
1517
+ tagContactTagRemove: async (call, callback) => {
1518
+ log.verbose('PuppetServiceImpl', 'tagContactTagRemove()')
1513
1519
 
1514
1520
  try {
1515
- const tagId = call.request.getId()
1516
-
1517
- await puppet.tagContactDelete(tagId)
1521
+ const tagGroupId = call.request.getTagGroupId()
1522
+ const tagId = call.request.getTagId()
1523
+ const contactId = call.request.getContactId()
1518
1524
 
1519
- return callback(null, new grpcPuppet.TagContactDeleteResponse())
1525
+ await puppet.tagContactTagRemove(tagGroupId, tagId, contactId)
1520
1526
 
1527
+ return callback(null, new grpcPuppet.TagContactTagRemoveResponse())
1521
1528
  } catch (e) {
1522
- return grpcError('tagContactDelete', e, callback)
1529
+ return grpcError('tagContactTagRemove', e, callback)
1523
1530
  }
1524
1531
  },
1525
1532
 
1526
- tagContactList: async (call, callback) => {
1527
- log.verbose('PuppetServiceImpl', 'tagContactList()')
1533
+ tagGroupAdd: async (call, callback) => {
1534
+ log.verbose('PuppetServiceImpl', 'tagGroupAdd()')
1528
1535
 
1529
1536
  try {
1530
- const contactId = call.request.getContactId()
1531
-
1532
- /**
1533
- * for a specific contact
1534
- */
1535
- if (contactId) {
1536
- const tagIdList = await puppet.tagContactList(contactId)
1537
-
1538
- const response = new grpcPuppet.TagContactListResponse()
1539
- response.setIdsList(tagIdList)
1540
-
1541
- return callback(null, new grpcPuppet.TagContactListResponse())
1542
- }
1543
-
1544
- {
1545
- /**
1546
- * Huan(202110): Deprecated: will be removed after Dec 31, 2022
1547
- */
1548
- const contactIdWrapper = call.request.getContactIdStringValueDeprecated()
1549
-
1550
- if (contactIdWrapper) {
1551
- const contactId = contactIdWrapper.getValue()
1552
-
1553
- const tagIdList = await puppet.tagContactList(contactId)
1537
+ const tagGroupName = call.request.getTagGroupName()
1554
1538
 
1555
- const response = new grpcPuppet.TagContactListResponse()
1556
- response.setIdsList(tagIdList)
1539
+ const result = await puppet.tagGroupAdd(tagGroupName)
1540
+ const payload = new grpcPuppet.TagGroupPayload()
1541
+ const response = new grpcPuppet.TagGroupAddResponse()
1557
1542
 
1558
- return callback(null, new grpcPuppet.TagContactListResponse())
1559
- }
1543
+ if (result) {
1544
+ payload.setId(result.id)
1545
+ payload.setName(result.name)
1546
+ response.setPayload(payload)
1560
1547
  }
1561
1548
 
1562
- /**
1563
- * get all tags for all contact
1564
- */
1565
- const tagIdList = await puppet.tagContactList()
1566
-
1567
- const response = new grpcPuppet.TagContactListResponse()
1568
- response.setIdsList(tagIdList)
1569
-
1570
1549
  return callback(null, response)
1571
-
1572
- } catch (e) {
1573
- return grpcError('tagContactList', e, callback)
1574
- }
1575
- },
1576
-
1577
- tagContactRemove: async (call, callback) => {
1578
- log.verbose('PuppetServiceImpl', 'tagContactRemove()')
1579
-
1580
- try {
1581
- const tagId = call.request.getId()
1582
- const contactId = call.request.getContactId()
1583
-
1584
- await puppet.tagContactRemove(tagId, contactId)
1585
-
1586
- return callback(null, new grpcPuppet.TagContactRemoveResponse())
1587
-
1588
1550
  } catch (e) {
1589
- return grpcError('tagContactRemove', e, callback)
1551
+ return grpcError('tagGroupAdd', e, callback)
1590
1552
  }
1591
1553
  },
1592
1554
 
1593
- /**
1594
- *
1595
- * corp-tag section
1596
- *
1597
- */
1598
-
1599
- corpTagContactTagAdd: async (call, callback) => {
1600
- log.verbose('PuppetServiceImpl', 'corpTagContactTagAdd()')
1601
-
1602
- try {
1603
- const corpTagGroupId = call.request.getCorpTagGroupId()
1604
- const corpTagId = call.request.getCorpTagId()
1605
- const contactId = call.request.getContactId()
1606
-
1607
- await puppet.corpTagContactTagAdd(corpTagGroupId, corpTagId, contactId)
1608
-
1609
- return callback(null, new grpcPuppet.CorpTagContactTagAddResponse())
1610
- } catch (e) {
1611
- return grpcError('corpTagContactTagAdd', e, callback)
1612
- }
1613
- },
1614
-
1615
- corpTagContactTagRemove: async (call, callback) => {
1616
- log.verbose('PuppetServiceImpl', 'corpTagContactTagRemove()')
1555
+ tagGroupDelete: async (call, callback) => {
1556
+ log.verbose('PuppetServiceImpl', 'tagGroupDelete()')
1617
1557
 
1618
1558
  try {
1619
- const corpTagGroupId = call.request.getCorpTagGroupId()
1620
- const corpTagId = call.request.getCorpTagId()
1621
- const contactId = call.request.getContactId()
1559
+ const tagGroupId = call.request.getTagGroupId()
1622
1560
 
1623
- await puppet.corpTagContactTagRemove(corpTagGroupId, corpTagId, contactId)
1561
+ await puppet.tagGroupDelete(tagGroupId)
1624
1562
 
1625
- return callback(null, new grpcPuppet.CorpTagContactTagRemoveResponse())
1563
+ return callback(null, new grpcPuppet.TagGroupDeleteResponse())
1626
1564
  } catch (e) {
1627
- return grpcError('corpTagContactTagRemove', e, callback)
1565
+ return grpcError('tagGroupDelete', e, callback)
1628
1566
  }
1629
1567
  },
1630
1568
 
1631
- corpTagGroupAdd: async (call, callback) => {
1632
- log.verbose('PuppetServiceImpl', 'corpTagGroupAdd()')
1569
+ tagTagAdd: async (call, callback) => {
1570
+ log.verbose('PuppetServiceImpl', 'tagTagAdd()')
1633
1571
 
1634
1572
  try {
1635
- const corpTagGroupName = call.request.getCorpTagGroupName()
1573
+ const tagGroupId = call.request.getTagGroupId()
1574
+ const tagName = call.request.getTagName()
1636
1575
 
1637
- const result = await puppet.corpTagGroupAdd(corpTagGroupName)
1638
- const payload = new grpcPuppet.CorpTagGroupPayload()
1639
- const response = new grpcPuppet.CorpTagGroupAddResponse()
1576
+ const result = await puppet.tagTagAdd(tagGroupId, tagName)
1577
+ const payload = new grpcPuppet.TagPayload()
1578
+ const response = new grpcPuppet.TagTagAddResponse()
1640
1579
 
1641
1580
  if (result) {
1642
1581
  payload.setId(result.id)
1643
1582
  payload.setName(result.name)
1583
+ payload.setType(result.type)
1584
+ if (result.groupId) {
1585
+ payload.setGroupId(result.groupId)
1586
+ }
1644
1587
  response.setPayload(payload)
1645
1588
  }
1646
1589
 
1647
1590
  return callback(null, response)
1648
1591
  } catch (e) {
1649
- return grpcError('corpTagGroupAdd', e, callback)
1592
+ return grpcError('tagTagAdd', e, callback)
1650
1593
  }
1651
1594
  },
1652
1595
 
1653
- corpTagGroupDelete: async (call, callback) => {
1654
- log.verbose('PuppetServiceImpl', 'corpTagGroupDelete()')
1596
+ tagTagDelete: async (call, callback) => {
1597
+ log.verbose('PuppetServiceImpl', 'tagTagDelete()')
1655
1598
 
1656
1599
  try {
1657
- const corpTagGroupId = call.request.getCorpTagGroupId()
1600
+ const tagGroupId = call.request.getTagGroupId()
1601
+ const tagId = call.request.getTagId()
1658
1602
 
1659
- await puppet.corpTagGroupDelete(corpTagGroupId)
1603
+ await puppet.tagTagDelete(tagGroupId, tagId)
1660
1604
 
1661
- return callback(null, new grpcPuppet.CorpTagGroupDeleteResponse())
1605
+ return callback(null, new grpcPuppet.TagTagDeleteResponse())
1662
1606
  } catch (e) {
1663
- return grpcError('corpTagGroupDelete', e, callback)
1607
+ return grpcError('tagTagDelete', e, callback)
1664
1608
  }
1665
1609
  },
1666
1610
 
1667
- corpTagTagAdd: async (call, callback) => {
1668
- log.verbose('PuppetServiceImpl', 'corpTagTagAdd()')
1611
+ tagGroupList: async (call, callback) => {
1612
+ log.verbose('PuppetServiceImpl', 'tagGroupList()')
1613
+ void call
1669
1614
 
1670
1615
  try {
1671
- const corpTagGroupId = call.request.getCorpTagGroupId()
1672
- const corpTagName = call.request.getCorpTagName()
1673
-
1674
- const result = await puppet.corpTagTagAdd(corpTagGroupId, corpTagName)
1675
- const payload = new grpcPuppet.CorpTagPayload()
1676
- const response = new grpcPuppet.CorpTagTagAddResponse()
1677
-
1678
- if (result) {
1679
- payload.setId(result.id)
1680
- payload.setName(result.name)
1681
- payload.setGroupId(result.groupId)
1682
- response.setPayload(payload)
1683
- }
1616
+ const result = await puppet.tagGroupList()
1617
+ const payloads = result.map(tagGroup => {
1618
+ const payload = new grpcPuppet.TagGroupPayload()
1619
+ payload.setId(tagGroup.id)
1620
+ payload.setName(tagGroup.name)
1621
+ return payload
1622
+ })
1623
+ const response = new grpcPuppet.TagGroupListResponse()
1624
+ response.setPayloadsList(payloads)
1684
1625
 
1685
1626
  return callback(null, response)
1686
1627
  } catch (e) {
1687
- return grpcError('corpTagTagAdd', e, callback)
1628
+ return grpcError('tagGroupList', e, callback)
1688
1629
  }
1689
1630
  },
1690
1631
 
1691
- corpTagTagDelete: async (call, callback) => {
1692
- log.verbose('PuppetServiceImpl', 'corpTagTagDelete()')
1632
+ tagGroupTagList: async (call, callback) => {
1633
+ log.verbose('PuppetServiceImpl', 'tagGroupTagList()')
1693
1634
 
1694
1635
  try {
1695
- const corpTagGroupId = call.request.getCorpTagGroupId()
1696
- const corpTagId = call.request.getCorpTagId()
1636
+ const tagGroupId = call.request.getTagGroupId()
1697
1637
 
1698
- await puppet.corpTagTagDelete(corpTagGroupId, corpTagId)
1638
+ const result = await puppet.tagGroupTagList(tagGroupId)
1639
+ const payloads = result.map(tag => {
1640
+ const payload = new grpcPuppet.TagPayload()
1641
+ payload.setId(tag.id)
1642
+ payload.setName(tag.name)
1643
+ payload.setType(tag.type)
1644
+ if (tag.groupId) {
1645
+ payload.setGroupId(tag.groupId)
1646
+ }
1647
+ return payload
1648
+ })
1649
+ const response = new grpcPuppet.TagTagListResponse()
1650
+ response.setPayloadsList(payloads)
1699
1651
 
1700
- return callback(null, new grpcPuppet.CorpTagTagDeleteResponse())
1652
+ return callback(null, response)
1701
1653
  } catch (e) {
1702
- return grpcError('corpTagTagDelete', e, callback)
1654
+ return grpcError('tagTagList', e, callback)
1703
1655
  }
1704
1656
  },
1705
1657
 
1706
- corpTagGroupList: async (call, callback) => {
1707
- log.verbose('PuppetServiceImpl', 'corpTagGroupList()')
1658
+ tagTagList: async (call, callback) => {
1659
+ log.verbose('PuppetServiceImpl', 'tagTagList()')
1708
1660
  void call
1709
1661
 
1710
1662
  try {
1711
- const result = await puppet.corpTagGroupList()
1712
- const payloads = result.map(corpTagGroup => {
1713
- const payload = new grpcPuppet.CorpTagGroupPayload()
1714
- payload.setId(corpTagGroup.id)
1715
- payload.setName(corpTagGroup.name)
1663
+ const result = await puppet.tagTagList()
1664
+ const payloads = result.map(tag => {
1665
+ const payload = new grpcPuppet.TagPayload()
1666
+ payload.setId(tag.id)
1667
+ payload.setName(tag.name)
1668
+ payload.setType(tag.type)
1669
+ if (tag.groupId) {
1670
+ payload.setGroupId(tag.groupId)
1671
+ }
1716
1672
  return payload
1717
1673
  })
1718
- const response = new grpcPuppet.CorpTagGroupListResponse()
1674
+ const response = new grpcPuppet.TagTagListResponse()
1719
1675
  response.setPayloadsList(payloads)
1720
1676
 
1721
1677
  return callback(null, response)
1722
1678
  } catch (e) {
1723
- return grpcError('corpTagGroupList', e, callback)
1679
+ return grpcError('tagTagList', e, callback)
1724
1680
  }
1725
1681
  },
1726
1682
 
1727
- corpTagTagList: async (call, callback) => {
1728
- log.verbose('PuppetServiceImpl', 'corpTagTagList()')
1683
+ tagContactTagList: async (call, callback) => {
1684
+ log.verbose('PuppetServiceImpl', 'tagContactTagList()')
1729
1685
 
1730
1686
  try {
1731
- const corpTagGroupId = call.request.getCorpTagGroupId()
1687
+ const contactId = call.request.getContactId()
1732
1688
 
1733
- const result = await puppet.corpTagTagList(corpTagGroupId)
1734
- const payloads = result.map(corpTag => {
1735
- const payload = new grpcPuppet.CorpTagPayload()
1736
- payload.setId(corpTag.id)
1737
- payload.setName(corpTag.name)
1738
- payload.setGroupId(corpTag.groupId)
1689
+ const result = await puppet.tagContactTagList(contactId)
1690
+ const payloads = result.map(tag => {
1691
+ const payload = new grpcPuppet.TagPayload()
1692
+ payload.setId(tag.id)
1693
+ payload.setName(tag.name)
1694
+ payload.setType(tag.type)
1695
+ if (tag.groupId) {
1696
+ payload.setGroupId(tag.groupId)
1697
+ }
1739
1698
  return payload
1740
1699
  })
1741
- const response = new grpcPuppet.CorpTagTagListResponse()
1700
+ const response = new grpcPuppet.TagContactTagListResponse()
1742
1701
  response.setPayloadsList(payloads)
1743
1702
 
1744
1703
  return callback(null, response)
1745
1704
  } catch (e) {
1746
- return grpcError('corpTagTagList', e, callback)
1705
+ return grpcError('tagContactTagList', e, callback)
1747
1706
  }
1748
1707
  },
1749
1708
 
1750
- corpTagContactTagList: async (call, callback) => {
1751
- log.verbose('PuppetServiceImpl', 'corpTagContactTagList()')
1709
+ tagTagContactList: async (call, callback) => {
1710
+ log.verbose('PuppetServiceImpl', 'tagTagContactList()')
1752
1711
 
1753
1712
  try {
1754
- const contactId = call.request.getContactId()
1713
+ const tagGroupId = call.request.getTagGroupId()
1714
+ const tagId = call.request.getTagId()
1755
1715
 
1756
- const result = await puppet.corpTagTagList(contactId)
1757
- const payloads = result.map(corpTag => {
1758
- const payload = new grpcPuppet.CorpTagPayload()
1759
- payload.setId(corpTag.id)
1760
- payload.setName(corpTag.name)
1761
- payload.setGroupId(corpTag.groupId)
1762
- return payload
1763
- })
1764
- const response = new grpcPuppet.CorpTagContactTagListResponse()
1765
- response.setPayloadsList(payloads)
1716
+ const result = await puppet.tagTagContactList(tagGroupId, tagId)
1717
+
1718
+ const response = new grpcPuppet.TagTagContactListResponse()
1719
+ response.setPayloadsList(result)
1766
1720
 
1767
1721
  return callback(null, response)
1768
1722
  } catch (e) {
1769
- return grpcError('corpTagContactTagList', e, callback)
1723
+ return grpcError('tagTagContactList', e, callback)
1770
1724
  }
1771
1725
  },
1772
1726