Added movability of dialogs

This commit is contained in:
Torsten Schulz
2024-08-19 12:34:08 +02:00
parent 4b6ad3aefe
commit 16a59daf39
40 changed files with 1625 additions and 204 deletions

View File

@@ -0,0 +1,65 @@
import { sequelize } from '../../utils/sequelize.js';
import { DataTypes } from 'sequelize';
import { encrypt, decrypt } from '../../utils/encryption.js';
const ContactMessage = sequelize.define('contact_message', {
email: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
if (value) {
const encryptedValue = encrypt(value);
this.setDataValue('email', encryptedValue.toString('hex'));
}
},
get() {
const value = this.getDataValue('email');
if (value) {
return decrypt(Buffer.from(value, 'hex'));
}
}
},
message: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
if (value) {
const encryptedValue = encrypt(value);
this.setDataValue('message', encryptedValue.toString('hex'));
}
},
get() {
const value = this.getDataValue('message');
if (value) {
return decrypt(Buffer.from(value, 'hex'));
}
}
},
name: {
type: DataTypes.STRING,
allowNull: false,
set(value) {
if (value) {
const encryptedValue = encrypt(value);
this.setDataValue('name', encryptedValue.toString('hex'));
}
},
get() {
const value = this.getDataValue('name');
if (value) {
return decrypt(Buffer.from(value, 'hex'));
}
}
},
allowDataSave: {
type: DataTypes.BOOLEAN,
allowNull: false
},
}, {
tableName: 'contact_message',
timestamps: true,
schema: 'service',
underscored: true
});
export default ContactMessage;