Skip to content

Commit

Permalink
Merge pull request #4392 from coralproject/fix/CORL-2944-truncate-lon…
Browse files Browse the repository at this point in the history
…g-comments-slack-integration

[CORL-2944]: truncate comment body sent to slack to stay under char limits
  • Loading branch information
kabeaty authored Dec 6, 2023
2 parents c8c935b + cdb1824 commit 1ef41da
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/src/core/server/events/listeners/slack/publishEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ export default class SlackPublishEvent {
);
const commentLink = getURLWithCommentID(this.story.url, this.comment.id);

const body = getHTMLPlainText(getLatestRevision(this.comment).body);
// We truncate to less than 3000 characters to stay under Slack limits
const truncatedBody = getHTMLPlainText(
getLatestRevision(this.comment).body
).slice(0, 2999);
return {
text: body,
text: truncatedBody,
blocks: [
{
type: "section",
Expand All @@ -121,7 +124,7 @@ export default class SlackPublishEvent {
block_id: "body-block",
text: {
type: "plain_text",
text: body,
text: truncatedBody,
},
},
{
Expand Down

0 comments on commit 1ef41da

Please sign in to comment.