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
Lint
  • Loading branch information
nono committed Dec 28, 2017
commit b7b2a35e78d3bad60f40c9d1d257e5d4ebe8cb8c
1 change: 1 addition & 0 deletions pkg/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (p *Permission) SetID(id string) { p.PID = id }
// SetRev implements jsonapi.Doc
func (p *Permission) SetRev(rev string) { p.PRev = rev }

// Expired returns true if the permissions are no longer valid
func (p *Permission) Expired() bool {
if p.ExpiresAt == nil {
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/sharings/sharings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func insertSharingIntoDB(t *testing.T, sharingID, sharingType string, owner bool
if owner {
sharing.Recipients = append(sharing.Recipients, rs)
} else {
sharing.Sharer = rs
sharing.Sharer = &rs
break
}
}
Expand Down
4 changes: 2 additions & 2 deletions web/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func createPermission(c echo.Context) error {
return echo.NewHTTPError(http.StatusUnauthorized, "no parent")
}

var expiresAt interface{} = nil
var expiresAt interface{}
if ttl != "" {
if d, err := bigduration.ParseDuration(ttl); err != nil {
if d, errd := bigduration.ParseDuration(ttl); errd != nil {
expiresAt = time.Now().Add(d)
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/sharings/sharings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func createSharing(t *testing.T, sharingID, sharingType string, owner bool, slug
if owner {
sharing.Recipients = append(sharing.Recipients, rs)
} else {
sharing.Sharer = rs
sharing.Sharer = &rs
break
}
}
Expand Down