Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a lot of things about sharing #1130

Merged
merged 12 commits into from
Jan 2, 2018
Prev Previous commit
Next Next commit
Fix accepting a sharing
  • Loading branch information
nono committed Dec 27, 2017
commit 3263774ecaac4d902fa69bf3cccfc93f24af7e8a
12 changes: 6 additions & 6 deletions pkg/sharings/sharings.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func (s *Sharing) Permissions(db couchdb.Database) (*permissions.Permission, err
// GetMemberFromClientID returns the Recipient associated with the
// given clientID.
func (s *Sharing) GetMemberFromClientID(db couchdb.Database, clientID string) (*Member, error) {
for _, m := range s.Recipients {
if m.Client.ClientID == clientID {
return &m, nil
for i := range s.Recipients {
if s.Recipients[i].Client.ClientID == clientID {
return &s.Recipients[i], nil
}
}
return nil, ErrRecipientDoesNotExist
Expand All @@ -97,9 +97,9 @@ func (s *Sharing) GetMemberFromClientID(db couchdb.Database, clientID string) (*
// GetMemberFromContactID returns the Member associated with the
// given contact ID.
func (s *Sharing) GetMemberFromContactID(db couchdb.Database, contactID string) (*Member, error) {
for _, m := range s.Recipients {
if m.RefContact.ID == contactID {
return &m, nil
for i := range s.Recipients {
if s.Recipients[i].RefContact.ID == contactID {
return &s.Recipients[i], nil
}
}
return nil, ErrRecipientDoesNotExist
Expand Down
1 change: 0 additions & 1 deletion pkg/sharings/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func RegisterClientOnTheRecipient(i *instance.Instance, s *Sharing, m *Member, u
i.Logger().Errorf("[sharing] Could not register at %s: %v", u, err)
return err
}
m.Status = consts.SharingStatusMailNotSent
return couchdb.UpdateDoc(i, s)
}

Expand Down
2 changes: 1 addition & 1 deletion web/sharings/sharings.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func SharingAnswer(c echo.Context) error {
if err != nil {
return wrapErrors(err)
}
return c.JSON(http.StatusFound, res)
return c.JSON(http.StatusCreated, res)
}

// Routes sets the routing for the sharing service
Expand Down