import { Config } from '../../config' ; import { Reaction , ReactionCanHandleOptions , ReactionHandleOptions } from '../github/reaction' ; import { MergeRequestPayload } from '../../schemas/gitlab/merge-request-payload' ; export class MergeRequestOpened extends Reaction < MergeRequestPayload > { getStreamLabsMessage ( { payload } ) { return `*${ payload . user . username }* just opened a merge request in *${ payload . repository . name }*` ; } getTwitchChatMessage ( { payload } ) { return `${ payload . user . username } just opened a merge request in ${ payload . object_attributes . url }` ; } canHandle ( { payload , event , config } ) { return ( event === 'Merge Request Hook' && payload . object_attributes . state === 'opened' && this . isAllowedByConfig ( config , payload ) ) ; } private isAllowedByConfig ( config , payload ) { return ( ! config || ! config . IGNORE_PR_OPENED_BY . includes ( payload . user . username ) || config . IGNORE_PR_OPENED_BY . length === 0 ) ; } }