@activepieces/piece-slack 0.5.12 → 0.6.0
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/package.json +2 -2
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/lib/actions/add-reaction-to-message.js +1 -1
- package/src/lib/actions/add-reaction-to-message.js.map +1 -1
- package/src/lib/actions/create-channel.js +8 -22
- package/src/lib/actions/create-channel.js.map +1 -1
- package/src/lib/actions/find-user-by-email.js +9 -21
- package/src/lib/actions/find-user-by-email.js.map +1 -1
- package/src/lib/actions/get-channel-history.js +1 -1
- package/src/lib/actions/get-channel-history.js.map +1 -1
- package/src/lib/actions/request-action-direct-message.d.ts +1 -1
- package/src/lib/actions/request-action-message.js +1 -1
- package/src/lib/actions/request-action-message.js.map +1 -1
- package/src/lib/actions/request-approval-direct-message.d.ts +1 -1
- package/src/lib/actions/request-approval-message.js +1 -1
- package/src/lib/actions/request-approval-message.js.map +1 -1
- package/src/lib/actions/search-messages.js +23 -26
- package/src/lib/actions/search-messages.js.map +1 -1
- package/src/lib/actions/send-direct-message-action.d.ts +1 -1
- package/src/lib/actions/send-message-action.js +1 -1
- package/src/lib/actions/send-message-action.js.map +1 -1
- package/src/lib/actions/update-message.js +9 -21
- package/src/lib/actions/update-message.js.map +1 -1
- package/src/lib/actions/update-profile.js +13 -30
- package/src/lib/actions/update-profile.js.map +1 -1
- package/src/lib/actions/upload-file.js +6 -26
- package/src/lib/actions/upload-file.js.map +1 -1
- package/src/lib/common/props.d.ts +2 -2
- package/src/lib/common/props.js +59 -40
- package/src/lib/common/props.js.map +1 -1
- package/src/lib/common/request-action.d.ts +1 -5
- package/src/lib/common/utils.d.ts +1 -5
- package/src/lib/common/utils.js +19 -60
- package/src/lib/common/utils.js.map +1 -1
- package/src/lib/triggers/new-channel.d.ts +1 -1
- package/src/lib/triggers/new-channel.js +52 -58
- package/src/lib/triggers/new-channel.js.map +1 -1
- package/src/lib/triggers/new-message.js +14 -17
- package/src/lib/triggers/new-message.js.map +1 -1
- package/src/lib/triggers/new-reaction-added.d.ts +6 -3
- package/src/lib/triggers/new-reaction-added.js +36 -6
- package/src/lib/triggers/new-reaction-added.js.map +1 -1
package/src/lib/common/props.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.actions = exports.text = exports.userId = exports.blocks = exports.profilePicture = exports.username = exports.slackChannel = exports.slackInfo = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const
|
|
6
|
+
const web_api_1 = require("@slack/web-api");
|
|
7
7
|
exports.slackInfo = pieces_framework_1.Property.MarkDown({
|
|
8
8
|
value: `
|
|
9
9
|
Please make sure add the bot to the channel by following these steps:
|
|
@@ -11,13 +11,14 @@ exports.slackInfo = pieces_framework_1.Property.MarkDown({
|
|
|
11
11
|
2. Click on Add apps to this channel.
|
|
12
12
|
3. Search for and add the bot.`,
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
const slackChannel = (required) => pieces_framework_1.Property.Dropdown({
|
|
15
15
|
displayName: 'Channel',
|
|
16
16
|
description: 'Channel, private group, or IM channel to send message to.',
|
|
17
|
-
required
|
|
17
|
+
required,
|
|
18
18
|
refreshers: [],
|
|
19
19
|
options(_a) {
|
|
20
20
|
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
|
|
21
|
+
var _b, e_1, _c, _d;
|
|
21
22
|
if (!auth) {
|
|
22
23
|
return {
|
|
23
24
|
disabled: true,
|
|
@@ -27,26 +28,35 @@ exports.slackChannel = pieces_framework_1.Property.Dropdown({
|
|
|
27
28
|
}
|
|
28
29
|
const authentication = auth;
|
|
29
30
|
const accessToken = authentication['access_token'];
|
|
31
|
+
const client = new web_api_1.WebClient(accessToken);
|
|
30
32
|
const channels = [];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
try {
|
|
34
|
+
for (var _e = true, _f = tslib_1.__asyncValues(client.paginate('conversations.list', {
|
|
35
|
+
types: 'public_channel,private_channel',
|
|
36
|
+
exclude_archived: true,
|
|
37
|
+
// Only limits page size, not total number of results.
|
|
38
|
+
// We use a high number to avoid rate limiting and because Slack filters archived channels AFTER computing each page
|
|
39
|
+
// i.e. you can get many pages with only 10-50 results even though you're asking for 1000 per page
|
|
40
|
+
limit: 1000,
|
|
41
|
+
})), _g; _g = yield _f.next(), _b = _g.done, !_b; _e = true) {
|
|
42
|
+
_d = _g.value;
|
|
43
|
+
_e = false;
|
|
44
|
+
const page = _d;
|
|
45
|
+
const response = page;
|
|
46
|
+
if (response.channels) {
|
|
47
|
+
channels.push(...response.channels.map((channel) => {
|
|
48
|
+
return { label: channel.name || '', value: channel.id || '' };
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
54
|
+
finally {
|
|
55
|
+
try {
|
|
56
|
+
if (!_e && !_b && (_c = _f.return)) yield _c.call(_f);
|
|
57
|
+
}
|
|
58
|
+
finally { if (e_1) throw e_1.error; }
|
|
59
|
+
}
|
|
50
60
|
return {
|
|
51
61
|
disabled: false,
|
|
52
62
|
placeholder: 'Select channel',
|
|
@@ -55,6 +65,7 @@ exports.slackChannel = pieces_framework_1.Property.Dropdown({
|
|
|
55
65
|
});
|
|
56
66
|
},
|
|
57
67
|
});
|
|
68
|
+
exports.slackChannel = slackChannel;
|
|
58
69
|
exports.username = pieces_framework_1.Property.ShortText({
|
|
59
70
|
displayName: 'Username',
|
|
60
71
|
description: 'The username of the bot',
|
|
@@ -77,6 +88,7 @@ exports.userId = pieces_framework_1.Property.Dropdown({
|
|
|
77
88
|
refreshers: [],
|
|
78
89
|
options(_a) {
|
|
79
90
|
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
|
|
91
|
+
var _b, e_2, _c, _d;
|
|
80
92
|
if (!auth) {
|
|
81
93
|
return {
|
|
82
94
|
disabled: true,
|
|
@@ -85,25 +97,32 @@ exports.userId = pieces_framework_1.Property.Dropdown({
|
|
|
85
97
|
};
|
|
86
98
|
}
|
|
87
99
|
const accessToken = auth.access_token;
|
|
100
|
+
const client = new web_api_1.WebClient(accessToken);
|
|
88
101
|
const users = [];
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
try {
|
|
103
|
+
for (var _e = true, _f = tslib_1.__asyncValues(client.paginate('users.list', {
|
|
104
|
+
limit: 1000, // Only limits page size, not total number of results
|
|
105
|
+
})), _g; _g = yield _f.next(), _b = _g.done, !_b; _e = true) {
|
|
106
|
+
_d = _g.value;
|
|
107
|
+
_e = false;
|
|
108
|
+
const page = _d;
|
|
109
|
+
const response = page;
|
|
110
|
+
if (response.members) {
|
|
111
|
+
users.push(...response.members
|
|
112
|
+
.filter((member) => !member.deleted)
|
|
113
|
+
.map((member) => {
|
|
114
|
+
return { label: member.name || '', value: member.id || '' };
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
120
|
+
finally {
|
|
121
|
+
try {
|
|
122
|
+
if (!_e && !_b && (_c = _f.return)) yield _c.call(_f);
|
|
123
|
+
}
|
|
124
|
+
finally { if (e_2) throw e_2.error; }
|
|
125
|
+
}
|
|
107
126
|
return {
|
|
108
127
|
disabled: false,
|
|
109
128
|
placeholder: 'Select channel',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA+E;AAC/E
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA+E;AAC/E,4CAIwB;AAEX,QAAA,SAAS,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IACzC,KAAK,EAAE;;;;kCAIyB;CACjC,CAAC,CAAC;AACI,MAAM,YAAY,GAAG,CAAoB,QAAW,EAAE,EAAE,CAAC,2BAAQ,CAAC,QAAQ,CAAY;IAC3F,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,2DAA2D;IACxE,QAAQ;IACR,UAAU,EAAE,EAAE;IACR,OAAO;qEAAC,EAAE,IAAI,EAAE;;YACpB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,uBAAuB;oBACpC,OAAO,EAAE,EAAE;iBACZ,CAAC;YACJ,CAAC;YACD,MAAM,cAAc,GAAG,IAA2B,CAAC;YACnD,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,IAAI,mBAAS,CAAC,WAAW,CAAC,CAAC;YAC1C,MAAM,QAAQ,GAAuC,EAAE,CAAC;;gBACxD,KAAyB,eAAA,KAAA,sBAAA,MAAM,CAAC,QAAQ,CAAC,oBAAoB,EAAE;oBAC7D,KAAK,EAAE,gCAAgC;oBACvC,gBAAgB,EAAE,IAAI;oBACtB,sDAAsD;oBACtD,oHAAoH;oBACpH,kGAAkG;oBAClG,KAAK,EAAE,IAAI;iBACZ,CAAC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IACvC,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,2BAAQ,CAAC,KAAK,CAAC;IACpC,WAAW,EAAE,gBAAgB;IAC7B,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export declare const requestAction: (conversationId: string, context: any) => Promise<{
|
|
2
|
-
success: boolean;
|
|
3
|
-
request_body: any;
|
|
4
|
-
response_body: any;
|
|
5
|
-
} | {
|
|
1
|
+
export declare const requestAction: (conversationId: string, context: any) => Promise<import("@slack/web-api").WebAPICallResult | {
|
|
6
2
|
action: string;
|
|
7
3
|
}>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { ApFile } from '@activepieces/pieces-framework';
|
|
2
|
-
export declare const slackSendMessage: ({ text, conversationId, username, profilePicture, blocks, threadTs, token, file, }: SlackSendMessageParams) => Promise<
|
|
3
|
-
success: boolean;
|
|
4
|
-
request_body: any;
|
|
5
|
-
response_body: any;
|
|
6
|
-
}>;
|
|
2
|
+
export declare const slackSendMessage: ({ text, conversationId, username, profilePicture, blocks, threadTs, token, file, }: SlackSendMessageParams) => Promise<import("@slack/web-api").WebAPICallResult>;
|
|
7
3
|
type SlackSendMessageParams = {
|
|
8
4
|
token: string;
|
|
9
5
|
conversationId: string;
|
package/src/lib/common/utils.js
CHANGED
|
@@ -2,73 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processMessageTimestamp = exports.slackSendMessage = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const web_api_1 = require("@slack/web-api");
|
|
6
6
|
const slackSendMessage = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ text, conversationId, username, profilePicture, blocks, threadTs, token, file, }) {
|
|
7
|
-
|
|
8
|
-
let request;
|
|
7
|
+
const client = new web_api_1.WebClient(token);
|
|
9
8
|
if (file) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'Content-Type': 'multipart/form-data',
|
|
22
|
-
},
|
|
23
|
-
authentication: {
|
|
24
|
-
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
25
|
-
token,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
9
|
+
return yield client.files.uploadV2({
|
|
10
|
+
channel_id: conversationId,
|
|
11
|
+
initial_comment: text,
|
|
12
|
+
thread_ts: threadTs,
|
|
13
|
+
file_uploads: [
|
|
14
|
+
{
|
|
15
|
+
file: file.data,
|
|
16
|
+
filename: file.filename,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
});
|
|
29
20
|
}
|
|
30
21
|
else {
|
|
31
|
-
|
|
22
|
+
return yield client.chat.postMessage({
|
|
32
23
|
text,
|
|
33
24
|
channel: conversationId,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (blocks)
|
|
40
|
-
body['blocks'] = blocks;
|
|
41
|
-
if (threadTs)
|
|
42
|
-
body['thread_ts'] = threadTs;
|
|
43
|
-
request = {
|
|
44
|
-
method: pieces_common_1.HttpMethod.POST,
|
|
45
|
-
url: 'https://slack.com/api/chat.postMessage',
|
|
46
|
-
body,
|
|
47
|
-
authentication: {
|
|
48
|
-
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
49
|
-
token,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
25
|
+
username,
|
|
26
|
+
icon_url: profilePicture,
|
|
27
|
+
blocks: blocks,
|
|
28
|
+
thread_ts: threadTs,
|
|
29
|
+
});
|
|
53
30
|
}
|
|
54
|
-
if (!response.body.ok) {
|
|
55
|
-
switch (response.body.error) {
|
|
56
|
-
case 'not_in_channel':
|
|
57
|
-
throw new Error(JSON.stringify({
|
|
58
|
-
message: 'The bot is not in the channel',
|
|
59
|
-
code: 'not_in_channel',
|
|
60
|
-
action: 'Invite the bot from the channel settings',
|
|
61
|
-
}));
|
|
62
|
-
default: {
|
|
63
|
-
throw new Error(response.body.error);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
success: true,
|
|
69
|
-
request_body: request.body,
|
|
70
|
-
response_body: response.body,
|
|
71
|
-
};
|
|
72
31
|
});
|
|
73
32
|
exports.slackSendMessage = slackSendMessage;
|
|
74
33
|
function processMessageTimestamp(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/common/utils.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/common/utils.ts"],"names":[],"mappings":";;;;AACA,4CAAkD;AAE3C,MAAM,gBAAgB,GAAG,KASL,EAAE,oDATU,EACrC,IAAI,EACJ,cAAc,EACd,QAAQ,EACR,cAAc,EACd,MAAM,EACN,QAAQ,EACR,KAAK,EACL,IAAI,GACmB;IACvB,MAAM,MAAM,GAAG,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YACjC,UAAU,EAAE,cAAc;YAC1B,eAAe,EAAE,IAAI;YACrB,SAAS,EAAE,QAAQ;YACnB,YAAY,EAAE;gBACZ;oBACE,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACxB;aACF;SACF,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;YACnC,IAAI;YACJ,OAAO,EAAE,cAAc;YACvB,QAAQ;YACR,QAAQ,EAAE,cAAc;YACxB,MAAM,EAAE,MAAiB;YACzB,SAAS,EAAE,QAAQ;SACpB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAA,CAAC;AAlCW,QAAA,gBAAgB,oBAkC3B;AAaF,SAAgB,uBAAuB,CAAC,KAAa;IACnD,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,kBAAkB,CAAC;IACpC,8BAA8B;IAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,sDAAsD;IACtD,MAAM,cAAc,GAAG,kBAAkB,CAAC;IAC1C,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACnD,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAlBD,0DAkBC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const channelCreated: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}>;
|
|
@@ -1,70 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.channelCreated = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const __1 = require("../../");
|
|
6
|
-
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
types: 'public_channel,private_channel',
|
|
19
|
-
limit: '200',
|
|
20
|
-
cursor: cursor !== null && cursor !== void 0 ? cursor : '',
|
|
21
|
-
},
|
|
22
|
-
authentication: {
|
|
23
|
-
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
24
|
-
token: auth.access_token,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
28
|
-
channels.push(...response.body.channels);
|
|
29
|
-
cursor = response.body.response_metadata.next_cursor;
|
|
30
|
-
} while (cursor !== '' && channels.length < 600);
|
|
31
|
-
return channels.map((channel) => ({
|
|
32
|
-
epochMilliSeconds: channel.created * 1000,
|
|
33
|
-
data: channel,
|
|
34
|
-
}));
|
|
35
|
-
}),
|
|
6
|
+
const __1 = require("../../");
|
|
7
|
+
const web_api_1 = require("@slack/web-api");
|
|
8
|
+
const sampleData = {
|
|
9
|
+
type: 'channel_created',
|
|
10
|
+
channel: {
|
|
11
|
+
id: 'C024BE91L',
|
|
12
|
+
name: 'fun',
|
|
13
|
+
created: 1360782804,
|
|
14
|
+
creator: 'U024BE7LH',
|
|
15
|
+
},
|
|
36
16
|
};
|
|
37
|
-
exports.
|
|
17
|
+
exports.channelCreated = (0, pieces_framework_1.createTrigger)({
|
|
38
18
|
auth: __1.slackAuth,
|
|
39
|
-
name: '
|
|
40
|
-
displayName: '
|
|
41
|
-
description: 'Triggers when a
|
|
42
|
-
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
19
|
+
name: 'channel_created',
|
|
20
|
+
displayName: 'Channel created',
|
|
21
|
+
description: 'Triggers when a channel is created',
|
|
43
22
|
props: {},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return yield pieces_common_1.pollingHelper.onDisable(polling, { store, auth, propsValue });
|
|
23
|
+
type: pieces_framework_1.TriggerStrategy.APP_WEBHOOK,
|
|
24
|
+
sampleData: sampleData,
|
|
25
|
+
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
// Older OAuth2 has team_id, newer has team.id
|
|
28
|
+
const teamId = (_a = context.auth.data['team_id']) !== null && _a !== void 0 ? _a : context.auth.data['team']['id'];
|
|
29
|
+
context.app.createListeners({
|
|
30
|
+
events: ['channel_created'],
|
|
31
|
+
identifierValue: teamId,
|
|
54
32
|
});
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
}),
|
|
34
|
+
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
// Ignored
|
|
36
|
+
}),
|
|
37
|
+
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const client = new web_api_1.WebClient(context.auth.access_token);
|
|
39
|
+
const response = yield client.conversations.list({
|
|
40
|
+
exclude_archived: true,
|
|
41
|
+
limit: 10,
|
|
42
|
+
types: 'public_channel,private_channel',
|
|
60
43
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
44
|
+
if (!response.channels) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return response.channels.map((channel) => {
|
|
48
|
+
return {
|
|
49
|
+
type: 'channel_created',
|
|
50
|
+
channel: {
|
|
51
|
+
id: channel.id,
|
|
52
|
+
name: channel.name,
|
|
53
|
+
created: channel.created,
|
|
54
|
+
creator: channel.creator,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
66
57
|
});
|
|
67
|
-
},
|
|
68
|
-
|
|
58
|
+
}),
|
|
59
|
+
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const payloadBody = context.payload.body;
|
|
61
|
+
return [payloadBody.event];
|
|
62
|
+
}),
|
|
69
63
|
});
|
|
70
64
|
//# sourceMappingURL=new-channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-channel.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/triggers/new-channel.ts"],"names":[],"mappings":";;;;AAAA,8BAAmC;AACnC
|
|
1
|
+
{"version":3,"file":"new-channel.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/triggers/new-channel.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,8BAAmC;AACnC,4CAA2C;AAE3C,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE;QACP,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,WAAW;KACrB;CACF,CAAC;AAEW,QAAA,cAAc,GAAG,IAAA,gCAAa,EAAC;IAC1C,IAAI,EAAE,aAAS;IACf,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,oCAAoC;IACjD,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,kCAAe,CAAC,WAAW;IACjC,UAAU,EAAE,UAAU;IACtB,QAAQ,EAAE,CAAO,OAAO,EAAE,EAAE;;QAC1B,8CAA8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AC;IAC7B,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
6
|
const props_1 = require("../common/props");
|
|
7
7
|
const __1 = require("../../");
|
|
8
|
-
const
|
|
8
|
+
const web_api_1 = require("@slack/web-api");
|
|
9
9
|
const sampleData = {
|
|
10
10
|
client_msg_id: '2767cf34-0651-44e0-b9c8-1b167ce9b7a9',
|
|
11
11
|
type: 'message',
|
|
@@ -41,7 +41,7 @@ exports.newMessage = (0, pieces_framework_1.createTrigger)({
|
|
|
41
41
|
description: 'Triggers when a new message is received',
|
|
42
42
|
props: {
|
|
43
43
|
info: props_1.slackInfo,
|
|
44
|
-
channel: props_1.slackChannel,
|
|
44
|
+
channel: (0, props_1.slackChannel)(true),
|
|
45
45
|
},
|
|
46
46
|
type: pieces_framework_1.TriggerStrategy.APP_WEBHOOK,
|
|
47
47
|
sampleData: sampleData,
|
|
@@ -49,7 +49,7 @@ exports.newMessage = (0, pieces_framework_1.createTrigger)({
|
|
|
49
49
|
var _a;
|
|
50
50
|
// Older OAuth2 has team_id, newer has team.id
|
|
51
51
|
const teamId = (_a = context.auth.data['team_id']) !== null && _a !== void 0 ? _a : context.auth.data['team']['id'];
|
|
52
|
-
|
|
52
|
+
context.app.createListeners({
|
|
53
53
|
events: ['message'],
|
|
54
54
|
identifierValue: teamId,
|
|
55
55
|
});
|
|
@@ -58,20 +58,17 @@ exports.newMessage = (0, pieces_framework_1.createTrigger)({
|
|
|
58
58
|
// Ignored
|
|
59
59
|
}),
|
|
60
60
|
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
74
|
-
return response.body.messages.map((message) => (Object.assign(Object.assign({}, message), { channel: context.propsValue.channel, event_ts: '1678231735.586539', channel_type: 'channel' })));
|
|
61
|
+
const client = new web_api_1.WebClient(context.auth.access_token);
|
|
62
|
+
const response = yield client.conversations.history({
|
|
63
|
+
channel: context.propsValue.channel,
|
|
64
|
+
limit: 10,
|
|
65
|
+
});
|
|
66
|
+
if (!response.messages) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
return response.messages.map((message) => {
|
|
70
|
+
return Object.assign(Object.assign({}, message), { channel: context.propsValue.channel, event_ts: '1678231735.586539', channel_type: 'channel' });
|
|
71
|
+
});
|
|
75
72
|
}),
|
|
76
73
|
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
74
|
const payloadBody = context.payload.body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-message.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/triggers/new-message.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"new-message.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/triggers/new-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,2CAA0D;AAC1D,8BAAmC;AACnC,4CAA2C;AAE3C,MAAM,UAAU,GAAG;IACjB,aAAa,EAAE,sCAAsC;IACrD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,aAAa;IACnB,EAAE,EAAE,mBAAmB;IACvB,MAAM,EAAE;QACN;YACE,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,mBAAmB;oBACzB,QAAQ,EAAE;wBACR;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,GAAG;yBACV;qBACF;iBACF;aACF;SACF;KACF;IACD,IAAI,EAAE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AG,CAAC,CAAC,OAAO,EAAE,EAAE;YACvC,uCACK,OAAO,KACV,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,EACnC,QAAQ,EAAE,mBAAmB,EAC7B,YAAY,EAAE,SAAS,IACvB;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAA;IAED,GAAG,EAAE,CAAO,OAAO,EAAE,EAAE;QACrB,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,IAAmB,CAAC;QACxD,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAC7D,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
2
|
export declare const newReactionAdded: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
-
|
|
3
|
+
emojis: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
4
|
+
channel: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
|
|
4
5
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
5
|
-
|
|
6
|
+
emojis: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
7
|
+
channel: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
|
|
6
8
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
7
|
-
|
|
9
|
+
emojis: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
10
|
+
channel: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
|
|
8
11
|
}>;
|
|
@@ -4,6 +4,8 @@ exports.newReactionAdded = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
6
|
const __1 = require("../../");
|
|
7
|
+
const props_1 = require("../common/props");
|
|
8
|
+
const web_api_1 = require("@slack/web-api");
|
|
7
9
|
const sampleData = {
|
|
8
10
|
client_msg_id: '2767cf34-0651-44e0-b9c8-1b167ce9b7a9',
|
|
9
11
|
type: 'message',
|
|
@@ -38,11 +40,12 @@ exports.newReactionAdded = (0, pieces_framework_1.createTrigger)({
|
|
|
38
40
|
displayName: 'New Reaction',
|
|
39
41
|
description: 'Triggers when a new reaction is added to a message',
|
|
40
42
|
props: {
|
|
41
|
-
|
|
43
|
+
emojis: pieces_framework_1.Property.Array({
|
|
42
44
|
displayName: 'Emojis (E.g fire, smile)',
|
|
43
|
-
description: 'Select
|
|
45
|
+
description: 'Select emojis to trigger on',
|
|
44
46
|
required: false,
|
|
45
47
|
}),
|
|
48
|
+
channel: (0, props_1.slackChannel)(false),
|
|
46
49
|
},
|
|
47
50
|
type: pieces_framework_1.TriggerStrategy.APP_WEBHOOK,
|
|
48
51
|
sampleData: sampleData,
|
|
@@ -50,7 +53,7 @@ exports.newReactionAdded = (0, pieces_framework_1.createTrigger)({
|
|
|
50
53
|
var _a;
|
|
51
54
|
// Older OAuth2 has team_id, newer has team.id
|
|
52
55
|
const teamId = (_a = context.auth.data['team_id']) !== null && _a !== void 0 ? _a : context.auth.data['team']['id'];
|
|
53
|
-
|
|
56
|
+
context.app.createListeners({
|
|
54
57
|
events: ['reaction_added'],
|
|
55
58
|
identifierValue: teamId,
|
|
56
59
|
});
|
|
@@ -59,12 +62,39 @@ exports.newReactionAdded = (0, pieces_framework_1.createTrigger)({
|
|
|
59
62
|
// Ignored
|
|
60
63
|
}),
|
|
61
64
|
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
|
|
65
|
+
var _b;
|
|
66
|
+
const client = new web_api_1.WebClient((_b = context.auth.data['authed_user']) === null || _b === void 0 ? void 0 : _b.access_token);
|
|
67
|
+
const response = yield client.reactions.list({ limit: 10, full: true });
|
|
68
|
+
if (!response.items) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
return response.items
|
|
72
|
+
.filter((item) => item.type === 'message')
|
|
73
|
+
.map((item) => {
|
|
74
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
75
|
+
return {
|
|
76
|
+
type: 'reaction_added',
|
|
77
|
+
user: (_c = (_b = (_a = item.message) === null || _a === void 0 ? void 0 : _a.reactions) === null || _b === void 0 ? void 0 : _b[0].users) === null || _c === void 0 ? void 0 : _c[0],
|
|
78
|
+
reaction: (_e = (_d = item.message) === null || _d === void 0 ? void 0 : _d.reactions) === null || _e === void 0 ? void 0 : _e[0].name,
|
|
79
|
+
item_user: (_f = item.message) === null || _f === void 0 ? void 0 : _f.user,
|
|
80
|
+
item: {
|
|
81
|
+
type: 'message',
|
|
82
|
+
channel: item.channel,
|
|
83
|
+
ts: (_g = item.message) === null || _g === void 0 ? void 0 : _g.ts,
|
|
84
|
+
},
|
|
85
|
+
event_ts: '1360782804.083113',
|
|
86
|
+
};
|
|
87
|
+
});
|
|
63
88
|
}),
|
|
64
89
|
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
90
|
const payloadBody = context.payload.body;
|
|
66
|
-
if (context.propsValue.
|
|
67
|
-
if (context.propsValue.
|
|
91
|
+
if (context.propsValue.emojis) {
|
|
92
|
+
if (!context.propsValue.emojis.includes(payloadBody.event.reaction)) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (context.propsValue.channel) {
|
|
97
|
+
if (payloadBody.event.item['channel'] !== context.propsValue.channel) {
|
|
68
98
|
return [];
|
|
69
99
|
}
|
|
70
100
|
}
|