spec cleanup, add find-by-handle for users
This commit is contained in:
@@ -309,7 +309,8 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},{
|
||||
},
|
||||
{
|
||||
"title": "Organisations",
|
||||
"description": "Organisations represent a top-level grouping entity. There may be many organisations defined in a single deployment.",
|
||||
"path": "/organisations",
|
||||
@@ -702,6 +703,12 @@
|
||||
"required": false,
|
||||
"title": "Search email to match against users"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "handle",
|
||||
"required": false,
|
||||
"title": "Search handle to match against users"
|
||||
},
|
||||
{
|
||||
"name": "kind",
|
||||
"type": "types.UserKind",
|
||||
@@ -1096,8 +1103,7 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
}, {
|
||||
"title": "Permissions",
|
||||
"parameters": {},
|
||||
"entrypoint": "permissions",
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
"title": "Search email to match against users",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "handle",
|
||||
"required": false,
|
||||
"title": "Search handle to match against users",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "kind",
|
||||
"required": false,
|
||||
|
||||
@@ -754,6 +754,7 @@ An organisation may have many roles. Roles may have many channels available. Acc
|
||||
| query | string | GET | Search query to match against users | N/A | NO |
|
||||
| username | string | GET | Search username to match against users | N/A | NO |
|
||||
| email | string | GET | Search email to match against users | N/A | NO |
|
||||
| handle | string | GET | Search handle to match against users | N/A | NO |
|
||||
| kind | types.UserKind | GET | Kind (normal, bot) | N/A | NO |
|
||||
| incDeleted | bool | GET | Include deleted users (requires 'access' permission) | N/A | NO |
|
||||
| incSuspended | bool | GET | Include suspended users (requires 'access' permission) | N/A | NO |
|
||||
|
||||
@@ -75,6 +75,19 @@ func (mr *MockUserRepositoryMockRecorder) FindByUsername(username interface{}) *
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByUsername", reflect.TypeOf((*MockUserRepository)(nil).FindByUsername), username)
|
||||
}
|
||||
|
||||
// FindByHandle mocks base method
|
||||
func (m *MockUserRepository) FindByHandle(handle string) (*types.User, error) {
|
||||
ret := m.ctrl.Call(m, "FindByHandle", handle)
|
||||
ret0, _ := ret[0].(*types.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// FindByHandle indicates an expected call of FindByHandle
|
||||
func (mr *MockUserRepositoryMockRecorder) FindByHandle(handle interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByHandle", reflect.TypeOf((*MockUserRepository)(nil).FindByHandle), handle)
|
||||
}
|
||||
|
||||
// FindByID mocks base method
|
||||
func (m *MockUserRepository) FindByID(id uint64) (*types.User, error) {
|
||||
ret := m.ctrl.Call(m, "FindByID", id)
|
||||
|
||||
@@ -148,6 +148,10 @@ func (r user) Find(filter types.UserFilter) (set types.UserSet, f types.UserFilt
|
||||
q = q.Where("u.username = ?", f.Username)
|
||||
}
|
||||
|
||||
if f.Handle != "" {
|
||||
q = q.Where("u.handle = ?", f.Handle)
|
||||
}
|
||||
|
||||
if f.Kind != "" {
|
||||
q = q.Where("u.kind = ?", f.Kind)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ type UserList struct {
|
||||
Query string
|
||||
Username string
|
||||
Email string
|
||||
Handle string
|
||||
Kind types.UserKind
|
||||
IncDeleted bool
|
||||
IncSuspended bool
|
||||
@@ -55,6 +56,7 @@ func (r UserList) Auditable() map[string]interface{} {
|
||||
out["query"] = r.Query
|
||||
out["username"] = r.Username
|
||||
out["email"] = r.Email
|
||||
out["handle"] = r.Handle
|
||||
out["kind"] = r.Kind
|
||||
out["incDeleted"] = r.IncDeleted
|
||||
out["incSuspended"] = r.IncSuspended
|
||||
@@ -101,6 +103,9 @@ func (r *UserList) Fill(req *http.Request) (err error) {
|
||||
if val, ok := get["email"]; ok {
|
||||
r.Email = val
|
||||
}
|
||||
if val, ok := get["handle"]; ok {
|
||||
r.Handle = val
|
||||
}
|
||||
if val, ok := get["kind"]; ok {
|
||||
r.Kind = types.UserKind(val)
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ func (ctrl User) List(ctx context.Context, r *request.UserList) (interface{}, er
|
||||
Query: r.Query,
|
||||
Email: r.Email,
|
||||
Username: r.Username,
|
||||
Handle: r.Handle,
|
||||
Kind: r.Kind,
|
||||
IncSuspended: r.IncSuspended,
|
||||
IncDeleted: r.IncDeleted,
|
||||
|
||||
@@ -46,6 +46,7 @@ type (
|
||||
Query string `json:"query"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
Handle string `json:"handle"`
|
||||
Kind UserKind `json:"kind"`
|
||||
IncDeleted bool `json:"incDeleted"`
|
||||
IncSuspended bool `json:"incSuspended"`
|
||||
|
||||
Reference in New Issue
Block a user