fix(subscriptions): cleanup and simplify fetching subscribers for tasks and projects logic
Vikunja now uses one recursive CTE and a few optimizations to fetch all subscribers for a task or project. This makes the relevant code easier to maintain and more performant. (cherry picked from commit 4ff8815fe1bfe72e02c10f6a6877c93a630f36a4)
This commit is contained in:
@ -1745,7 +1745,7 @@ func IsErrSubscriptionAlreadyExists(err error) bool {
|
||||
}
|
||||
|
||||
func (err *ErrSubscriptionAlreadyExists) Error() string {
|
||||
return fmt.Sprintf("Subscription for this (entity_id, entity_type, user_id) already exists [EntityType: %d, EntityID: %d, ID: %d]", err.EntityType, err.EntityID, err.UserID)
|
||||
return fmt.Sprintf("Subscription for this (entity_id, entity_type, user_id) already exists [EntityType: %d, EntityID: %d, UserID: %d]", err.EntityType, err.EntityID, err.UserID)
|
||||
}
|
||||
|
||||
// ErrCodeSubscriptionAlreadyExists holds the unique world-error code of this error
|
||||
@ -1760,6 +1760,32 @@ func (err ErrSubscriptionAlreadyExists) HTTPError() web.HTTPError {
|
||||
}
|
||||
}
|
||||
|
||||
// ErrMustProvideUser represents an error where you need to provide a user to fetch subscriptions
|
||||
type ErrMustProvideUser struct {
|
||||
}
|
||||
|
||||
// IsErrMustProvideUser checks if an error is ErrMustProvideUser.
|
||||
func IsErrMustProvideUser(err error) bool {
|
||||
_, ok := err.(*ErrMustProvideUser)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (err *ErrMustProvideUser) Error() string {
|
||||
return "no user provided while fetching subscriptions"
|
||||
}
|
||||
|
||||
// ErrCodeMustProvideUser holds the unique world-error code of this error
|
||||
const ErrCodeMustProvideUser = 12003
|
||||
|
||||
// HTTPError holds the http error description
|
||||
func (err ErrMustProvideUser) HTTPError() web.HTTPError {
|
||||
return web.HTTPError{
|
||||
HTTPCode: http.StatusPreconditionFailed,
|
||||
Code: ErrCodeMustProvideUser,
|
||||
Message: "You must provide a user to fetch subscriptions",
|
||||
}
|
||||
}
|
||||
|
||||
// =================
|
||||
// Link Share errors
|
||||
// =================
|
||||
|
Reference in New Issue
Block a user