-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
removed user read call in sessions and added organization key to model #960
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on 11 Oct
require('dotenv').config() | ||
const materializedViewsService = require('@generics/materializedViews') | ||
|
||
/** @type {import('sequelize-cli').Migration} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr Remove copy in name, see if some better name can be given, please add comment in file what this migration does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aks30 its invalid file, not required
src/database/migrations/20241007083318-add organisation column to userExtention.js
Outdated
Show resolved
Hide resolved
src/services/users.js
Outdated
@@ -127,6 +165,8 @@ module.exports = class UserHelper { | |||
competency: userDetails.competency, | |||
designation: userDetails.designation, | |||
language: userDetails.language, | |||
organization_name: userDetails.organization.name, | |||
image: userDetails.image, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr we can add this in column i am thinking, anyways in ELEVATE we have user image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on 14 Oct
@@ -0,0 +1,3335 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr Let's move these files in project root, in sunbird-mentoring and mentoring
try { | ||
const { STRING } = Sequelize | ||
|
||
await queryInterface.addColumn('organization_extension', 'organization_name', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr let's call it name only
src/database/migrations/20241007083318-add organisation column to OrgExt.js
Outdated
Show resolved
Hide resolved
@@ -39,6 +39,7 @@ module.exports = (sequelize, DataTypes) => { | |||
}, | |||
mentee_visibility_policy: { type: DataTypes.STRING }, | |||
external_mentee_visibility_policy: { type: DataTypes.STRING }, | |||
organization_name: { type: DataTypes.STRING }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr rename it to just name please, Also update the corresponding DB diagrams for documentation as well.
try { | ||
const { STRING } = Sequelize | ||
|
||
await queryInterface.addColumn('organization_extension', 'organization_name', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr name can be an index if its fetched very often
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on 16 Oct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed partially on 13 Nov
@@ -24,6 +24,16 @@ const decrypt = async (encryptedEmail) => { | |||
throw err | |||
} | |||
} | |||
const emailEncryption = { encrypt, decrypt } | |||
|
|||
async function decryptAndValidate(data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr What validation happens here? Can we start adding function signature, name, description, argument examples and response signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are trying to decrypt the email if success it returns decrypted value else it returns false
} | ||
} | ||
|
||
static async getUsersByEmailIds(emailIds) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr Can we start adding function signatures, along with sample arguments and responses?
static async getUsersByEmailIds(emailIds) { | ||
try { | ||
const userFilterClause = | ||
emailIds.length === 0 ? '' : `email IN (${emailIds.map((id) => `'${id}'`).join(',')})` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr is the email column indexed? Is it encrypted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
email is not indexed. yes its encrypted.
should we add index for email ?
try { | ||
let orgReadUrl | ||
if (organizationId && db == true) { | ||
const organizationDetails = await organisationExtensionQueries.findOne({ organization_id: organizationId }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr don't we need org code based query as below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently we are not storing org code in OrganizationExtension
|
||
if (userId) profileUrl += `/${userId}` | ||
if (userDetails.image) { | ||
userDetails.image = await getDownloadableUrl(userDetails.image).result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr don't we have to check whether we have http path of just storage bucket path before making a call to user service even when db is true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added check in the getDownloadableUrl function
@@ -103,38 +142,90 @@ const fetchUserDetails = async ({ token, userId }) => { | |||
* @returns | |||
*/ | |||
|
|||
const getListOfUserDetails = function (userIds, excludeDeletedRecords = false) { | |||
const getListOfUserDetails = function (userIds, db = false, excludeDeletedRecords = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr Why default value is false here and true at other places? Also let's define function signatures in all functions we modify going forward?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function has used in migrations so I kept db = false as default.
// Enrich user details with roles and organization info | ||
userDetails.forEach(async (user) => { | ||
if (user.image) { | ||
user.image = await getDownloadableUrl(user.image).result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshSgr Why do we have to make a API call in loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently we can get only one path at time from user service API
No description provided.