sending images through messages works
This commit is contained in:
@@ -25,7 +25,7 @@ const Message = sequelize.define('Message', {
|
||||
},
|
||||
content: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false
|
||||
allowNull: true
|
||||
},
|
||||
isRead: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
@@ -36,7 +36,15 @@ const Message = sequelize.define('Message', {
|
||||
allowNull: true
|
||||
}
|
||||
}, {
|
||||
timestamps: true
|
||||
timestamps: true,
|
||||
validate: {
|
||||
contentOrImage() {
|
||||
const hasContent = this.content && this.content.trim().length > 0;
|
||||
if (!hasContent && !this.imageFilename) {
|
||||
throw new Error('Message must have content or an image');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Message;
|
||||
Reference in New Issue
Block a user