feat: checking for whatsapp session Id on ticket and message creation

This commit is contained in:
canove
2020-09-06 14:22:05 -03:00
parent 371477aa98
commit b793d28e60
7 changed files with 60 additions and 6 deletions

View File

@@ -39,6 +39,10 @@ class Ticket extends Sequelize.Model {
static associate(models) {
this.belongsTo(models.Contact, { foreignKey: "contactId", as: "contact" });
this.belongsTo(models.User, { foreignKey: "userId", as: "user" });
this.belongsTo(models.Whatsapp, {
foreignKey: "whatsappId",
as: "whatsapp",
});
this.hasMany(models.Message, { foreignKey: "ticketId", as: "messages" });
}
}

View File

@@ -23,6 +23,10 @@ class Whatsapp extends Sequelize.Model {
return this;
}
static associate(models) {
this.hasMany(models.Ticket, { foreignKey: "whatsappId", as: "tickets" });
}
}
module.exports = Whatsapp;