@juzi/wechaty-puppet-service 1.0.12 → 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,101 +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)
1509
+ await puppet.tagContactTagAdd(tagGroupId, tagId, contactId)
1510
+
1511
+ return callback(null, new grpcPuppet.TagContactTagAddResponse())
1512
+ } catch (e) {
1513
+ return grpcError('tagContactTagAdd', e, callback)
1514
+ }
1515
+ },
1516
+
1517
+ tagContactTagRemove: async (call, callback) => {
1518
+ log.verbose('PuppetServiceImpl', 'tagContactTagRemove()')
1503
1519
 
1504
- return callback(null, new grpcPuppet.TagContactAddResponse())
1520
+ try {
1521
+ const tagGroupId = call.request.getTagGroupId()
1522
+ const tagId = call.request.getTagId()
1523
+ const contactId = call.request.getContactId()
1505
1524
 
1525
+ await puppet.tagContactTagRemove(tagGroupId, tagId, contactId)
1526
+
1527
+ return callback(null, new grpcPuppet.TagContactTagRemoveResponse())
1506
1528
  } catch (e) {
1507
- return grpcError('tagContactAdd', e, callback)
1529
+ return grpcError('tagContactTagRemove', e, callback)
1508
1530
  }
1509
1531
  },
1510
1532
 
1511
- tagContactDelete: async (call, callback) => {
1512
- log.verbose('PuppetServiceImpl', 'tagContactDelete()')
1533
+ tagGroupAdd: async (call, callback) => {
1534
+ log.verbose('PuppetServiceImpl', 'tagGroupAdd()')
1513
1535
 
1514
1536
  try {
1515
- const tagId = call.request.getId()
1537
+ const tagGroupName = call.request.getTagGroupName()
1516
1538
 
1517
- await puppet.tagContactDelete(tagId)
1539
+ const result = await puppet.tagGroupAdd(tagGroupName)
1540
+ const payload = new grpcPuppet.TagGroupPayload()
1541
+ const response = new grpcPuppet.TagGroupAddResponse()
1518
1542
 
1519
- return callback(null, new grpcPuppet.TagContactDeleteResponse())
1543
+ if (result) {
1544
+ payload.setId(result.id)
1545
+ payload.setName(result.name)
1546
+ response.setPayload(payload)
1547
+ }
1520
1548
 
1549
+ return callback(null, response)
1521
1550
  } catch (e) {
1522
- return grpcError('tagContactDelete', e, callback)
1551
+ return grpcError('tagGroupAdd', e, callback)
1523
1552
  }
1524
1553
  },
1525
1554
 
1526
- tagContactList: async (call, callback) => {
1527
- log.verbose('PuppetServiceImpl', 'tagContactList()')
1555
+ tagGroupDelete: async (call, callback) => {
1556
+ log.verbose('PuppetServiceImpl', 'tagGroupDelete()')
1528
1557
 
1529
1558
  try {
1530
- const contactId = call.request.getContactId()
1559
+ const tagGroupId = call.request.getTagGroupId()
1531
1560
 
1532
- /**
1533
- * for a specific contact
1534
- */
1535
- if (contactId) {
1536
- const tagIdList = await puppet.tagContactList(contactId)
1561
+ await puppet.tagGroupDelete(tagGroupId)
1562
+
1563
+ return callback(null, new grpcPuppet.TagGroupDeleteResponse())
1564
+ } catch (e) {
1565
+ return grpcError('tagGroupDelete', e, callback)
1566
+ }
1567
+ },
1537
1568
 
1538
- const response = new grpcPuppet.TagContactListResponse()
1539
- response.setIdsList(tagIdList)
1569
+ tagTagAdd: async (call, callback) => {
1570
+ log.verbose('PuppetServiceImpl', 'tagTagAdd()')
1540
1571
 
1541
- return callback(null, new grpcPuppet.TagContactListResponse())
1572
+ try {
1573
+ const tagGroupId = call.request.getTagGroupId()
1574
+ const tagName = call.request.getTagName()
1575
+
1576
+ const result = await puppet.tagTagAdd(tagGroupId, tagName)
1577
+ const payload = new grpcPuppet.TagPayload()
1578
+ const response = new grpcPuppet.TagTagAddResponse()
1579
+
1580
+ if (result) {
1581
+ payload.setId(result.id)
1582
+ payload.setName(result.name)
1583
+ payload.setType(result.type)
1584
+ if (result.groupId) {
1585
+ payload.setGroupId(result.groupId)
1586
+ }
1587
+ response.setPayload(payload)
1542
1588
  }
1543
1589
 
1544
- {
1545
- /**
1546
- * Huan(202110): Deprecated: will be removed after Dec 31, 2022
1547
- */
1548
- const contactIdWrapper = call.request.getContactIdStringValueDeprecated()
1590
+ return callback(null, response)
1591
+ } catch (e) {
1592
+ return grpcError('tagTagAdd', e, callback)
1593
+ }
1594
+ },
1549
1595
 
1550
- if (contactIdWrapper) {
1551
- const contactId = contactIdWrapper.getValue()
1596
+ tagTagDelete: async (call, callback) => {
1597
+ log.verbose('PuppetServiceImpl', 'tagTagDelete()')
1552
1598
 
1553
- const tagIdList = await puppet.tagContactList(contactId)
1599
+ try {
1600
+ const tagGroupId = call.request.getTagGroupId()
1601
+ const tagId = call.request.getTagId()
1554
1602
 
1555
- const response = new grpcPuppet.TagContactListResponse()
1556
- response.setIdsList(tagIdList)
1603
+ await puppet.tagTagDelete(tagGroupId, tagId)
1557
1604
 
1558
- return callback(null, new grpcPuppet.TagContactListResponse())
1559
- }
1560
- }
1605
+ return callback(null, new grpcPuppet.TagTagDeleteResponse())
1606
+ } catch (e) {
1607
+ return grpcError('tagTagDelete', e, callback)
1608
+ }
1609
+ },
1561
1610
 
1562
- /**
1563
- * get all tags for all contact
1564
- */
1565
- const tagIdList = await puppet.tagContactList()
1611
+ tagGroupList: async (call, callback) => {
1612
+ log.verbose('PuppetServiceImpl', 'tagGroupList()')
1613
+ void call
1566
1614
 
1567
- const response = new grpcPuppet.TagContactListResponse()
1568
- response.setIdsList(tagIdList)
1615
+ try {
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)
1569
1625
 
1570
1626
  return callback(null, response)
1627
+ } catch (e) {
1628
+ return grpcError('tagGroupList', e, callback)
1629
+ }
1630
+ },
1631
+
1632
+ tagGroupTagList: async (call, callback) => {
1633
+ log.verbose('PuppetServiceImpl', 'tagGroupTagList()')
1634
+
1635
+ try {
1636
+ const tagGroupId = call.request.getTagGroupId()
1637
+
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)
1651
+
1652
+ return callback(null, response)
1653
+ } catch (e) {
1654
+ return grpcError('tagTagList', e, callback)
1655
+ }
1656
+ },
1571
1657
 
1658
+ tagTagList: async (call, callback) => {
1659
+ log.verbose('PuppetServiceImpl', 'tagTagList()')
1660
+ void call
1661
+
1662
+ try {
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
+ }
1672
+ return payload
1673
+ })
1674
+ const response = new grpcPuppet.TagTagListResponse()
1675
+ response.setPayloadsList(payloads)
1676
+
1677
+ return callback(null, response)
1572
1678
  } catch (e) {
1573
- return grpcError('tagContactList', e, callback)
1679
+ return grpcError('tagTagList', e, callback)
1574
1680
  }
1575
1681
  },
1576
1682
 
1577
- tagContactRemove: async (call, callback) => {
1578
- log.verbose('PuppetServiceImpl', 'tagContactRemove()')
1683
+ tagContactTagList: async (call, callback) => {
1684
+ log.verbose('PuppetServiceImpl', 'tagContactTagList()')
1579
1685
 
1580
1686
  try {
1581
- const tagId = call.request.getId()
1582
1687
  const contactId = call.request.getContactId()
1583
1688
 
1584
- await puppet.tagContactRemove(tagId, contactId)
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
+ }
1698
+ return payload
1699
+ })
1700
+ const response = new grpcPuppet.TagContactTagListResponse()
1701
+ response.setPayloadsList(payloads)
1585
1702
 
1586
- return callback(null, new grpcPuppet.TagContactRemoveResponse())
1703
+ return callback(null, response)
1704
+ } catch (e) {
1705
+ return grpcError('tagContactTagList', e, callback)
1706
+ }
1707
+ },
1708
+
1709
+ tagTagContactList: async (call, callback) => {
1710
+ log.verbose('PuppetServiceImpl', 'tagTagContactList()')
1711
+
1712
+ try {
1713
+ const tagGroupId = call.request.getTagGroupId()
1714
+ const tagId = call.request.getTagId()
1715
+
1716
+ const result = await puppet.tagTagContactList(tagGroupId, tagId)
1587
1717
 
1718
+ const response = new grpcPuppet.TagTagContactListResponse()
1719
+ response.setPayloadsList(result)
1720
+
1721
+ return callback(null, response)
1588
1722
  } catch (e) {
1589
- return grpcError('tagContactRemove', e, callback)
1723
+ return grpcError('tagTagContactList', e, callback)
1590
1724
  }
1591
1725
  },
1592
1726