[MM-47542] Extend Plugin API (#21446)
* Extend Plugin API * Use Error, NoError in tests * Address suggestions * Simplify code * Add new line * Add featureflag and GetCollectionMetadataByIds hook * Add enter at the end of file * make build-templates * Fix test * Fix GetCollectionMetadataByIds ret type * Add GetTopicMetadataByIds hook * Add log * Extract i18n * Add experimental notice on hooks * Update model/feature_flags.go * Swap user to userId * Change userId to userID Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cc69c917f2
Коммит
b8da473da7
@@ -2941,6 +2941,20 @@ func (_m *API) ReadFile(path string) ([]byte, *model.AppError) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// RegisterCollectionAndTopic provides a mock function with given fields: collectionType, topicType
|
||||
func (_m *API) RegisterCollectionAndTopic(collectionType string, topicType string) error {
|
||||
ret := _m.Called(collectionType, topicType)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(collectionType, topicType)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// RegisterCommand provides a mock function with given fields: command
|
||||
func (_m *API) RegisterCommand(command *model.Command) error {
|
||||
ret := _m.Called(command)
|
||||
|
||||
@@ -73,6 +73,119 @@ func (_m *Hooks) FileWillBeUploaded(c *plugin.Context, info *model.FileInfo, fil
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetAllCollectionIDsForUser provides a mock function with given fields: c, userID, collectionType
|
||||
func (_m *Hooks) GetAllCollectionIDsForUser(c *plugin.Context, userID string, collectionType string) ([]string, error) {
|
||||
ret := _m.Called(c, userID, collectionType)
|
||||
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func(*plugin.Context, string, string) []string); ok {
|
||||
r0 = rf(c, userID, collectionType)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*plugin.Context, string, string) error); ok {
|
||||
r1 = rf(c, userID, collectionType)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetAllUserIdsForCollection provides a mock function with given fields: c, collectionType, collectionID
|
||||
func (_m *Hooks) GetAllUserIdsForCollection(c *plugin.Context, collectionType string, collectionID string) ([]string, error) {
|
||||
ret := _m.Called(c, collectionType, collectionID)
|
||||
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func(*plugin.Context, string, string) []string); ok {
|
||||
r0 = rf(c, collectionType, collectionID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*plugin.Context, string, string) error); ok {
|
||||
r1 = rf(c, collectionType, collectionID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetCollectionMetadataByIds provides a mock function with given fields: c, collectionType, collectionIds
|
||||
func (_m *Hooks) GetCollectionMetadataByIds(c *plugin.Context, collectionType string, collectionIds []string) (map[string]*model.CollectionMetadata, error) {
|
||||
ret := _m.Called(c, collectionType, collectionIds)
|
||||
|
||||
var r0 map[string]*model.CollectionMetadata
|
||||
if rf, ok := ret.Get(0).(func(*plugin.Context, string, []string) map[string]*model.CollectionMetadata); ok {
|
||||
r0 = rf(c, collectionType, collectionIds)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(map[string]*model.CollectionMetadata)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*plugin.Context, string, []string) error); ok {
|
||||
r1 = rf(c, collectionType, collectionIds)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetTopicMetadataByIds provides a mock function with given fields: c, topicType, topicIds
|
||||
func (_m *Hooks) GetTopicMetadataByIds(c *plugin.Context, topicType string, topicIds []string) (map[string]*model.TopicMetadata, error) {
|
||||
ret := _m.Called(c, topicType, topicIds)
|
||||
|
||||
var r0 map[string]*model.TopicMetadata
|
||||
if rf, ok := ret.Get(0).(func(*plugin.Context, string, []string) map[string]*model.TopicMetadata); ok {
|
||||
r0 = rf(c, topicType, topicIds)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(map[string]*model.TopicMetadata)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*plugin.Context, string, []string) error); ok {
|
||||
r1 = rf(c, topicType, topicIds)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetTopicRedirect provides a mock function with given fields: c, topicType, topicID
|
||||
func (_m *Hooks) GetTopicRedirect(c *plugin.Context, topicType string, topicID string) (string, error) {
|
||||
ret := _m.Called(c, topicType, topicID)
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func(*plugin.Context, string, string) string); ok {
|
||||
r0 = rf(c, topicType, topicID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*plugin.Context, string, string) error); ok {
|
||||
r1 = rf(c, topicType, topicID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Implemented provides a mock function with given fields:
|
||||
func (_m *Hooks) Implemented() ([]string, error) {
|
||||
ret := _m.Called()
|
||||
@@ -299,6 +412,27 @@ func (_m *Hooks) UserHasLoggedIn(c *plugin.Context, user *model.User) {
|
||||
_m.Called(c, user)
|
||||
}
|
||||
|
||||
// UserHasPermissionToCollection provides a mock function with given fields: c, userID, collectionType, collectionId, permission
|
||||
func (_m *Hooks) UserHasPermissionToCollection(c *plugin.Context, userID string, collectionType string, collectionId string, permission *model.Permission) (bool, error) {
|
||||
ret := _m.Called(c, userID, collectionType, collectionId, permission)
|
||||
|
||||
var r0 bool
|
||||
if rf, ok := ret.Get(0).(func(*plugin.Context, string, string, string, *model.Permission) bool); ok {
|
||||
r0 = rf(c, userID, collectionType, collectionId, permission)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(*plugin.Context, string, string, string, *model.Permission) error); ok {
|
||||
r1 = rf(c, userID, collectionType, collectionId, permission)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UserWillLogIn provides a mock function with given fields: c, user
|
||||
func (_m *Hooks) UserWillLogIn(c *plugin.Context, user *model.User) string {
|
||||
ret := _m.Called(c, user)
|
||||
|
||||
Ссылка в новой задаче
Block a user