Skip to content

Commit

Permalink
fix(gitlab): move embed description limit into handler parser
Browse files Browse the repository at this point in the history
fix way too long descriptions (over 2048 chars)
  • Loading branch information
dsevillamartin committed Jun 17, 2018
1 parent 8bfc74f commit e5e7155
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/Gitlab/EventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class Events {
};
embed.url = embed.url || (data.object_attributes && data.object_attributes.url) || data.project.web_url;
embed.timestamp = new Date();

embed.description = embed.description.slice(0, 1000) + (embed.description.length > 1000 ? '...' : '');

return embed;
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Gitlab/Events/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class Issue extends EventResponse {
description: 'A test issue event was fired from the GitLab integrations page',
fields: [{
name: 'Description',
value: `${issue.description.split('\n').slice(0, 4).join('\n').slice(0, 2000)}\n\u200B`,
value: `${issue.description.split('\n').slice(0, 4).join('\n')
.slice(0, 2000)}\n\u200B`,
}, {
name: 'State',
value: issue.state[0].toUpperCase() + issue.state.slice(1),
Expand Down
4 changes: 2 additions & 2 deletions lib/Gitlab/Events/tag_push.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TagPush extends EventResponse {
color: 0xF0C330,
title: `${this.isCreated(data) ? 'Created' : 'Deleted'} tag \`${tag}\` ${sha ? `from commit \`${sha}\`` : ''}${isCreated ? ` with ${commitCount} ${commitCount !== 1 ? 'commits' : 'commit'}` : ''}`,
url: isCreated ? `${data.project.web_url}/tags/${tag}` : null,
description: `${message.slice(0, 2000)}${message.length > 2000 ? '...' : ''}`,
description: message,
};
}

Expand All @@ -32,7 +32,7 @@ class TagPush extends EventResponse {

return [
`⚡ **${actor}** ${isCreated ? 'created' : 'deleted'} tag \`${tag}\` ${sha ? `from commit \`${sha}\`` : ''}${isCreated ? `with ${commitCount} ${commitCount !== 1 ? 'commits' : 'commit'}` : ''}`,
` ${message.slice(0, 200)}${message.length > 200 ? '...' : ''}`, ` `,
` ${message.split('\n')[0]}`, ` `,
`${isCreated ? `<${data.project.web_url}/tags/${tag}>` : ''}`,
].filter(e => e !== '').join('\n');
}
Expand Down

0 comments on commit e5e7155

Please sign in to comment.