mirror of
				https://gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud
				synced 2025-11-04 05:11:46 +00:00 
			
		
		
		
	implemented User's CreateBatchWithoutPassoword
This commit is contained in:
		@@ -45,16 +45,14 @@ func (e *UserUpdateError) Error() string {
 | 
			
		||||
 | 
			
		||||
//NewUpdateError returns an UpdateError based on an UpdateError channel
 | 
			
		||||
func NewUpdateError(errors chan UpdateError) *UserUpdateError {
 | 
			
		||||
	empty := true
 | 
			
		||||
	var ue UserUpdateError
 | 
			
		||||
	for e := range errors {
 | 
			
		||||
		if ue.Errors == nil {
 | 
			
		||||
			empty = false
 | 
			
		||||
			ue.Errors = map[string]error{e.Field: e.Error}
 | 
			
		||||
		}
 | 
			
		||||
		ue.Errors[e.Field] = e.Error
 | 
			
		||||
	}
 | 
			
		||||
	if !empty {
 | 
			
		||||
	if len(ue.Errors) > 0 {
 | 
			
		||||
		return &ue
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
 
 | 
			
		||||
@@ -95,16 +95,17 @@ type Shares interface {
 | 
			
		||||
//Users available methods
 | 
			
		||||
type Users interface {
 | 
			
		||||
	List() ([]string, error)
 | 
			
		||||
	ListDetails() (map[string]User, error)
 | 
			
		||||
	Get(name string) (*User, error)
 | 
			
		||||
	ListDetails() (map[string]UserDetails, error)
 | 
			
		||||
	Get(name string) (*UserDetails, error)
 | 
			
		||||
	Search(search string) ([]string, error)
 | 
			
		||||
	Create(username string, password string, user *User) error
 | 
			
		||||
	Create(username string, password string, user *UserDetails) error
 | 
			
		||||
	CreateWithoutPassword(username, email, displayName, quota, language string, groups ...string) error
 | 
			
		||||
	CreateBatchWithoutPassword(users []User) error
 | 
			
		||||
	Delete(name string) error
 | 
			
		||||
	Enable(name string) error
 | 
			
		||||
	Disable(name string) error
 | 
			
		||||
	SendWelcomeEmail(name string) error
 | 
			
		||||
	Update(user *User) error
 | 
			
		||||
	Update(user *UserDetails) error
 | 
			
		||||
	UpdateEmail(name string, email string) error
 | 
			
		||||
	UpdateDisplayName(name string, displayName string) error
 | 
			
		||||
	UpdatePhone(name string, phone string) error
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ type UserListDetailsResponse struct {
 | 
			
		||||
	Ocs struct {
 | 
			
		||||
		Meta Meta `json:"meta"`
 | 
			
		||||
		Data struct {
 | 
			
		||||
			Users map[string]User `json:"users"`
 | 
			
		||||
			Users map[string]UserDetails `json:"users"`
 | 
			
		||||
		} `json:"data"`
 | 
			
		||||
	} `json:"ocs"`
 | 
			
		||||
}
 | 
			
		||||
@@ -39,8 +39,8 @@ type UserListDetailsResponse struct {
 | 
			
		||||
//UserResponse
 | 
			
		||||
type UserResponse struct {
 | 
			
		||||
	Ocs struct {
 | 
			
		||||
		Meta Meta `json:"meta"`
 | 
			
		||||
		Data User `json:"data"`
 | 
			
		||||
		Meta Meta        `json:"meta"`
 | 
			
		||||
		Data UserDetails `json:"data"`
 | 
			
		||||
	} `json:"ocs"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,20 @@
 | 
			
		||||
package types
 | 
			
		||||
 | 
			
		||||
//Users
 | 
			
		||||
//User encapsulate the data needed to create a new Nextcloud's User
 | 
			
		||||
type User struct {
 | 
			
		||||
	Enabled bool   `json:"enabled"`
 | 
			
		||||
	ID      string `json:"id"`
 | 
			
		||||
	Quota   struct {
 | 
			
		||||
		Free     int64   `json:"free"`
 | 
			
		||||
		Used     int     `json:"used"`
 | 
			
		||||
		Total    int64   `json:"total"`
 | 
			
		||||
		Relative float64 `json:"relative"`
 | 
			
		||||
		Quota    int     `json:"quota"`
 | 
			
		||||
	} `json:"quota"`
 | 
			
		||||
	Username    string
 | 
			
		||||
	Email       string
 | 
			
		||||
	DisplayName string
 | 
			
		||||
	Quota       string
 | 
			
		||||
	Language    string
 | 
			
		||||
	Groups      []string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//UserDetails is the raw Nextcloud User response
 | 
			
		||||
type UserDetails struct {
 | 
			
		||||
	Enabled     bool     `json:"enabled"`
 | 
			
		||||
	ID          string   `json:"id"`
 | 
			
		||||
	Quota       Quota    `json:"quota"`
 | 
			
		||||
	Email       string   `json:"email"`
 | 
			
		||||
	Displayname string   `json:"displayname"`
 | 
			
		||||
	Phone       string   `json:"phone"`
 | 
			
		||||
@@ -26,3 +30,11 @@ type User struct {
 | 
			
		||||
	Subadmin        []interface{} `json:"subadmin,omitempty"`
 | 
			
		||||
	Locale          string        `json:"locale,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Quota struct {
 | 
			
		||||
	Free     int64   `json:"free"`
 | 
			
		||||
	Used     int     `json:"used"`
 | 
			
		||||
	Total    int64   `json:"total"`
 | 
			
		||||
	Relative float64 `json:"relative"`
 | 
			
		||||
	Quota    int     `json:"quota"`
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user