@juzi/wechaty-puppet-service 1.0.14 → 1.0.18

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