-
-
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 note/snippet - fired when someone comments …
…on snippet I don't think it will (or should) ever be fired, as there is no such thing as a snippet on a repo...
- Loading branch information
1 parent
13fcf70
commit 692178b
Showing
1 changed file
with
32 additions
and
0 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,32 @@ | ||
const EventResponse = require('../EventResponse'); | ||
|
||
class NoteSnippet extends EventResponse { | ||
constructor(...args) { | ||
super(...args, { | ||
description: 'This event gets fired when someone comments on a code snippet', | ||
}); | ||
} | ||
|
||
embed(data) { | ||
const comment = data.object_attributes; | ||
const snippet = data.snippet; | ||
return { | ||
color: `#996633`, | ||
title: `Commented on snippet \`${snippet.title}\``, | ||
description: comment.note, | ||
}; | ||
} | ||
|
||
text(data) { | ||
const actor = data.user.name; | ||
const comment = data.object_attributes; | ||
const snippet = data.snippet; | ||
return [ | ||
`**${actor}** commented on snippet **#${snippet.title}**`, | ||
` ${comment.note.slice(0, 100).replace(/\n/g, '\n ')}`, | ||
`${comment.url}`, | ||
].join('\n'); | ||
} | ||
} | ||
|
||
module.exports = NoteSnippet; |