Skip to content

Commit

Permalink
feat(gitlab: events): add note/snippet - fired when someone comments …
Browse files Browse the repository at this point in the history
…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
dsevillamartin committed Apr 15, 2017
1 parent 13fcf70 commit 692178b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/Gitlab/Events/note-snippet.js
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;

0 comments on commit 692178b

Please sign in to comment.