Skip to content

Commit

Permalink
Merge pull request #59 from Skill-Sync/SS-1.4-Medhat
Browse files Browse the repository at this point in the history
Ss 1.4 medhat
  • Loading branch information
MAES-Pyramids authored Sep 15, 2023
2 parents 3b460c1 + 27ae2bc commit b2f650d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ yarn-error.log*


config.env
*.env
*.env
*.rdb
8 changes: 7 additions & 1 deletion config.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ EMAIL_USERNAME=demo22793@gmail.com
EMAIL_PASSWORD=utnxhdstjozjzxlh
EMAIL_HOST=gmail

CLIENT_URL=DEMO.com
CLIENT_URL=DEMO.com

#dyte configration
DYTE_BASE_URL=https://api.dyte.io/v2
DYTE_ORG_ID=ca9bb773-faa3-4983-a7a4-d0cddd07818d
DYTE_API_KEY=ec19c2d69a52287711b1
DYTE_API_TOKEN=Y2E5YmI3NzMtZmFhMy00OTgzLWE3YTQtZDBjZGRkMDc4MThkOmVjMTljMmQ2OWE1MjI4NzcxMWIx
33 changes: 20 additions & 13 deletions src/utils/dyte.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const axios = require('axios').default;

const DYTE_API_BASE_URL = 'https://api.dyte.io/v2';
const DYTE_API_TOKEN = `${process.env.ORG_ID}:${process.env.API_KEY}`;
// const DYTE_API_Meeting_URL = 'https://api.dyte.io/v2/meetings';
// const DYTE_API_Adding_URL = `https://api.dyte.io/v2
// /meetings/{meeting_id}/participants`;

exports.createDyteMeeting = async function(title) {
exports.createDyteMeeting = async title => {
try {
const response = await axios.post(
`${DYTE_API_BASE_URL}/meetings`,
`${process.env.DYTE_BASE_URL}/meetings`,
{
title: `${title}`,
preferred_region: 'ap-south-1',
Expand All @@ -16,29 +17,35 @@ exports.createDyteMeeting = async function(title) {
{
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${DYTE_API_TOKEN}`
Authorization: `Basic ${process.env.DYTE_API_TOKEN}`
}
}
);

return response.data.id;
// console.log(response.data.data.id);

return response.data.data.id;
} catch (error) {
console.error('Error creating Dyte meeting:', error);
throw error;
console.error('Error creating Dyte meeting:', error.message);
// throw error;
}
};

//add participant -->auth token

exports.addUserToMeeting = async function(meetingId, userData) {
try {
const url = `${DYTE_API_BASE_URL}/meetings/${meetingId}/participants`;
const url = `${process.env.DYTE_BASE_URL}/meetings/${meetingId}/participants`;
const response = await axios.post(url, userData, {
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${DYTE_API_TOKEN}`
Authorization: `Basic ${process.env.DYTE_API_TOKEN}`
}
});

return response.data.token;
console.log(response.data.data.token);

return response.data.data.token;
} catch (error) {
console.error('Error adding user to Dyte meeting:', error);
throw error;
Expand All @@ -49,5 +56,5 @@ const userData = {
name: '',
picture: '',
preset_name: '',
custom_participant_id: ''
};
custom_participant_id: ''
};
19 changes: 17 additions & 2 deletions src/utils/sockets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const User = require('../models/user.model');
const { createClient } = require('redis');
const dyte = require('./dyte');

const redisClient = createClient();

Expand Down Expand Up @@ -135,7 +136,7 @@ const listen = function(io) {
console.log(socketId, 'socketId');
//1- get user to user skills
// console.log('connected');
socket.on('start-search', async function({
socket.on('start-searching', async function({
userId,
wantedInnerSkill,
userSocketId
Expand Down Expand Up @@ -335,7 +336,21 @@ const listen = function(io) {
}
});

// socket.on('disconnect', reason => {});
socket.on('hi', async function({ userId }) {
const meetingID = await dyte.createDyteMeeting('test');
console.log(meetingID);
const token = await dyte.addUserToMeeting(meetingID, {
// name: 'test',
// picture: 'test',
preset_name: 'test',
custom_participant_id: 'sdafhosadkfhoksadf'
});
console.log(token);
});

socket.on('disconnect', reason => {
console.log('disconnected', reason);
});
});
};

Expand Down

0 comments on commit b2f650d

Please sign in to comment.