Skip to content

Commit

Permalink
Merge pull request #547 from 18F/mgwalker-patch-1
Browse files Browse the repository at this point in the history
Don't unfurl links in random responses
  • Loading branch information
mgwalker authored Sep 9, 2024
2 parents 7856e74 + bda0621 commit 55f5bea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/scripts/random-responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const responseFrom =
new RegExp(`(^|\\w)(-?)(\\S+) ${config.trigger}`, "i"),
) ?? [false, false, false, false];

const message = { thread_ts: thread };
const message = { thread_ts: thread, unfurl_links: false };
if (defaultEmoji) {
message.icon_emoji = defaultEmoji;
}
Expand Down
16 changes: 14 additions & 2 deletions src/scripts/random-responses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ describe("random responder", () => {
{
testName: "simple string response",
responseList: ["a message"],
expected: { text: "a message", thread_ts: "thread timestamp" },
expected: {
text: "a message",
thread_ts: "thread timestamp",
unfurl_links: false,
},
},
{
testName: "string with emoji",
Expand All @@ -47,12 +51,17 @@ describe("random responder", () => {
text: "b message",
thread_ts: "thread timestamp",
icon_emoji: ":emoji:",
unfurl_links: false,
},
},
{
testName: "message object with no name or emoji",
responseList: [{ text: "c message" }],
expected: { text: "c message", thread_ts: "thread timestamp" },
expected: {
text: "c message",
thread_ts: "thread timestamp",
unfurl_links: false,
},
},
{
testName: "message object with no name",
Expand All @@ -61,6 +70,7 @@ describe("random responder", () => {
text: "d message",
thread_ts: "thread timestamp",
icon_emoji: ":emoji:",
unfurl_links: false,
},
},
{
Expand All @@ -70,6 +80,7 @@ describe("random responder", () => {
text: "e message",
thread_ts: "thread timestamp",
username: "bob",
unfurl_links: false,
},
},
{
Expand All @@ -80,6 +91,7 @@ describe("random responder", () => {
thread_ts: "thread timestamp",
icon_emoji: ":emoji:",
username: "bob",
unfurl_links: false,
},
},
];
Expand Down

0 comments on commit 55f5bea

Please sign in to comment.