-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1145 from simlu/dev
feat: added channel.shareFiles and self.shareFiles
- Loading branch information
Showing
9 changed files
with
108 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
const getSelf = require('./util/get-self'); | ||
|
||
module.exports = (call) => ({ | ||
message: async (msg) => { | ||
const rtmStart = await call('rtm.start', {}, true); | ||
const user = rtmStart.self; | ||
const self = await getSelf(call); | ||
return call('chat.command', { | ||
disp: '/me', | ||
command: '/msg', | ||
text: `${user.name} ${msg}`, | ||
channel: rtmStart.ims.find((im) => im.user === user.id).id | ||
text: `${self.name} ${msg}`, | ||
channel: self.channel | ||
}); | ||
}, | ||
shareFiles: async (files) => { | ||
const self = await getSelf(call); | ||
return call('files.share', { | ||
files: files.join(','), | ||
channel: self.channel | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = async (call) => { | ||
const rtmStart = await call('rtm.start', {}, true); | ||
const user = rtmStart.self; | ||
return { | ||
id: user.id, | ||
name: user.name, | ||
channel: rtmStart.ims.find((im) => im.user === user.id).id | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../index/channel.spec.js__cassettes/testingSlackSDK_testingChannelShareFiles_recording.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[ | ||
{ | ||
"scope": "https://workspace.slack.com:443", | ||
"method": "POST", | ||
"path": "/api/rtm.start", | ||
"body": "----------------------------240931670220439824763760\r\nContent-Disposition: form-data; name=\"token\"\r\n\r\nSLACK-SESSION-TOKEN\r\n----------------------------240931670220439824763760--\r\n", | ||
"status": 200, | ||
"response": { | ||
"ok": true, | ||
"channels": [ | ||
{ | ||
"id": "C3Y9NQTQG", | ||
"name": "channel" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"scope": "https://workspace.slack.com:443", | ||
"method": "POST", | ||
"path": "/api/files.share", | ||
"body": "----------------------------898525272439246643720391\r\nContent-Disposition: form-data; name=\"token\"\r\n\r\nSLACK-SESSION-TOKEN\r\n----------------------------898525272439246643720391\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\nF029QHN0AAZ,F02AH8J752L\r\n----------------------------898525272439246643720391\r\nContent-Disposition: form-data; name=\"channel\"\r\n\r\nC3Y9NQTQG\r\n----------------------------898525272439246643720391--\r\n", | ||
"status": 200, | ||
"response": { | ||
"ok": true | ||
}, | ||
"responseIsBinary": false | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/index/self.spec.js__cassettes/testingSlackSDK_testingSelfShareFiles_recording.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[ | ||
{ | ||
"scope": "https://workspace.slack.com:443", | ||
"method": "POST", | ||
"path": "/api/rtm.start", | ||
"body": "----------------------------004906267591311878777087\r\nContent-Disposition: form-data; name=\"token\"\r\n\r\nSLACK-SESSION-TOKEN\r\n----------------------------004906267591311878777087--\r\n", | ||
"status": 200, | ||
"response": { | ||
"ok": true, | ||
"self": { | ||
"id": "U0G9QF9C6", | ||
"name": "user.name" | ||
}, | ||
"ims": [ | ||
{ | ||
"id": "D19NX2Y3Z", | ||
"user": "U0G9QF9C6" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"scope": "https://workspace.slack.com:443", | ||
"method": "POST", | ||
"path": "/api/files.share", | ||
"body": "----------------------------253285144519931620775601\r\nContent-Disposition: form-data; name=\"token\"\r\n\r\nSLACK-SESSION-TOKEN\r\n----------------------------253285144519931620775601\r\nContent-Disposition: form-data; name=\"files\"\r\n\r\nF029QHN0AAZ,F02AH8J752L\r\n----------------------------253285144519931620775601\r\nContent-Disposition: form-data; name=\"channel\"\r\n\r\nD19NX2Y3Z\r\n----------------------------253285144519931620775601--\r\n", | ||
"status": 200, | ||
"response": { | ||
"ok": true | ||
}, | ||
"responseIsBinary": false | ||
} | ||
] |