Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
entitlement claim
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleAM committed Dec 12, 2023
1 parent 2658fa1 commit 9412bff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion structures/v3/builder.entitlement.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package structures

import "go.mongodb.org/mongo-driver/bson/primitive"
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)

type EntitlementBuilder[D EntitlementData] struct {
Entitlement Entitlement[D]
Expand Down Expand Up @@ -45,3 +47,8 @@ func (b *EntitlementBuilder[D]) SetApp(app EntitlementApp) *EntitlementBuilder[D
b.Entitlement.App = &app
return b
}

func (b *EntitlementBuilder[D]) SetClaim(claim EntitlementClaim) *EntitlementBuilder[D] {
b.Entitlement.Claim = &claim
return b
}
12 changes: 10 additions & 2 deletions structures/v3/type.entitlement.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Entitlement[D EntitlementData] struct {
Data D `json:"data" bson:"data"`
// The user who is entitled to the item
UserID primitive.ObjectID `json:"user_id" bson:"user_id"`
// An optional claim expectation
Claim *EntitlementClaim `json:"claim" bson:"claim"`
// Eligibility conditions for this entitlement
Condition EntitlementCondition `json:"condition" bson:"condition"`
// Whether this entitlement is currently inactive
Expand Down Expand Up @@ -147,6 +149,12 @@ func (e EntitlementCondition) IsMet(roleIDs utils.Set[primitive.ObjectID]) bool
}

type EntitlementApp struct {
Name string `json:"name"`
State map[string]any `json:"state"`
Name string `json:"name"`
ActorID string `json:"string,omitempty"`
State map[string]any `json:"state"`
}

type EntitlementClaim struct {
Platform UserConnectionPlatform `json:"platform" bson:"platform"`
ID string `json:"id" bson:"id"`
}
1 change: 1 addition & 0 deletions structures/v3/type.role.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const (
RolePermissionManageStack RolePermission = 1 << 55 // 36028797018963968 - (Admin) Allows managing the application stack
RolePermissionManageCosmetics RolePermission = 1 << 56 // 72057594037927936 - (Admin) Allows managing user cosmetics
RolePermissionRunJobs RolePermission = 1 << 57 // 144115188075855872 - (Admin) Allows firing processing jobs
RolePermissionManageEntitlements RolePermission = 1 << 58 // 288230376151711744 - (Admin) Allows managing entitlements
)

// All permissions
Expand Down

0 comments on commit 9412bff

Please sign in to comment.