diff --git a/package-lock.json b/package-lock.json index 7a24bd3..b0cee4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -263,9 +263,9 @@ "integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==" }, "@types/node": { - "version": "12.7.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.4.tgz", - "integrity": "sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ==" + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.0.tgz", + "integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==" }, "@types/p-queue": { "version": "2.3.2", diff --git a/package.json b/package.json index 86ffbd3..37b0aee 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@slack/web-api": "^5.2.1", "@types/dotenv": "^6.1.1", "@types/express": "^4.17.1", + "@types/node": "^13.7.0", "@types/qs": "^6.5.3", "body-parser": "^1.19.0", "dotenv": "^8.2.0", diff --git a/src/Actions.ts b/src/Actions.ts index d2dc70a..bcf8059 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -34,6 +34,8 @@ export class Actions { public onButtonAction(payload: any, res: (message: any) => Promise): { text: string } { try { const poll = new Poll(payload.message.blocks); + payload.actions[0].text.text = payload.actions[0].text.text.replace("<","<") + .replace(">",">").replace("&","&"); poll.vote(payload.actions[0].text.text, payload.user.id); payload.message.blocks = poll.getBlocks(); payload.message.text = "Vote changed!"; diff --git a/src/Poll.ts b/src/Poll.ts index 6902995..b0c111f 100644 --- a/src/Poll.ts +++ b/src/Poll.ts @@ -44,9 +44,6 @@ export class Poll { actionBlocks.push(newActionBlock); actionBlockCount++; } - // Remove special characters, should be able to remove this once slack figures itself out - parameters[i] = parameters[i].replace("&", "+").replace(">", "greater than ") - .replace("<", "less than "); // We set value to empty string so that it is always defined const button: Button = { type: "button", value: " ", text: PollHelpers.buildTextElem(parameters[i]) }; actionBlocks[actionBlockCount].elements.push(button); @@ -149,6 +146,8 @@ export class Poll { for (let j = 0; j < currentBlock.elements.length; j++) { if (currentBlock.elements[j].type !== "button") continue; const button = currentBlock.elements[j] as Button; + button.text.text = button.text.text.replace("<","<") + .replace(">",">").replace("&","&"); if (buttonCallback(button)) break; } } @@ -194,4 +193,4 @@ export class Poll { } return -1; } -} \ No newline at end of file +}