Skip to content

Commit

Permalink
Merge pull request #202 from billbarsch/myzap3.0
Browse files Browse the repository at this point in the history
Myzap3.0
  • Loading branch information
jhowbhz authored Jul 15, 2024
2 parents c8f5e0b + f095abd commit 2177133
Show file tree
Hide file tree
Showing 655 changed files with 297,560 additions and 5,295 deletions.
78 changes: 32 additions & 46 deletions .env_exemplo
Original file line number Diff line number Diff line change
@@ -1,59 +1,45 @@
################################################################################
# File: .env #
# Project: MyZap2.0 #
# Created Date: 2021-06-21 12:52:13 #
# Author: Eduardo Policarpo #
# Last Modified: 2021-06-21 12:59:26 #
# Modified By: Eduardo Policarpo #
################################################################################

# Defina o numero da porta a ser usada pela API.
############################################
# Conheça o DivulgaWhats #
# https://whitelabel.divulgawhats.com.br #
############################################

# Host of API
HOST_SSL=

# Server port
PORT=3333

# Defina o HOST aqui caso voce utilize uma VPS deve ser colocado o IP da VPS
# Exemplos:
# HOST=204.202.54.2 => IP da VPS, caso esteja usando virtualização via hospedagem
# HOST=10.0.0.10 => IP da VM, caso esteja usando virtualização
# HOST=localhost => caso esteja usando na sua proprima maquina local
# Create your token protect API
TOKEN=123456

HOST=http://localhost
// colocar o http ou https
# Version of API
VERSION="latest"

# CASO UTILIZE CERTIFICADO SSL COM REDIRECIONAMENTO DE PORTA, DEVE PREENCHER A VARIAVEL DOMAIN_SSL
# CASO DE NÃO SER CONFIGURADO UM DOMÍNIO MATENHA A VARIAVEL DOMAIN_SSL VAZIA
# Exemplos:
# DOMAIN_SSL=api.myzap.com.br ou myzap.com.br
# DOMAIN_SSL=

DOMAIN_SSL=
# Version of WhatsApp
# https://wppconnect.io/pt-BR/whatsapp-versions/
# WHATSAPP_VERSION="2.2409.x"

# ENGINE: setar o valor correspondente a ENGINE que deseja utilizar
# 1 - para WhatsApp-Web-JS / 2 - para WPPCONNECT / 3 - para VENOM
ENGINE=2
DIVULGAWHATS_TOKEN=""

# Caso utilize certificado SSL defina a variavel HTTPS=1 e informe o diretorio nas variaveis
HTTPS=0
# SSL_KEY_PATH=/etc/letsencrypt/live/yourdomain.net/privkey.pem
# SSL_CERT_PATH=/etc/letsencrypt/live/yourdomain.net/cert.pem
# Use chromium of default
USE_CHROME=true

# TOKEN => Aqui voce define uma chave de segurança para Uso da API,
# só conseguira conectar e criar sessões informando o codigo definido Aqui
# Hiden logs from database
PRODUCTION=true

TOKEN=
# Engine 1 - Venom / Engine 2 - WPPConnect
ENGINE=1

#firebase database config
# Nesta sesão voce deve configurar os seus dados de autenticação da conta firebase
# Default configs
HTTPS=0
HOST=http://127.0.0.1

API_KEY=
AUTH_DOMAIN=
PROJECT_ID=
STORAGE_BUCKET=
MESSAGING_SENDER_ID=
APP_ID=
COMPANY="MYZAP"
LOGO="https://upload.wikimedia.org/wikipedia/commons/f/f7/WhatsApp_logo.svg"

# As Sessoes criadas na API são salvas no banco de dados GOOGLE firebase
# Caso queira que ao iniciar a API todas as sessões salvas sejam inicializadas automaticamente
START_ALL_SESSIONS=true
FORCE_CONNECTION_USE_HERE=true

# Caso queira forçar a reconexão da API em caso de desconexão do WhatsApp defina true
FORCE_CONNECTION_USE_HERE=true
CORS_ORIGIN="*"
TIME_TYPING=800
JWT_SECRET=
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ node_modules/
tokens/
.vscode/
.env
teste.js
teste.js
instances/
database/
logs/
24 changes: 24 additions & 0 deletions Models/cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { DataTypes, Model } = require('sequelize');

module.exports = (sequelize) => {

class Cache extends Model {
// Métodos

static associate(models) {
// define association here
}
}

Cache.init({
number: DataTypes.STRING,
profile: DataTypes.STRING,
updated_at: DataTypes.DATE,
created_at: DataTypes.DATE,
}, {
sequelize,
modelName: 'Cache', // Nome do modelo
});

return Cache;
};
25 changes: 25 additions & 0 deletions Models/company.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { DataTypes, Model } = require('sequelize');

module.exports = (sequelize) => {

class Company extends Model { }

Company.init({
cnpj: DataTypes.STRING,
company: DataTypes.STRING,
cpf: DataTypes.STRING,
email: DataTypes.STRING,
logo: DataTypes.STRING,

created_at: DataTypes.DATE,
updated_at: DataTypes.DATE,

}, {
sequelize,
tableName: 'Companys', // Nome da tabela
modelName: 'Company', // Nome do modelo
timezone: '-03:00', // Timezone
});

return Company;
};
30 changes: 30 additions & 0 deletions Models/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { DataTypes, Model } = require('sequelize');

module.exports = (sequelize) => {

class Configuration extends Model {
// Métodos

static associate(models) {
// define association here
}
}

Configuration.init({
port: DataTypes.STRING,
host: DataTypes.STRING,
host_ssl: DataTypes.STRING,
company: DataTypes.STRING,
logo: DataTypes.STRING,
cors_origin: DataTypes.STRING,
time_typing: DataTypes.INTEGER,
version: DataTypes.STRING,
created_at: DataTypes.DATE,
updated_at: DataTypes.DATE,
}, {
sequelize,
modelName: 'Configuration', // Nome do modelo
});

return Configuration;
};
68 changes: 68 additions & 0 deletions Models/device.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const { DataTypes, Model } = require('sequelize');

module.exports = (sequelize) => {
class Device extends Model {

static associate(models) {
// Definindo a associação entre Device e User
Device.belongsTo(models.User, {
foreignKey: 'user_id', // Chave estrangeira em Device
as: 'user'
});
}

}

Device.init({
session: DataTypes.STRING,
sessionkey: DataTypes.STRING,
user_id: DataTypes.INTEGER,
wh_qrcode: DataTypes.STRING,
wh_connect: DataTypes.STRING,
wh_message: DataTypes.STRING,
wh_status: DataTypes.STRING,
status: DataTypes.STRING,
state: DataTypes.STRING,
qrCode: DataTypes.STRING,
attempts: DataTypes.INTEGER,
urlCode: DataTypes.STRING,

last_start: DataTypes.DATE,
attempts_start: DataTypes.INTEGER,

number: DataTypes.STRING,
wa_js_version: DataTypes.STRING,
wa_version: DataTypes.STRING,

battery: DataTypes.STRING,
blockStoreAdds: DataTypes.STRING,
clientToken: DataTypes.STRING,
connected: DataTypes.BOOLEAN,
is24h: DataTypes.BOOLEAN,
isResponse: DataTypes.BOOLEAN,
lc: DataTypes.STRING,
lg: DataTypes.STRING,
locales: DataTypes.STRING,
platform: DataTypes.STRING,
plugged: DataTypes.BOOLEAN,
protoVersion: DataTypes.STRING,
pushname: DataTypes.STRING,
ref: DataTypes.STRING,
refTTL: DataTypes.STRING,
serverToken: DataTypes.STRING,
smbTos: DataTypes.STRING,
tos: DataTypes.STRING,

last_connect: DataTypes.DATE,
last_disconnect: DataTypes.DATE,
created_at: DataTypes.DATE,
updated_at: DataTypes.DATE,

}, {
sequelize,
modelName: 'Device', // Nome do modelo
timezone: '-03:00', // Timezone
});

return Device;
};
43 changes: 43 additions & 0 deletions Models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const process = require('process');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};

let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}

fs
.readdirSync(__dirname)
.filter(file => {
return (
file.indexOf('.') !== 0 &&
file !== basename &&
file.slice(-3) === '.js' &&
file.indexOf('.test.js') === -1
);
})
.forEach(file => {
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
db[model.name] = model;
});

Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});

db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
24 changes: 24 additions & 0 deletions Models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const { DataTypes, Model } = require('sequelize');

module.exports = (sequelize) => {
class User extends Model {

static associate(models) {
// define association here
}
}
User.init({
first_name: DataTypes.STRING,
last_name: DataTypes.STRING,
email: DataTypes.STRING,
password: DataTypes.STRING,
cpf: DataTypes.STRING,
phone: DataTypes.STRING,
}, {
sequelize,
modelName: 'User',
});
return User;
};
Loading

0 comments on commit 2177133

Please sign in to comment.