2020-09-03 09:00:02 +03:00
|
|
|
import * as Utilities from "~/node_common/utilities";
|
|
|
|
import * as Data from "~/node_common/data";
|
2021-03-07 23:53:54 +03:00
|
|
|
import * as Serializers from "~/node_common/serializers";
|
2020-09-03 09:00:02 +03:00
|
|
|
import * as Strings from "~/common/strings";
|
|
|
|
|
|
|
|
export default async (req, res) => {
|
2021-03-07 23:53:54 +03:00
|
|
|
const response = await Data.getSlateById({
|
|
|
|
id: req.body.data.id,
|
|
|
|
includeFiles: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!response) {
|
|
|
|
return res.status(404).send({ decorator: "SERVER_GET_SLATE_NOT_FOUND", error: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error) {
|
|
|
|
return res.status(500).send({ decorator: "SERVER_GET_SLATE_NOT_FOUND", error: true });
|
2021-01-24 09:20:57 +03:00
|
|
|
}
|
2021-03-07 23:53:54 +03:00
|
|
|
|
2021-05-06 03:08:14 +03:00
|
|
|
if (!response.isPublic) {
|
|
|
|
const id = Utilities.getIdFromCookie(req);
|
|
|
|
|
|
|
|
if (!ownerId || response.ownerId !== id) {
|
|
|
|
return res.status(403).send({
|
|
|
|
decorator: "SERVER_GET_SLATE_PRIVATE_ACCESS_DENIED",
|
|
|
|
error: true,
|
|
|
|
});
|
|
|
|
}
|
2021-03-07 23:53:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return res.status(200).send({ decorator: "SERVER_GET_SLATE", slate: response });
|
2020-09-03 09:00:02 +03:00
|
|
|
};
|