-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gitlab: events): add issue (#31)
- Loading branch information
1 parent
d1ef292
commit 8bfc74f
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const EventResponse = require('../EventResponse'); | ||
|
||
class Issue extends EventResponse { | ||
constructor(...args) { | ||
super(...args, { | ||
description: 'This event gets fired when a test issue event is executed', | ||
}); | ||
} | ||
|
||
embed(data) { | ||
const issue = data.object_attributes; | ||
|
||
return { | ||
color: 0xFFFc00, | ||
title: `Issue #${issue.iid}: ${issue.title}`, | ||
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`, | ||
}, { | ||
name: 'State', | ||
value: issue.state[0].toUpperCase() + issue.state.slice(1), | ||
inline: true, | ||
}, { | ||
name: 'Created At', | ||
value: new Date(issue.created_at).toGMTString(), | ||
inline: true, | ||
}, { | ||
name: 'Labels', | ||
value: data.labels && data.labels.length ? data.labels.map(l => `\`${l.title}\``).join(', ') : 'None', | ||
}], | ||
}; | ||
} | ||
|
||
text(data) { | ||
const { | ||
user: actor, | ||
object_attributes: issue, | ||
} = data; | ||
|
||
return [ | ||
`🤦♂️ **${actor.name}** tested an issue event, and issue **#${issue.iid}** was sent.`, | ||
`<${issue.url}>`, | ||
].join('\n'); | ||
} | ||
} | ||
|
||
module.exports = Issue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters