I am using the Installation
-Model to allow users to configure which (push) Notifications they want to receive on which device, without having to sign up. Unfortunately, it seems the Installation
-Object acts differently than other models. To allow for a smooth setup, I set the channel based on a custom field on first iteration, but then want to allow the user to change them. The parse-code looks like this:
Parse.Cloud.beforeSave(Parse.Installation, async (request) => {
const defaultTeamId = request.object.get("defaultTeamId");
request.object.unset("defaultTeamId");
if (!request.master) {
if (request.user) {
request.object.set("user", request.user);
} else {
request.object.unset("user");
}
}
if (request.original) {
// an update not a create, ignore startingFollows
// but let it return the existing set of channels:
console.log("known");
request.object.set('channels', request.original.get('channels'));
return
}
const channels = []
if (request.user) {
const { teams } = await fetchMyTeams(request.user);
teams.forEach((x) => {
channels.push(x.id)
});
}
if (channels.length === 0 && defaultTeamId) {
channels.push(defaultTeamId);
}
request.object.set("channels", channels.map((x) => `${x}:news`));
});
This generally works as expected, just that the channels are not returned to the user, nor the id
of the object when it set/created:
{"updatedAt":"2021-02-21T16:03:05.733Z","defaultTeamId":{"__op":"Delete"},"user":{"__op":"Delete"}}
I noticed that there is an empty []
in the protectedFields
of the schema:
"protectedFields": {
"*": []
}
Which I canât change either. Is that related? How can I get the parse-server to return the other fields? Especially since the client doesnât even get the objectId
?
Thanks!