@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.
- package/actions/add-emoji-reaction/add-emoji-reaction.mjs +43 -0
- package/actions/add-star/add-star.mjs +1 -1
- package/actions/archive-channel/archive-channel.mjs +1 -1
- package/actions/complete-reminder/complete-reminder.mjs +1 -1
- package/actions/create-channel/create-channel.mjs +1 -1
- package/actions/create-reminder/create-reminder.mjs +1 -1
- package/actions/delete-file/delete-file.mjs +1 -1
- package/actions/delete-message/delete-message.mjs +1 -1
- package/actions/delete-reminder/delete-reminder.mjs +1 -1
- package/actions/find-message/find-message.mjs +4 -3
- package/actions/find-user-by-email/find-user-by-email.mjs +1 -1
- package/actions/get-channel/get-channel.mjs +1 -1
- package/actions/get-file/get-file.mjs +1 -1
- package/actions/get-reminder/get-reminder.mjs +1 -1
- package/actions/invite-user-to-channel/invite-user-to-channel.mjs +1 -2
- package/actions/join-channel/join-channel.mjs +1 -1
- package/actions/kick-user/kick-user.mjs +1 -1
- package/actions/leave-channel/leave-channel.mjs +1 -1
- package/actions/list-channels/list-channels.mjs +1 -1
- package/actions/list-files/list-files.mjs +1 -1
- package/actions/list-members-in-channel/list-members-in-channel.mjs +1 -1
- package/actions/list-reminders/list-reminders.mjs +1 -1
- package/actions/list-replies/list-replies.mjs +1 -1
- package/actions/list-user-groups-users/list-user-groups-users.mjs +1 -1
- package/actions/list-users/list-users.mjs +5 -3
- package/actions/remove-star/remove-star.mjs +1 -1
- package/actions/reply-to-a-message/reply-to-a-message.mjs +1 -1
- package/actions/send-block-kit-message/send-block-kit-message.mjs +1 -1
- package/actions/send-custom-message/send-custom-message.mjs +1 -1
- package/actions/send-direct-message/send-direct-message.mjs +1 -1
- package/actions/send-group-message/send-group-message.mjs +1 -1
- package/actions/send-large-message/send-large-message.mjs +1 -1
- package/actions/send-message-private-channel/send-message-private-channel.mjs +8 -2
- package/actions/send-message-public-channel/send-message-public-channel.mjs +8 -2
- package/actions/set-channel-purpose/set-channel-purpose.mjs +1 -1
- package/actions/set-channel-topic/set-channel-topic.mjs +1 -1
- package/actions/unarchive-channel/unarchive-channel.mjs +1 -1
- package/actions/update-message/update-message.mjs +1 -1
- package/actions/update-profile/update-profile.mjs +1 -1
- package/actions/update-user-groups-users/update-user-groups-users.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +1 -1
- package/actions/verify-slack-signature/verify-slack-signature.mjs +1 -1
- package/common/constants.mjs +15 -0
- package/package.json +1 -1
- package/slack.app.mjs +333 -158
- package/sources/common/constants.mjs +12 -1
- package/sources/new-direct-message/new-direct-message.mjs +1 -1
- package/sources/new-interaction-event-received/new-interaction-event-received.mjs +1 -1
- package/sources/new-mention/new-mention.mjs +34 -12
- package/sources/new-message-in-channels/new-message-in-channels.mjs +1 -1
- package/sources/new-reaction-added/new-reaction-added.mjs +1 -1
- 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.
|
|
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.
|
|
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(
|
|
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
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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
|
-
|
|
120
|
+
if (!constants.ALLOWED_SUBTYPES.includes(subtype)) {
|
|
121
|
+
console.log(`Ignoring message with subtype. "${subtype}"`);
|
|
102
122
|
return;
|
|
103
123
|
}
|
|
104
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|