Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
bcf0d48
changes from server
May 25, 2021
6a3f713
Merge branch 'dev' of https://github.com/shouse/metis into dev
May 25, 2021
acc5d16
socket improvements
joramirezStackit May 28, 2021
8d9b186
merge from dev
joramirezStackit May 28, 2021
80e51bb
Ability to enable PN for each channel
joramirezStackit Jun 1, 2021
4383e25
Fix for loading spinner login page
isa1az Jun 3, 2021
8ac6686
Merge pull request #5 from jupiter-project/fix/login-spinner
joramirezStackit Jun 4, 2021
9857dbb
Merge pull request #6 from jupiter-project/feature/push-notification-…
joramirezStackit Jun 4, 2021
ac84ea4
Merge branch 'dev' of https://github.com/jupiter-project/metis into dev
Jun 4, 2021
c6374a6
enabling logging errors on mongo db
joramirezStackit Jun 4, 2021
038524d
Merge branch 'dev' of https://github.com/jupiter-project/metis into dev
Jun 4, 2021
2142f8d
push notification improvements
joramirezStackit Jun 7, 2021
552a921
Merge pull request #7 from jupiter-project/fix/push-notifications
joramirezStackit Jun 7, 2021
480e534
Merge branch 'dev' of https://github.com/jupiter-project/metis into dev
Jun 7, 2021
84dc787
Check and fix the issue with socket being disconnected
joramirezStackit Jun 9, 2021
181c015
Metis app is always displaying 1 notification bubble even if you don'…
joramirezStackit Jun 10, 2021
033d5c7
added dependency for buntu server
Jun 10, 2021
adf0a78
The metis service deployment instructions are added using the docker-…
Jun 10, 2021
4b43384
Added url samples that can be used when using redis and mongo as imag…
Jun 10, 2021
1d5dbef
Command to change from branch to dev is added
Jun 10, 2021
cc7ff9c
--build is mandatory to run docker-compose up
Jun 10, 2021
64e0c46
increase memory
Jun 10, 2021
4463726
merge from dev
Jun 10, 2021
665ff75
logger issues related to memory leak
joramirezStackit Jun 11, 2021
8b3a2e9
solved code conflict
joramirezStackit Jun 11, 2021
60d313a
PN somethings are not being received, it may be related to Mute channels
joramirezStackit Jun 11, 2021
be90d6f
variable added to mongo
joramirezStackit Jun 11, 2021
7d73808
Merge pull request #8 from jupiter-project/feature/socket-diconnection
joramirezStackit Jun 12, 2021
80bd721
Merge pull request #9 from jupiter-project/fix/badgeCount
joramirezStackit Jun 12, 2021
3591abc
Merge pull request #10 from jupiter-project/fix/logger-issues
joramirezStackit Jun 12, 2021
29160dd
Merge pull request #11 from jupiter-project/fix/notification-mute-cha…
joramirezStackit Jun 12, 2021
0d46c59
Implement ability to mention in channel
joramirezStackit Jun 14, 2021
e453fed
Merge pull request #12 from jupiter-project/feature/ability-to-mention
joramirezStackit Jun 14, 2021
599a818
When replying a message, we are showing an object in the preview of t…
joramirezStackit Jun 18, 2021
365e03b
Merge pull request #14 from jupiter-project/fix/pn-reply-messages
joramirezStackit Jun 18, 2021
9cddb43
Docker image size reduction
isa1az Jun 8, 2021
826276c
Creating deployment flow
isa1az Jun 16, 2021
31bf184
Merge pull request #15 from jupiter-project/feature/devops
isaiastack Jun 18, 2021
3ed764a
isa1az Jun 18, 2021
958a5b1
Merge pull request #16 from jupiter-project/feature/metrics
joramirezStackit Jun 18, 2021
da6448a
Refactor Metis Logging+Containers
joramirezStackit Jun 20, 2021
d6e5b4d
logging configuration and socket ping timeout increased
joramirezStackit Jun 20, 2021
f2c8a84
Merge pull request #17 from jupiter-project/feature/logging-containers
isaiastack Jun 20, 2021
4af66b2
stream logger configuration fixed
joramirezStackit Jun 22, 2021
c73f769
Merge pull request #18 from jupiter-project/fix/stream-logger
reyesrene Jun 22, 2021
fd13366
fix transport logic
joramirezStackit Jun 22, 2021
bc9635d
Merge pull request #19 from jupiter-project/fix/stream-logger
reyesrene Jun 22, 2021
d1a7759
socket disconnection error
joramirezStackit Jun 24, 2021
e8e87e5
Merge pull request #20 from jupiter-project/fix/socket-io-disconnetion
reyesrene Jun 24, 2021
92e1a91
socket namespace fixed
joramirezStackit Jun 24, 2021
0830d50
Merge pull request #21 from jupiter-project/fx/socket-namespace
reyesrene Jun 24, 2021
6b0a0e4
push notification fixed
joramirezStackit Jun 27, 2021
4d50cb2
algorithm changed from 128 to 256 and login page fixed
joramirezStackit Jun 29, 2021
12b300b
ws socket
Jun 30, 2021
0a7c4ab
jupiter socket comunication implemented
anggeloexe Jun 30, 2021
33e3c0c
jupiter socket comunication implemented
anggeloexe Jun 30, 2021
194b86a
send to log
anggeloexe Jun 30, 2021
5687156
save transaction blocks into mongodb
Jul 1, 2021
fd2e66b
isa1az Jul 1, 2021
e1ff645
Merge pull request #23 from jupiter-project/fix/pushnotifications
isaiastack Jul 1, 2021
b8891ba
Merge pull request #26 from jupiter-project/feature/devops-update
joramirezStackit Jul 1, 2021
4698b49
revert docker-compose.yml changes
Jul 1, 2021
a233d4c
Merge pull request #25 from jupiter-project/feature/jupiter_websocket
isaiastack Jul 1, 2021
e31fd3d
isa1az Jul 1, 2021
0f4d764
Merge pull request #27 from jupiter-project/fix/pm2
isaiastack Jul 1, 2021
3f45f67
socket disconnection fixed
joramirezStackit Jul 2, 2021
30492e4
Merge pull request #28 from jupiter-project/fix/websocket
joramirezStackit Jul 2, 2021
f812ac3
ecma5 error
joramirezStackit Jul 6, 2021
f43786f
Merge pull request #29 from jupiter-project/fix/ecma-error-logger
reyesrene Jul 6, 2021
fc6d649
isa1az Jul 12, 2021
b424be0
isa1az Jul 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
Gravity Documentation - v1.pdf
public/bundle.js
10 changes: 10 additions & 0 deletions .env_sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ EMAIL='[REPLACE_EMAIL]'
REFRESH_TOKEN='[REPLACE_REFRESH_TOKEN]'
CLIENT_SECRET='[REPLACE_CLIENT_SECRET]'
CLIENT_ID='[REPLACE_CLIENT_ID]'
REDIS_HOST=redis
REDIS_PORT=6379
MONGO_URL=mongodb://mongo:27017/metisPN
URL_DB=mongodb://mongo:27017/metisPN
NODE_OPTIONS=--max_old_space_size=4096
S3_STREAM_ENDPOINT='sfo3.digitaloceanspaces.com'
S3_STREAM_KEY='ZS6SNTVEW45MWFOZZHB5'
S3_STREAM_SECRET_KEY='pFancYkzwzT57TJBdu2pAFdbY/KB+WdoX7kYxAuu7Gg'
S3_STREAM_BUCKET_DEV='metis-logs-dev'
S3_STREAM_BUCKET_PROD='metis-logs-prod'
42 changes: 42 additions & 0 deletions .github/workflows/dev.workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and publish Metis Dev

on:
push:
branches: [ dev ]
workflow_dispatch:

jobs:
build_and_push:
environment: dev
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Build image
run: docker build -t metis .
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Tag image
run: docker tag metis ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ secrets.DIGITALOCEAN_APP_TAG }}
- name: Push image to DO Container Registry
run: docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ secrets.DIGITALOCEAN_APP_TAG }}
- name: Launch image
run: doctl apps create-deployment ${{ secrets.DIGITALOCEAN_APP_ID }} --wait
- name: Channel specific notification Slack
uses: adamkdean/simple-slack-notify@master
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
channel: '#general'
text: 'A new version of Metis Dev has been deployed'
# - name: send custom message to Telegram
# uses: appleboy/telegram-action@master
# with:
# to: ${{ secrets.TELEGRAM_TO }}
# token: ${{ secrets.TELEGRAM_TOKEN }}
# message: |
# The ${{ github.event_name }} event triggered final step. This is only a test.
42 changes: 42 additions & 0 deletions .github/workflows/prod.workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and publish Metis Prod

on:
push:
branches: [ release/** ]
workflow_dispatch:

jobs:
build_and_push:
environment: production
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Build image
run: docker build -t metis .
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Tag image
run: docker tag metis ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ secrets.DIGITALOCEAN_APP_TAG }}
- name: Push image to DO Container Registry
run: docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ secrets.DIGITALOCEAN_APP_TAG }}
- name: Launch image
run: doctl apps create-deployment ${{ secrets.DIGITALOCEAN_APP_ID }} --wait
- name: Channel specific notification Slack
uses: adamkdean/simple-slack-notify@master
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
channel: '#general'
text: 'A new version of Metis Prod has been deployed'
# - name: send custom message to Telegram
# uses: appleboy/telegram-action@master
# with:
# to: ${{ secrets.TELEGRAM_TO }}
# token: ${{ secrets.TELEGRAM_TOKEN }}
# message: |
# The ${{ github.event_name }} event triggered final step. This is only a test.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ dev

.idea
/logs/log-api.log
/data
/mongodb_data
/.scannerwork
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ To build your own local Metis instance to truly protect your communications!
7. Open your browser and type in 127.0.0.1:4000

This is a 100% local instance of Metis that talks to Jupiter's blockchain. Anyone can complete these steps and create their own private, encrypted, and shielded communications. Even though this is a local only instance, you can log into ANY Metis instance with your credentials and it will still work and have all your past conversations waiting for you! This is due to all your conversations being encrypted and stored on Jupiter's decentralized blockchain.

If you want to start the system using docker, it is necessary to execute the following steps.

1. Install **docker**
2. Install **docker-compose**
3. Clone the repository code https://github.com/jupiter-project/metis.git
`git clone https://github.com/jupiter-project/metis.git`
4. It is necessary to switch to the dev branch
`cd metis`
`git checkout dev`
`git pull`
5. Inside the code folder execute the command `docker-compose up --build`
6. This command will start a mongodb container, a redis container and a metis container.
7. Open your browser and type in 127.0.0.1:4000
2 changes: 1 addition & 1 deletion config/apn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { join } = require('path');

const IS_PRODUCTION = process.env.NODE_ENV === 'production';
const IS_PRODUCTION = ['qa', 'staging', 'production'].includes(process.env.NODE_ENV);

const getApnOptions = () => ({
pfx: join(__dirname, '../certificates', 'apn.p12'),
Expand Down
2 changes: 1 addition & 1 deletion config/gravity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ class Gravity {
APP_ACCOUNT: passphrase,
APP_ACCOUNT_ADDRESS: address,
APP_PUBLIC_KEY: publicKey,
ENCRYPT_ALGORITHM: 'aes-128-cbc',
ENCRYPT_ALGORITHM: 'aes-256-cbc',
ENCRYPT_PASSWORD: password,
APP_ACCOUNT_ID: publicKey,
};
Expand Down
14 changes: 8 additions & 6 deletions config/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const logger = require('../utils/logger')(module);
* @param badgeCount Integer of updated badge count
* @param payload Extra data
* @param category Used to identify push on device
* @param delay delay on milliseconds for push notification
* @returns {Promise}
*/
async function sendPushNotification(tokens, alert, badgeCount, payload, category) {
function sendPushNotification(tokens, alert, badgeCount, payload, category, delay = 1) {
logger.info('[Notifications][sendPushNotification] -> Start');

const apnProvider = new apn.Provider(APN_OPTIONS);
Expand All @@ -27,11 +28,12 @@ async function sendPushNotification(tokens, alert, badgeCount, payload, category

notification.category = `metis.category.${category || 'default'}`;

// Send the actual notification
const result = await apnProvider.send(notification, tokens);

// Show the result of the send operation:
logger.info(JSON.stringify(result));
setTimeout(async () => {
// Send the actual notification
const result = await apnProvider.send(notification, tokens);
// Show the result of the send operation:
logger.info(JSON.stringify(result));
}, delay);
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const metisSignup = (passport) => {
}, req.flash('signupMessage', 'Your account has been created and is being saved into the blockchain. Please wait a couple of minutes before logging in.'));
})
.catch((err) => {
logger.error(err);
logger.error('USER CREATION FAILED', JSON.stringify(err));
let errorMessage;
if (err.verification_error !== undefined && err.verification_error === true) {
err.errors.forEach((x) => {
Expand All @@ -112,7 +112,7 @@ const metisSignup = (passport) => {
} else {
errorMessage = err.errors;
}
return done(null, false, req.flash('signupMessage', errorMessage));
return done(null, false, { message: errorMessage });
});
});

Expand Down
12 changes: 11 additions & 1 deletion controllers/_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,21 @@ module.exports = (app, passport, React, ReactDOMServer) => {

passport.authenticate('gravity-login', (err, userInfo) => {
if (err) return next(err);
if (!userInfo) {
const errorMessage = 'There was an error in verifying the passphrase with the Blockchain';

logger.error(new Error(errorMessage));

return res.status(400).json({
success: false,
message: errorMessage,
});
}

const accountData = JSON.parse(gravity.decrypt(userInfo.accountData));

userInfo.publicKey = accountData.publicKey;
res.json(userInfo);
return res.json(userInfo);
})(req, res, next);
});

Expand Down
80 changes: 60 additions & 20 deletions controllers/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,42 @@ import { messagesConfig } from '../config/constants';
import Invite from '../models/invite';
import Channel from '../models/channel';
import Message from '../models/message';
import { findNotificationInfoByAliasOrJupId } from '../services/notificationService';
import metis from '../config/metis';

const connection = process.env.SOCKET_SERVER;
const device = require('express-device');
const Notifications = require('../models/notifications');
const { sendPushNotification } = require('../config/notifications');
const logger = require('../utils/logger')(module);

const decryptUserData = (req) => {
return JSON.parse(gravity.decrypt(req.session.accessData));
const { hasJsonStructure } = require('../utils/utils');

const decryptUserData = req => JSON.parse(gravity.decrypt(req.session.accessData));

const getPNTokensAndSendPushNotification = (members, senderAlias, channel, message, title) => {
if (members && Array.isArray(members) && !_.isEmpty(members)) {
findNotificationInfoByAliasOrJupId(members, channel.id)
.then((data) => {
if (data && Array.isArray(data) && !_.isEmpty(data)) {
const tokens = _.map(data, 'token');
const payload = { title, channel };
sendPushNotification(tokens, message, 0, payload, 'channels');
}
})
.catch((error) => {
logger.error(JSON.stringify(error));
});
}
};

const getPNTokensAndSendPushNotification = (members, channelName, senderAlias) => {
Notifications.find({ alias: { $in: members }, token: { $ne: '' } })
const getPNTokenAndSendInviteNotification = (senderAlias, recipientAliasOrJupId, channelName) => {
findNotificationInfoByAliasOrJupId([recipientAliasOrJupId])
.then((data) => {
if (data && Array.isArray(data) && !_.isEmpty(data)) {
const tokens = _.map(data, 'token');
const alert = `${senderAlias} has sent a message to '${channelName}' channel`;
const payload = { title: 'New Message' };
sendPushNotification(tokens, alert, 1, payload, 'channels');
const alert = `${senderAlias} invited you to the channel "${channelName}"`;
const payload = { title: 'Invitation', isInvitation: true };
const threeMinutesDelay = 180000;
sendPushNotification(tokens, alert, 0, payload, 'channels', threeMinutesDelay);
}
})
.catch((error) => {
Expand Down Expand Up @@ -60,8 +77,7 @@ module.exports = (app, passport, React, ReactDOMServer) => {
});

app.post('/reportUser', controller.isLoggedIn, (req, res) => {

let transporter = mailer.createTransport({
const transporter = mailer.createTransport({
service: 'gmail',
auth: {
type: 'OAuth2',
Expand Down Expand Up @@ -163,6 +179,10 @@ module.exports = (app, passport, React, ReactDOMServer) => {

try {
response = await invite.send();
const recipient = _.get(data, 'recipient', '');
const sender = _.get(data, 'senderAlias', '');
const channelName = _.get(data, 'channel.name', '');
getPNTokenAndSendInviteNotification(sender, recipient, channelName);
} catch (e) {
logger.error(e);
response = e;
Expand Down Expand Up @@ -258,7 +278,7 @@ module.exports = (app, passport, React, ReactDOMServer) => {
*/
app.post('/data/messages', controller.isLoggedIn, async (req, res) => {
const { maxMessageLength } = messagesConfig;
const hasMessage = _.get(req, 'body.data.message', null);
let hasMessage = _.get(req, 'body.data.message', null);
let response;

if (hasMessage && hasMessage.length <= maxMessageLength) {
Expand All @@ -270,25 +290,45 @@ module.exports = (app, passport, React, ReactDOMServer) => {
message.record.sender = _.get(req, 'user.record.account', req.body.user.account);
// accountData
// const userData = decryptUserData(req);
let members = _.get(req, 'body.members', []);

let { members } = await metis.getMember({
channel: tableData.account,
account: tableData.publicKey,
password: tableData.password,
});

const mentions = _.get(req, 'body.mentions', []);
const channel = _.get(req, 'body.channel', []);
const channelName = _.get(tableData, 'name', 'a channel');
const accessData = _.get(req, 'session.accessData', req.body.user.accountData);
const userData = JSON.parse(gravity.decrypt(accessData));
try {
const data = await message.sendMessage(userData, tableData, message.record);
response = data;

if (Array.isArray(members)) {
members = members.filter(member => member !== message.record.name);
if (Array.isArray(members) && members.length > 0) {
const senderName = message.record.name;
members = members.filter(member => member !== senderName && !mentions.includes(member));

if (hasJsonStructure(hasMessage)) {
hasMessage = JSON.parse(hasMessage);
hasMessage = hasMessage.fromMsj || '';
}

// push notification for members
const pnTitle = `${senderName} @ ${channelName}`;
getPNTokensAndSendPushNotification(members, senderName, channel, hasMessage, pnTitle);

// Push notification for mentioned members
const pnmTitle = `${senderName} has tagged @ ${channelName}`;
getPNTokensAndSendPushNotification(mentions, senderName, channel, hasMessage, pnmTitle);
}
getPNTokensAndSendPushNotification(members, channelName, message.record.name);
} catch (e) {
logger.error(e);
logger.error('[/data/messages]', JSON.stringify(e));
response = { success: false, fullError: e };
}
} else {
response = { success: false, messages: [`Message exceeds allowable limit of ${maxMessageLength} characters`] };
logger.error(response);
response = { success: false, messages: [`Message is not valid or exceeds allowable limit of ${maxMessageLength} characters`] };
logger.error(JSON.stringify(response));
}
res.send(response);
});
Expand Down
5 changes: 0 additions & 5 deletions controllers/pn-token.js

This file was deleted.

7 changes: 7 additions & 0 deletions controllers/pushNotificationController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const Notification = require('../services/pushNotificationTokenService');

module.exports = (app) => {
app.post('/pn_token', Notification.addTokenNotification);
app.put('/mute_channels', Notification.editMutedChannels);
app.get('/mute_channels/:alias', Notification.findMutedChannels);
};
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
version: "3"
services:
mongo:
image: "mongo:3.6"
volumes:
- ./data/db:/data/db
ports:
- 27017:27017
- 28017:28017
redis:
image: "redis"
ports:
- "6380:6379"
metis:
build: .
depends_on:
- mongo
- redis
ports:
- "4000:4000"
Expand All @@ -16,5 +24,8 @@ services:
- ./:/apps/metis
- /apps/metis/node_modules
environment:
- MONGO_URL=mongodb://mongo:27017/metisPN
- URL_DB=mongodb://mongo:27017/metisPN
- REDIS_HOST=redis
- REDIS_PORT=6379
- BUCKET_NAME=metis_s3
Loading