X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fuser.js;h=e64bab8abc54061778968453e6a7ff0caff71e84;hb=00871a261787ae1ed8446861ba2bd5eea9faca6d;hp=35a98dd6b430cc725d4bb64bebd155f2fa522ecc;hpb=ad4a8a1cca1049f600ebcdce9260c1021cd821a5;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/user.js b/server/models/user.js index 35a98dd6b..e64bab8ab 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -33,12 +33,23 @@ module.exports = function (sequelize, DataTypes) { } }, email: { - type: DataTypes.STRING, + type: DataTypes.STRING(400), allowNull: false, validate: { isEmail: true } }, + displayNSFW: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: false, + validate: { + nsfwValid: function (value) { + const res = customUsersValidators.isUserDisplayNSFWValid(value) + if (res === false) throw new Error('Display NSFW is not valid.') + } + } + }, role: { type: DataTypes.ENUM(values(constants.USER_ROLES)), allowNull: false @@ -101,6 +112,7 @@ function toFormatedJSON () { id: this.id, username: this.username, email: this.email, + displayNSFW: this.displayNSFW, role: this.role, createdAt: this.createdAt }