Merge pull request #290 from BrunoMoreira991/indev

Fix use of Array as String Resolvable on sendFile with content
This commit is contained in:
abalabahaha
2016-04-22 17:52:22 -07:00
2 changed files with 13 additions and 9 deletions

View File

@@ -752,10 +752,12 @@ var InternalClient = (function () {
} }
return this.resolver.resolveChannel(where).then(function (destination) { return this.resolver.resolveChannel(where).then(function (destination) {
var content = _this16.resolver.resolveString(_content);
if (options.file) { if (options.file) {
return _this16.resolver.resolveFile(options.file.file).then(function (file) { return _this16.resolver.resolveFile(options.file.file).then(function (file) {
return _this16.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, { return _this16.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, {
content: _content, content: content,
tts: options.tts tts: options.tts
}, { }, {
name: options.file.name, name: options.file.name,
@@ -765,8 +767,6 @@ var InternalClient = (function () {
}); });
}); });
} else { } else {
var content = _this16.resolver.resolveString(_content);
return _this16.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, { return _this16.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, {
content: content, content: content,
tts: options.tts tts: options.tts
@@ -779,7 +779,7 @@ var InternalClient = (function () {
// def sendFile // def sendFile
InternalClient.prototype.sendFile = function sendFile(where, _file, name, content) { InternalClient.prototype.sendFile = function sendFile(where, _file, name, _content) {
var _this17 = this; var _this17 = this;
if (!name) { if (!name) {
@@ -793,6 +793,8 @@ var InternalClient = (function () {
} }
} }
var content = this.resolver.resolveString(_content);
if (content) { if (content) {
content = { content = {
content: content content: content

View File

@@ -617,11 +617,13 @@ export default class InternalClient {
return this.resolver.resolveChannel(where) return this.resolver.resolveChannel(where)
.then(destination => { .then(destination => {
var content = this.resolver.resolveString(_content);
if (options.file) { if (options.file) {
return this.resolver.resolveFile(options.file.file) return this.resolver.resolveFile(options.file.file)
.then(file => .then(file =>
this.apiRequest("post", Endpoints.CHANNEL_MESSAGES(destination.id), true, { this.apiRequest("post", Endpoints.CHANNEL_MESSAGES(destination.id), true, {
content: _content, content: content,
tts: options.tts tts: options.tts
}, { }, {
name: options.file.name, name: options.file.name,
@@ -629,8 +631,6 @@ export default class InternalClient {
}).then(res => destination.messages.add(new Message(res, destination, this.client))) }).then(res => destination.messages.add(new Message(res, destination, this.client)))
) )
} else { } else {
var content = this.resolver.resolveString(_content);
return this.apiRequest("post", Endpoints.CHANNEL_MESSAGES(destination.id), true, { return this.apiRequest("post", Endpoints.CHANNEL_MESSAGES(destination.id), true, {
content: content, content: content,
tts: options.tts tts: options.tts
@@ -642,7 +642,7 @@ export default class InternalClient {
} }
// def sendFile // def sendFile
sendFile(where, _file, name, content) { sendFile(where, _file, name, _content) {
if (!name) { if (!name) {
if (_file instanceof String || typeof _file === "string") { if (_file instanceof String || typeof _file === "string") {
name = require("path").basename(_file); name = require("path").basename(_file);
@@ -654,6 +654,8 @@ export default class InternalClient {
} }
} }
var content = this.resolver.resolveString(_content);
if(content) { if(content) {
content = { content = {
content content