serverless-slack
Advanced tools
Comparing version 1.0.15 to 1.0.16
{ | ||
"name": "serverless-slack", | ||
"description": "A Slack App Framework for AWS Lambda / Serverless.js", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"main": "src/index.js", | ||
@@ -6,0 +6,0 @@ "author": "John Agan <john@slack-corp.com>", |
@@ -31,4 +31,3 @@ 'use strict'; | ||
get response_url() { | ||
if (this.payload) | ||
return this.payload.response_url; | ||
if (this.payload) return this.payload.response_url; | ||
} | ||
@@ -43,6 +42,8 @@ | ||
get channel() { | ||
if (this.payload) { | ||
if (this.payload.channel_id) return this.payload.channel_id; | ||
else if (this.payload.channel) return this.payload.channel.id; | ||
else if (this.payload.event && this.payload.event.channel) return this.payload.event.channel; | ||
let payload = this.payload, event = payload.event; | ||
if (payload) { | ||
if (payload.channel_id) return payload.channel_id; | ||
else if (payload.channel) return payload.channel.id; | ||
else if (event && event.channel) return event.channel; | ||
else if (event && event.item) return event.item.channel; | ||
} | ||
@@ -58,4 +59,4 @@ } | ||
get token() { | ||
if (this.auth) | ||
return this.auth.bot ? this.auth.bot.bot_access_token : this.auth.access_token; | ||
let auth = this.auth, bot = auth.bot; | ||
if (auth) return auth.bot ? auth.bot.bot_access_token : auth.access_token; | ||
} | ||
@@ -72,9 +73,6 @@ | ||
reply(message, ephemeral) { | ||
if (this.response_url || ephemeral) { | ||
if (!this.response_url) | ||
return Promise.reject("Message can't be ephemeral"); | ||
if (!ephemeral) | ||
message.response_type = 'in_channel'; | ||
if (!this.response_url && ephemeral) { | ||
return Promise.reject("Message can't be ephemeral"); | ||
} else if (this.response_url) { | ||
if (!ephemeral) message.response_type = 'in_channel'; | ||
return this.send(this.response_url, message); | ||
@@ -109,8 +107,5 @@ } else { | ||
// set the bot or user token if unset | ||
if (!message.token && this.token) message.token = this.token; | ||
// set defaults when available | ||
message = Object.assign({ token: this.token, channel: this.channel }, message); | ||
// set the channel if unset | ||
if (!message.channel && this.channel) message.channel = this.channel; | ||
// convert json except when passing in a url | ||
@@ -117,0 +112,0 @@ if (!endPoint.match(/^http/i)) message = qs.stringify(message); |
9591
297