I have two Parse Classes Group and Post. Group have a parse relation field people (users, that are in this group) and Post have a pointer field group (which group, this post belong to).
When someone create a group, he/she add his friends to this group that are being saved in "people" field.
Everybody who is in the people relation can post in the group.
I have some questions about setting ACL on post and group object.
Parse.Cloud.beforeSave(POST, function(request, response){
Parse.Cloud.useMasterKey();
var post = request.object;
var owner = post.get("owner");
var community = post.get("group")
var draft = post.get("draft");
if (!owner || !draft || !community) return response.error(PARAMETERS_NOT_FOUND);
if (draft.length <1) return response.error(FIELD_SIZE_LIMIT_NOT_ENOUGH)
var community = validateCommunity(community.id);
if (!community) return response.error(FAKE_COMMUNITY);
var people_to_share = community.relation("people");
var acl = new Parse.ACL();
acl.setWriteAccess(owner, true);
acl.setReadAccess(owner, true);
// Now here i want to set the acl of post for all people_to_share .... And that is working good ... but the problem is when i add new person in community (people field) .... I have to do set acl for him in every post of community.
post.setACL(acl);
response.success();
});
Yes. I have solved this Issue using a common role. I created a role for every group and saved it in the Group Class as a pointer. Whenever a new person is added to group. I give him read access to that group's role. And on removing person from that group. I remove his read access.
Similarly, When new post is created, I just set post's acl to that group's role. It is good dynamic way.