@pipedream/slack 0.4.11 → 0.4.13

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 (52) hide show
  1. package/actions/add-emoji-reaction/add-emoji-reaction.mjs +43 -0
  2. package/actions/add-star/add-star.mjs +1 -1
  3. package/actions/archive-channel/archive-channel.mjs +1 -1
  4. package/actions/complete-reminder/complete-reminder.mjs +1 -1
  5. package/actions/create-channel/create-channel.mjs +1 -1
  6. package/actions/create-reminder/create-reminder.mjs +1 -1
  7. package/actions/delete-file/delete-file.mjs +1 -1
  8. package/actions/delete-message/delete-message.mjs +1 -1
  9. package/actions/delete-reminder/delete-reminder.mjs +1 -1
  10. package/actions/find-message/find-message.mjs +4 -3
  11. package/actions/find-user-by-email/find-user-by-email.mjs +1 -1
  12. package/actions/get-channel/get-channel.mjs +1 -1
  13. package/actions/get-file/get-file.mjs +1 -1
  14. package/actions/get-reminder/get-reminder.mjs +1 -1
  15. package/actions/invite-user-to-channel/invite-user-to-channel.mjs +1 -2
  16. package/actions/join-channel/join-channel.mjs +1 -1
  17. package/actions/kick-user/kick-user.mjs +1 -1
  18. package/actions/leave-channel/leave-channel.mjs +1 -1
  19. package/actions/list-channels/list-channels.mjs +1 -1
  20. package/actions/list-files/list-files.mjs +1 -1
  21. package/actions/list-members-in-channel/list-members-in-channel.mjs +1 -1
  22. package/actions/list-reminders/list-reminders.mjs +1 -1
  23. package/actions/list-replies/list-replies.mjs +1 -1
  24. package/actions/list-user-groups-users/list-user-groups-users.mjs +1 -1
  25. package/actions/list-users/list-users.mjs +5 -3
  26. package/actions/remove-star/remove-star.mjs +1 -1
  27. package/actions/reply-to-a-message/reply-to-a-message.mjs +1 -1
  28. package/actions/send-block-kit-message/send-block-kit-message.mjs +1 -1
  29. package/actions/send-custom-message/send-custom-message.mjs +1 -1
  30. package/actions/send-direct-message/send-direct-message.mjs +1 -1
  31. package/actions/send-group-message/send-group-message.mjs +1 -1
  32. package/actions/send-large-message/send-large-message.mjs +1 -1
  33. package/actions/send-message-private-channel/send-message-private-channel.mjs +8 -2
  34. package/actions/send-message-public-channel/send-message-public-channel.mjs +8 -2
  35. package/actions/set-channel-purpose/set-channel-purpose.mjs +1 -1
  36. package/actions/set-channel-topic/set-channel-topic.mjs +1 -1
  37. package/actions/unarchive-channel/unarchive-channel.mjs +1 -1
  38. package/actions/update-message/update-message.mjs +1 -1
  39. package/actions/update-profile/update-profile.mjs +1 -1
  40. package/actions/update-user-groups-users/update-user-groups-users.mjs +1 -1
  41. package/actions/upload-file/upload-file.mjs +1 -1
  42. package/actions/verify-slack-signature/verify-slack-signature.mjs +1 -1
  43. package/common/constants.mjs +15 -0
  44. package/package.json +1 -1
  45. package/slack.app.mjs +333 -158
  46. package/sources/common/constants.mjs +12 -1
  47. package/sources/new-direct-message/new-direct-message.mjs +1 -1
  48. package/sources/new-interaction-event-received/new-interaction-event-received.mjs +1 -1
  49. package/sources/new-mention/new-mention.mjs +34 -12
  50. package/sources/new-message-in-channels/new-message-in-channels.mjs +1 -1
  51. package/sources/new-reaction-added/new-reaction-added.mjs +1 -1
  52. package/sources/new-star-added/new-star-added.mjs +4 -7
@@ -1,10 +1,11 @@
1
1
  import common from "../common/base.mjs";
2
+ import constants from "../common/constants.mjs";
2
3
 
3
4
  export default {
4
5
  ...common,
5
6
  key: "slack-new-mention",
6
7
  name: "New Mention (Instant)",
7
- version: "1.0.6",
8
+ version: "1.0.8",
8
9
  description: "Emit new event when a username or specific keyword is mentioned in a channel",
9
10
  type: "source",
10
11
  dedupe: "unique",
@@ -66,11 +67,14 @@ export default {
66
67
  methods: {
67
68
  ...common.methods,
68
69
  async getMatches(params) {
69
- return (await this.slack.sdk().search.messages(params)).messages.matches || [];
70
+ return (await this.slack.searchMessages(params)).messages.matches || [];
70
71
  },
71
72
  async emitHistoricalEvents(messages) {
72
73
  for (const message of messages) {
73
- const event = await this.processEvent(message);
74
+ const event = await this.processEvent({
75
+ ...message,
76
+ subtype: message.subtype || constants.SUBTYPE.PD_HISTORY_MESSAGE,
77
+ });
74
78
  if (event) {
75
79
  if (!event.client_msg_id) {
76
80
  event.pipedream_msg_id = `pd_${Date.now()}_${Math.random().toString(36)
@@ -89,24 +93,40 @@ export default {
89
93
  return "New mention received";
90
94
  },
91
95
  async processEvent(event) {
92
- if (event.type !== "message") {
93
- console.log(`Ignoring event with unexpected type "${event.type}"`);
96
+ const {
97
+ type: msgType,
98
+ subtype,
99
+ bot_id: botId,
100
+ text,
101
+ blocks = [],
102
+ } = event;
103
+ const [
104
+ {
105
+ elements: [
106
+ { elements = [] } = {},
107
+ ] = [],
108
+ } = {},
109
+ ] = blocks;
110
+
111
+ if (msgType !== "message") {
112
+ console.log(`Ignoring event with unexpected type "${msgType}"`);
94
113
  return;
95
114
  }
96
- if (event.subtype != null && event.subtype != "bot_message" && event.subtype != "file_share") {
115
+
97
116
  // This source is designed to just emit an event for each new message received.
98
117
  // Due to inconsistencies with the shape of message_changed and message_deleted
99
118
  // events, we are ignoring them for now. If you want to handle these types of
100
119
  // events, feel free to change this code!!
101
- console.log("Ignoring message with subtype.");
120
+ if (!constants.ALLOWED_SUBTYPES.includes(subtype)) {
121
+ console.log(`Ignoring message with subtype. "${subtype}"`);
102
122
  return;
103
123
  }
104
- if ((this.ignoreBot) && (event.subtype == "bot_message" || event.bot_id)) {
124
+
125
+ if ((this.ignoreBot) && (subtype === constants.SUBTYPE.BOT_MESSAGE || botId)) {
105
126
  return;
106
127
  }
107
- let emitEvent = false;
108
- const elements = event.blocks[0]?.elements[0]?.elements;
109
128
 
129
+ let emitEvent = false;
110
130
  if (this.isUsername && elements) {
111
131
  for (const item of elements) {
112
132
  if (item.user_id) {
@@ -117,10 +137,12 @@ export default {
117
137
  }
118
138
  }
119
139
  }
120
-
121
- } else if (event.text.indexOf(this.keyword) !== -1) {
140
+ } else if (text.indexOf(this.keyword) !== -1) {
141
+ emitEvent = true;
142
+ } else if (subtype === constants.SUBTYPE.PD_HISTORY_MESSAGE) {
122
143
  emitEvent = true;
123
144
  }
145
+
124
146
  if (emitEvent) {
125
147
  return event;
126
148
  }
@@ -4,7 +4,7 @@ export default {
4
4
  ...common,
5
5
  key: "slack-new-message-in-channels",
6
6
  name: "New Message In Channels (Instant)",
7
- version: "1.0.5",
7
+ version: "1.0.6",
8
8
  description: "Emit new event when a new message is posted to one or more channels",
9
9
  type: "source",
10
10
  dedupe: "unique",
@@ -4,7 +4,7 @@ export default {
4
4
  ...common,
5
5
  key: "slack-new-reaction-added",
6
6
  name: "New Reaction Added (Instant)",
7
- version: "1.1.6",
7
+ version: "1.1.7",
8
8
  description: "Emit new event when a member has added an emoji reaction to an item",
9
9
  type: "source",
10
10
  dedupe: "unique",
@@ -1,14 +1,11 @@
1
1
  import common from "../common/base.mjs";
2
- import {
3
- events,
4
- eventsOptions,
5
- } from "../common/constants.mjs";
2
+ import constants from "../common/constants.mjs";
6
3
 
7
4
  export default {
8
5
  ...common,
9
6
  key: "slack-new-star-added",
10
7
  name: "New Star Added (Instant)",
11
- version: "0.0.9",
8
+ version: "0.0.11",
12
9
  description: "Emit new event when a star is added to an item",
13
10
  type: "source",
14
11
  dedupe: "unique",
@@ -28,14 +25,14 @@ export default {
28
25
  type: "string[]",
29
26
  label: "Event Types",
30
27
  description: "The types of event to emit. If not specified, all events will be emitted.",
31
- options: eventsOptions,
28
+ options: constants.eventsOptions,
32
29
  optional: true,
33
30
  },
34
31
  },
35
32
  methods: {
36
33
  ...common.methods,
37
34
  getSummary({ item: { type } }) {
38
- return `New star added - ${events[type] ?? type}`;
35
+ return `New star added - ${constants.events[type] ?? type}`;
39
36
  },
40
37
  async processEvent(event) {
41
38
  if (this.eventTypes == null