slate/node_common/serializers.js

66 lines
2.1 KiB
JavaScript
Raw Normal View History

// //NOTE(martina): clean the object before adding it to the database
// export const cleanUser = (user) => {
// return {
// id: user.id,
// createdAt: user.createdAt,
// lastActive: user.lastActive,
// username: user.username,
// password: user.password,
// salt: user.salt,
// email: user.email,
// followerCount: user.followerCount,
// slateCount: user.slateCount,
// twitterId: user.twitterId,
// authVersion: user.authVersion,
// revertedVersion: user.revertedVersion,
// body: user.body,
// photo: user.photo,
// name: user.name,
// twitterUsername: user.twitterUsername,
// twitterVerified: user.twitterVerified,
2021-09-25 04:20:28 +03:00
// textileKey: user.textileKey,
// textileToken: user.textileToken,
2021-09-25 04:20:28 +03:00
// textileThreadID: user.textileThreadID,
// textileBucketCID: user.textileThreadID,
// onboarding: user.onboarding,
// };
// };
//NOTE(martina): add a variable to sanitizeUser if it should be sent to the front end. Otherwise, it will be filtered out
export const sanitizeUser = (user) => {
return {
id: user.id,
createdAt: user.createdAt,
lastActive: user.lastActive,
username: user.username,
slates: user.slates, //NOTE(martina): this is not in the database. It is added after
library: user.library, //NOTE(martina): this is not in the database. It is added after
name: user.name,
body: user.body,
photo: user.photo,
followerCount: user.followerCount,
slateCount: user.slateCount,
twitterUsername: user.twitterUsername,
twitterVerified: user.twitterVerified,
};
};
//NOTE(martina): the user public properties list filters out sensitive information
export const userPublicProperties = [
2021-07-07 23:50:57 +03:00
"users.id",
"users.createdAt",
"users.lastActive",
2021-07-07 23:50:57 +03:00
"users.username",
2021-08-29 03:29:17 +03:00
"users.name",
2021-08-29 04:36:48 +03:00
"users.body",
"users.photo",
2021-07-07 23:50:57 +03:00
"users.slateCount",
"users.followerCount",
"users.twitterUsername",
"users.twitterVerified",
2021-07-07 23:50:57 +03:00
];
//NOTE(martina): the user preview properties list contains the minimal info needed to preview the owner of a file or slate
export const userPreviewProperties = ["users.id", "users.name", "users.username", "users.photo"];