2016-11-16 12:28:38 -05:00
|
|
|
module Gitlab
|
|
|
|
module ChatCommands
|
|
|
|
class BaseCommand
|
|
|
|
QUERY_LIMIT = 5
|
|
|
|
|
2016-11-18 05:38:54 -05:00
|
|
|
def self.match(_text)
|
2016-11-16 12:28:38 -05:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.help_message
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2016-11-18 05:38:54 -05:00
|
|
|
def self.available?(_project)
|
2016-11-16 12:28:38 -05:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2016-11-18 05:38:54 -05:00
|
|
|
def self.allowed?(_user, _ability)
|
2016-11-17 15:27:12 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.can?(object, action, subject)
|
|
|
|
Ability.allowed?(object, action, subject)
|
|
|
|
end
|
|
|
|
|
2016-11-16 12:28:38 -05:00
|
|
|
def execute(_)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def collection
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
attr_accessor :project, :current_user, :params
|
|
|
|
|
|
|
|
def initialize(project, user, params = {})
|
|
|
|
@project, @current_user, @params = project, user, params.dup
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def find_by_iid(iid)
|
2016-11-25 09:41:28 -05:00
|
|
|
collection.find_by(iid: iid)
|
2016-11-16 12:28:38 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|