Fix twilio settings.

This commit is contained in:
Nawaz Dhandala 2020-09-14 17:25:49 +09:00
parent f1803ea6bd
commit b23001b0ea
8 changed files with 25 additions and 14 deletions

View File

@ -11,4 +11,4 @@ REDIS_HOST=localhost
CLUSTER_KEY=f414c23b4cdf4e84a6a66ecfd528eff2
TEST_TWILIO_NUMBER=+919910568840
# IS_SAAS_SERVICE=true
# ENCRYPTION_KEY=01234567890123456789012345678901
ENCRYPTION_KEY=01234567890123456789012345678901

View File

@ -46,7 +46,7 @@ router.get('/:projectId', getUser, isAuthorized, async function(req, res) {
try {
const projectId = req.params.projectId;
const smsSmtp = await SmsSmtpService.findOneBy({ projectId });
return sendItemResponse(req, res, smsSmtp);
return sendItemResponse(req, res, smsSmtp || {});
} catch (error) {
return sendErrorResponse(req, res, error);
}

View File

@ -7,7 +7,7 @@ const twilioSchema = new Schema({
authToken: String,
phoneNumber: String,
iv: Schema.Types.Buffer,
enabled: { type: Boolean, default: true },
enabled: { type: Boolean, default: false },
createdAt: {
type: Date,
default: Date.now,

View File

@ -165,7 +165,7 @@ module.exports = {
}
query.deleted = false;
let twilio = await TwilioModel.findOne(query)
const twilio = await TwilioModel.findOne(query)
.sort([['createdAt', -1]])
.populate('projectId', 'name')
.lean();
@ -176,9 +176,6 @@ module.exports = {
);
delete twilio.iv;
}
if (!twilio) {
twilio = {};
}
return twilio;
} catch (error) {

View File

@ -35,7 +35,7 @@ const _this = {
error.code = 400;
return error;
}
return new twilio(accountSid, authToken);
return twilio(accountSid, authToken);
},
getSettings: async () => {
@ -173,7 +173,9 @@ const _this = {
customTwilioSettings.accountSid,
customTwilioSettings.authToken
);
const message = await twilioClient.messages.create(options);
return message;
} else {
const creds = await _this.getSettings();

View File

@ -1,10 +1,18 @@
# Running Fyipe
## Running this project in local environment.
- Run MongoDB and Redis manually on port 27017 and 6379 respectively. (You can do this with docker)
- If Docker and Docker compose is not your thing, you can run `npm install` and `npm run dev` on projects you want to work on. Ideally you would need to run those commands in `accounts`, `backend`, `probe`, `dashboard`, and `status-page` in seperate terminal instances to run the basic app.
## Running this project in local environment (without docker compose, recommended if you're doing active development).
## Running with docker compose
- Run MongoDB and Redis manually on port 27017 and 6379 respectively. You can do this with docker below:
```
mkdir ~/mongodata # This is where all of your Fyipe MongoDB data will be stored.
docker run -d -p 27017:27017 -v ~/mongodata:/data/db mongo:latest
docker run -d -p 6379:6379 redis:latest
```
- You can run `npm install` and `npm run dev` on projects you want to work on. Ideally you would need to run those commands in `accounts`, `backend`, `probe`, `dashboard`, and `status-page` in seperate terminal instances to run the basic app.
## Running with docker compose (with docker-compose, recommended if you're actively testing the app)
- Before you run this project locally, please make sure you're on Ubuntu or on a Mac machine.
- Install Docker and Docker Compose.

View File

@ -1,3 +1,9 @@
# This document is for launching Fyipe VM's on Azure, GCP and AWS.
# Follow the installation steps below.
# Azure: https://docs.microsoft.com/en-us/azure/marketplace/partner-center-portal/azure-vm-create-offer#technical-configuration
# Add these lines to: sudo crontab -e
# Run this on Reboot.

View File

@ -3,10 +3,8 @@
# This is used to install Fyipe on a standalone VM
# This is usally used for CI/CD testing, and to update VM's on GCP, Azure and AWS.
# Flush all repos
# If this is the first install, then helm wont be found.
if [[ ! $(which helm) ]]
then
echo "RUNNING COMMAND: sudo rm /etc/apt/sources.list || echo 'File not found'"