gifs/api

Paddy 2014-10-17 Parent:08ec88016e2f Child:18cb30e077ba

1:d3ba1115bfd0 Browse Files

Remove user functions and logins, fix UpdateCollection. UpdateCollection now takes a CollectionChange argument, rather than overwriting everything. Remove all our user related code, as that's going to be superseded by code.secondbit.org/auth, anyways.

datastore.go

     1.1 --- a/datastore.go	Wed Aug 27 22:34:02 2014 -0400
     1.2 +++ b/datastore.go	Fri Oct 17 07:11:56 2014 -0400
     1.3 @@ -6,24 +6,20 @@
     1.4  	"unicode"
     1.5  
     1.6  	"code.google.com/p/go.text/unicode/norm"
     1.7 -	"secondbit.org/uuid"
     1.8 +	"code.secondbit.org/uuid.hg"
     1.9  )
    1.10  
    1.11  var (
    1.12 -	CollectionNotFoundError  = errors.New("collection not found")
    1.13 -	DomainNotFoundError      = errors.New("domain not found")
    1.14 -	DomainAlreadyExistsError = errors.New("domain already attached to a collection")
    1.15 -	ItemNotFoundError        = errors.New("item not found")
    1.16 -	ItemAlreadyExistsError   = errors.New("item already exists")
    1.17 -	UserNotFoundError        = errors.New("user not found")
    1.18 -	UserAlreadyExistsError   = errors.New("user already exists")
    1.19 -	LoginNotFoundError       = errors.New("login not found")
    1.20 -	LoginAlreadyExistsError  = errors.New("login already exists")
    1.21 +	ErrCollectionNotFound  = errors.New("collection not found")
    1.22 +	ErrDomainNotFound      = errors.New("domain not found")
    1.23 +	ErrDomainAlreadyExists = errors.New("domain already attached to a collection")
    1.24 +	ErrItemNotFound        = errors.New("item not found")
    1.25 +	ErrItemAlreadyExists   = errors.New("item already exists")
    1.26  )
    1.27  
    1.28  type Datastore interface {
    1.29  	CreateCollection(c Collection) error
    1.30 -	UpdateCollection(c Collection) error
    1.31 +	UpdateCollection(id uuid.ID, change CollectionChange) error
    1.32  	GetCollectionByDomain(domain string) (Collection, error)
    1.33  	GetCollectionByID(id uuid.ID) (Collection, error)
    1.34  	GetCollectionsByUser(id uuid.ID) ([]Collection, error)
    1.35 @@ -37,15 +33,6 @@
    1.36  	AddItemToCollection(id uuid.ID, item Item) error
    1.37  	GetItemByName(collectionID uuid.ID, name string) (Item, error)
    1.38  	DeleteItem(item Item) error
    1.39 -
    1.40 -	GetUserByID(id uuid.ID) (User, error)
    1.41 -	GetUserByLogin(loginType, value, passphrase string) (User, error)
    1.42 -	AddLoginToUser(login Login, user uuid.ID) error
    1.43 -	RemoveLoginFromUser(loginType, value string, user uuid.ID) error
    1.44 -	GetLoginsByUser(user uuid.ID) ([]Login, error)
    1.45 -	CreateUser(u User) error
    1.46 -	UpdateUser(u User) error
    1.47 -	DeleteUser(u User) error
    1.48  }
    1.49  
    1.50  func slugify(in string) string {
    1.51 @@ -72,6 +59,16 @@
    1.52  	Created time.Time
    1.53  }
    1.54  
    1.55 +func (c *Collection) ApplyChange(change CollectionChange) {
    1.56 +	if change.Name != nil {
    1.57 +		c.Name = *change.Name
    1.58 +	}
    1.59 +}
    1.60 +
    1.61 +type CollectionChange struct {
    1.62 +	Name *string
    1.63 +}
    1.64 +
    1.65  type Domain struct {
    1.66  	Domain       string
    1.67  	CollectionID uuid.ID
    1.68 @@ -84,20 +81,3 @@
    1.69  	CollectionID uuid.ID
    1.70  	Name         string
    1.71  }
    1.72 -
    1.73 -type User struct {
    1.74 -	ID         uuid.ID
    1.75 -	Name       string
    1.76 -	Passphrase string
    1.77 -	Email      string
    1.78 -	Created    time.Time
    1.79 -	LastSeen   time.Time
    1.80 -}
    1.81 -
    1.82 -type Login struct {
    1.83 -	Type     string
    1.84 -	Value    string
    1.85 -	UserID   uuid.ID
    1.86 -	Created  time.Time
    1.87 -	LastUsed time.Time
    1.88 -}