-
Notifications
You must be signed in to change notification settings - Fork 133
/
facebook_groups.go
184 lines (149 loc) · 4.71 KB
/
facebook_groups.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package shapes
import (
"github.com/Permify/permify/pkg/development/file"
)
// FACEBOOK GROUPS SAMPLE
var InitialFacebookGroupsShape = file.Shape{
Schema: `
entity user {}
entity group {
// Relation to represent the members of the group
relation member @user
// Relation to represent the admins of the group
relation admin @user
// Relation to represent the moderators of the group
relation moderator @user
// Permissions for the group entity
action create = member
action join = member
action leave = member
action invite_to_group = admin
action remove_from_group = admin or moderator
action edit_settings = admin or moderator
action post_to_group = member
action comment_on_post = member
action view_group_insights = admin or moderator
}
entity post {
// Relation to represent the owner of the post
relation owner @user
// Relation to represent the group that the post belongs to
relation group @group
// Permissions for the post entity
action view_post = owner or group.member
action edit_post = owner or group.admin
action delete_post = owner or group.admin
permission group_member = group.member
}
entity comment {
// Relation to represent the owner of the comment
relation owner @user
// Relation to represent the post that the comment belongs to
relation post @post
// Permissions for the comment entity
action view_comment = owner or post.group_member
action edit_comment = owner
action delete_comment = owner
}
entity like {
// Relation to represent the owner of the like
relation owner @user
// Relation to represent the post that the like belongs to
relation post @post
// Permissions for the like entity
action like_post = owner or post.group_member
action unlike_post = owner or post.group_member
}
entity poll {
// Relation to represent the owner of the poll
relation owner @user
// Relation to represent the group that the poll belongs to
relation group @group
// Permissions for the poll entity
action create_poll = owner or group.admin
action view_poll = owner or group.member
action edit_poll = owner or group.admin
action delete_poll = owner or group.admin
}
entity file {
// Relation to represent the owner of the file
relation owner @user
// Relation to represent the group that the file belongs to
relation group @group
// Permissions for the file entity
action upload_file = owner or group.member
action view_file = owner or group.member
action delete_file = owner or group.admin
}
entity event {
// Relation to represent the owner of the event
relation owner @user
// Relation to represent the group that the event belongs to
relation group @group
// Permissions for the event entity
action create_event = owner or group.admin
action view_event = owner or group.member
action edit_event = owner or group.admin
action delete_event = owner or group.admin
action RSVP_to_event = owner or group.member
}
`,
Relationships: []string{
// group relationships
"group:1#member@user:1",
"group:1#admin@user:2",
"group:2#moderator@user:3",
"group:2#member@user:4",
"group:1#member@user:5",
// post relationships
"post:1#owner@user:1",
"post:1#group@group:1",
"post:2#owner@user:4",
"post:2#group@group:1",
// comment relationships
"comment:1#owner@user:2",
"comment:1#post@post:1",
"comment:2#owner@user:5",
"comment:2#post@post:2",
// like relationships
"like:1#owner@user:3",
"like:1#post@post:1",
"like:2#owner@user:4",
"like:2#post@post:2",
// poll relationships
"poll:1#owner@user:2",
"poll:1#group@group:1",
"poll:2#owner@user:5",
"poll:2#group@group:1",
// like relationships
"file:1#owner@user:1",
"file:1#group@group:1",
// event relationships
"event:1#owner@user:3",
"event:1#group@group:1",
},
Scenarios: []file.Scenario{
{
Name: "Scenario 1",
Description: "Scenario Description",
Checks: []file.Check{
{
Entity: "event:1",
Subject: "user:4",
Assertions: map[string]bool{
"RSVP_to_event": false,
},
},
{
Entity: "comment:1",
Subject: "user:5",
Assertions: map[string]bool{
"view_comment": true,
},
},
},
EntityFilters: []file.EntityFilter{},
SubjectFilters: []file.SubjectFilter{},
},
},
}