upd(crm): make repository consistent
This commit is contained in:
@@ -4,6 +4,10 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
"github.com/crusttech/crust/internal/auth"
|
||||
"github.com/crusttech/crust/internal/organization"
|
||||
"github.com/crusttech/crust/messaging/types"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -18,6 +22,19 @@ func DB(ctx context.Context) *factory.DB {
|
||||
return factory.Database.MustGet("crm").With(ctx)
|
||||
}
|
||||
|
||||
// Identity returns the User ID from context
|
||||
func Identity(ctx context.Context) uint64 {
|
||||
return auth.GetIdentityFromContext(ctx).Identity()
|
||||
}
|
||||
|
||||
// Organisation returns the Organisation from context
|
||||
func Organization(ctx context.Context) *types.Organisation {
|
||||
return &types.Organisation{
|
||||
organization.GetFromContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// With updates repository and database contexts
|
||||
func (r *repository) With(ctx context.Context, db *factory.DB) *repository {
|
||||
return &repository{
|
||||
ctx: ctx,
|
||||
|
||||
Reference in New Issue
Block a user