MM-17912: Allow searching for files through plugin API (#13647)
* constants and options for getting files * Method to get files with options * Add i18n strings for en * Add API methods for getting files with options * gofmt -s file * explicitly set create at in tests * use greater than nanosecond time difference for tests * use gte instead of gt for getting files by created time * use created at time as default sort order for getting file infos * use explicit inline strings instead of format strings * join tables only when required * use if as secondary sort, and update tests * update field docs to reflect previous changes * make page and perPage get options as required * add json struct tags to GetFileOptions * bump minimum server versioni * remove sorting by username and channelname * use bool for sort order type * use FileInfo prefix instead of just File * clearer comments * use zero-based page numbering * test filtering by user and channel * remove unnecessary whitespace * use int instead of uint for page and perPage arguments Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ed52acd89c
Коммит
3fc5287f6b
@@ -659,6 +659,12 @@ type API interface {
|
||||
// Minimum server version: 5.3
|
||||
GetFileInfo(fileId string) (*model.FileInfo, *model.AppError)
|
||||
|
||||
// GetFileInfos gets File Infos with options
|
||||
//
|
||||
// @tag File
|
||||
// Minimum server version: 5.22
|
||||
GetFileInfos(page, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, *model.AppError)
|
||||
|
||||
// GetFile gets content of a file by it's ID
|
||||
//
|
||||
// @tag File
|
||||
|
||||
@@ -3320,6 +3320,37 @@ func (s *apiRPCServer) GetFileInfo(args *Z_GetFileInfoArgs, returns *Z_GetFileIn
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetFileInfosArgs struct {
|
||||
A int
|
||||
B int
|
||||
C *model.GetFileInfosOptions
|
||||
}
|
||||
|
||||
type Z_GetFileInfosReturns struct {
|
||||
A []*model.FileInfo
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetFileInfos(page, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, *model.AppError) {
|
||||
_args := &Z_GetFileInfosArgs{page, perPage, opt}
|
||||
_returns := &Z_GetFileInfosReturns{}
|
||||
if err := g.client.Call("Plugin.GetFileInfos", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetFileInfos API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetFileInfos(args *Z_GetFileInfosArgs, returns *Z_GetFileInfosReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetFileInfos(page, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetFileInfos(args.A, args.B, args.C)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetFileInfos called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetFileArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
@@ -1000,6 +1000,31 @@ func (_m *API) GetFileInfo(fileId string) (*model.FileInfo, *model.AppError) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFileInfos provides a mock function with given fields: page, perPage, opt
|
||||
func (_m *API) GetFileInfos(page int, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, *model.AppError) {
|
||||
ret := _m.Called(page, perPage, opt)
|
||||
|
||||
var r0 []*model.FileInfo
|
||||
if rf, ok := ret.Get(0).(func(int, int, *model.GetFileInfosOptions) []*model.FileInfo); ok {
|
||||
r0 = rf(page, perPage, opt)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.FileInfo)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(int, int, *model.GetFileInfosOptions) *model.AppError); ok {
|
||||
r1 = rf(page, perPage, opt)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFileLink provides a mock function with given fields: fileId
|
||||
func (_m *API) GetFileLink(fileId string) (string, *model.AppError) {
|
||||
ret := _m.Called(fileId)
|
||||
|
||||
Ссылка в новой задаче
Block a user