2021-03-07 23:53:54 +03:00
|
|
|
//NOTE(martina): when you add any new variable to the user, file, or slate objects, add it in these structures
|
|
|
|
//add it to sanitize___ if it should be sent to the front end
|
|
|
|
//add it to clean____ if it should be saved to the database
|
2020-08-28 07:34:50 +03:00
|
|
|
|
2021-03-07 23:53:54 +03:00
|
|
|
//NOTE(martina): these functions are to remove sensitive information before sending the data to the front end
|
|
|
|
//only variables listed here will be sent to the front end
|
|
|
|
|
|
|
|
export const sanitizeUser = (entity) => {
|
2020-08-28 07:34:50 +03:00
|
|
|
return {
|
|
|
|
id: entity.id,
|
|
|
|
username: entity.username,
|
2021-03-07 23:53:54 +03:00
|
|
|
slates: entity.slates, //NOTE(martina): this is not in the database. It is added after
|
|
|
|
library: entity.library, //NOTE(martina): this is not in the database. It is added after
|
2021-08-29 03:29:17 +03:00
|
|
|
name: entity.name,
|
2021-08-29 04:36:48 +03:00
|
|
|
body: entity.body,
|
2021-09-02 01:29:15 +03:00
|
|
|
photo: entity.photo,
|
2021-06-01 08:14:22 +03:00
|
|
|
followerCount: entity.followerCount,
|
|
|
|
slateCount: entity.slateCount,
|
2020-08-28 07:34:50 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-07 23:53:54 +03:00
|
|
|
export const sanitizeSlate = (entity) => {
|
2020-08-28 07:34:50 +03:00
|
|
|
return {
|
|
|
|
id: entity.id,
|
|
|
|
slatename: entity.slatename,
|
2021-08-29 03:29:17 +03:00
|
|
|
name: entity.name,
|
2021-03-07 23:53:54 +03:00
|
|
|
ownerId: entity.ownerId,
|
|
|
|
isPublic: entity.isPublic,
|
|
|
|
objects: entity.objects,
|
2021-07-15 19:32:18 +03:00
|
|
|
owner: entity.owner,
|
2021-03-07 23:53:54 +03:00
|
|
|
user: entity.user, //NOTE(martina): this is not in the database. It is added after
|
2021-08-29 04:36:48 +03:00
|
|
|
body: entity.body,
|
2021-09-01 02:37:57 +03:00
|
|
|
preview: entity.preview,
|
2021-06-01 08:14:22 +03:00
|
|
|
fileCount: entity.fileCount,
|
|
|
|
subscriberCount: entity.subscriberCount,
|
2020-08-28 07:34:50 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-07 23:53:54 +03:00
|
|
|
export const sanitizeFile = (entity) => {
|
2020-08-31 21:10:42 +03:00
|
|
|
return {
|
2021-03-07 23:53:54 +03:00
|
|
|
id: entity.id,
|
|
|
|
cid: entity.cid,
|
|
|
|
ownerId: entity.ownerId,
|
|
|
|
isPublic: entity.isPublic,
|
|
|
|
filename: entity.filename,
|
2021-08-29 03:29:17 +03:00
|
|
|
name: entity.name,
|
2021-04-30 22:14:14 +03:00
|
|
|
createdAt: entity.createdAt,
|
2021-08-29 04:36:48 +03:00
|
|
|
body: entity.body,
|
2021-08-31 00:20:24 +03:00
|
|
|
size: entity.size,
|
2021-08-31 01:03:45 +03:00
|
|
|
type: entity.type,
|
2021-08-31 01:07:08 +03:00
|
|
|
blurhash: entity.blurhash,
|
2021-08-31 01:12:37 +03:00
|
|
|
source: entity.source,
|
2021-08-31 01:14:33 +03:00
|
|
|
author: entity.author,
|
2021-08-31 01:31:28 +03:00
|
|
|
coverImage: entity.coverImage,
|
2021-09-01 03:07:17 +03:00
|
|
|
linkName: entity.linkName,
|
|
|
|
linkBody: entity.linkBody,
|
|
|
|
linkSource: entity.linkSource,
|
|
|
|
linkAuthor: entity.linkAuthor,
|
|
|
|
linkDomain: entity.linkDomain,
|
|
|
|
linkImage: entity.linkImage,
|
|
|
|
linkFavicon: entity.linkFavicon,
|
|
|
|
linkHtml: entity.linkHtml,
|
|
|
|
linkIFrameAllowed: entity.linkIFrameAllowed,
|
2021-09-01 03:27:41 +03:00
|
|
|
tags: entity.tags,
|
2021-03-07 23:53:54 +03:00
|
|
|
data: {
|
|
|
|
unity: entity.data?.unity, //NOTE(martina): newly added
|
|
|
|
},
|
2021-06-01 08:14:22 +03:00
|
|
|
downloadCount: entity.downloadCount,
|
|
|
|
saveCount: entity.saveCount,
|
2021-07-07 23:50:57 +03:00
|
|
|
isLink: entity.isLink,
|
|
|
|
url: entity.url,
|
2020-08-31 21:10:42 +03:00
|
|
|
};
|
2020-08-30 12:07:21 +03:00
|
|
|
};
|
|
|
|
|
2021-07-07 23:50:57 +03:00
|
|
|
//NOTE(martina): list of the properties of the tables that should be returned by db queries
|
|
|
|
export const slateProperties = [
|
|
|
|
"slates.id",
|
|
|
|
"slates.slatename",
|
2021-08-29 03:29:17 +03:00
|
|
|
"slates.name",
|
2021-08-29 04:36:48 +03:00
|
|
|
"slates.body",
|
2021-07-07 23:50:57 +03:00
|
|
|
"slates.ownerId",
|
|
|
|
"slates.isPublic",
|
|
|
|
"slates.subscriberCount",
|
|
|
|
"slates.fileCount",
|
|
|
|
];
|
|
|
|
|
|
|
|
export const userProperties = [
|
|
|
|
"users.id",
|
|
|
|
"users.username",
|
2021-08-29 03:29:17 +03:00
|
|
|
"users.name",
|
2021-08-29 04:36:48 +03:00
|
|
|
"users.body",
|
2021-07-07 23:50:57 +03:00
|
|
|
"users.slateCount",
|
|
|
|
"users.followerCount",
|
|
|
|
];
|
|
|
|
|
|
|
|
export const fileProperties = [
|
|
|
|
"files.id",
|
|
|
|
"files.ownerId",
|
|
|
|
"files.cid",
|
|
|
|
"files.isPublic",
|
|
|
|
"files.filename",
|
2021-08-29 03:29:17 +03:00
|
|
|
"files.name",
|
2021-08-29 04:36:48 +03:00
|
|
|
"files.body",
|
2021-07-07 23:50:57 +03:00
|
|
|
"files.data",
|
|
|
|
"files.createdAt",
|
|
|
|
"files.downloadCount",
|
|
|
|
"files.saveCount",
|
|
|
|
"files.isLink",
|
|
|
|
"files.url",
|
|
|
|
];
|