Skip to content
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

feat: image service integrated with feature flag #2003

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

ivinayakg
Copy link
Contributor

@ivinayakg ivinayakg commented Apr 4, 2024

Date: 13/04/2024

Developer Name: Vinayak Goyal


Issue Ticket Number

closes #1924

Description

  • Enables the new Image Service to sync both Profile and Discord Image for a user. Note - Currently this feature is behind a feature flag.
  • Temporary API docs here

Test Coverage

image

@@ -60,7 +60,8 @@
userValidator.validateImageVerificationQuery,
users.verifyUserImage
);
router.get("/picture/:id", authenticate, authorizeRoles([SUPERUSER]), users.getUserImageForVerification);
router.get("/picture/all", authenticate, authorizeRoles([SUPERUSER]), users.getAllUsersPhotoVerificationRequests);

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.
This route handler performs
authorization
, but is not rate-limited.
This route handler performs
authorization
, but is not rate-limited.
routes/users.js Fixed Show fixed Hide fixed
router.patch(
"/avatar/verify/:id",
authenticate,
authorizeRoles([SUPERUSER]),
checkIsVerifiedDiscord,
updateDiscordImageForVerification
);
router.patch(
"/avatar/update/:discordId",
authenticate,

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.
This route handler performs
authorization
, but is not rate-limited.
This route handler performs
authorization
, but is not rate-limited.
routes/users.js Dismissed Show dismissed Hide dismissed
@ivinayakg ivinayakg changed the title feat: image service integrated with feature flag [DRAFT] feat: image service integrated with feature flag Apr 14, 2024
Copy link
Member

@iamitprakash iamitprakash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test case stats missing

middlewares/authenticate.js Outdated Show resolved Hide resolved
Copy link
Contributor

@prakashchoudhary07 prakashchoudhary07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too long PR

constants/users.ts Show resolved Hide resolved
controllers/discordactions.js Outdated Show resolved Hide resolved
routes/users.js Show resolved Hide resolved
services/imageService.js Show resolved Hide resolved
routes/discordactions.js Outdated Show resolved Hide resolved
* @return {Promise<{Object}|{Object}>}
* @throws {Error} - If error occurs while fetching user's image verification entry
*/
const getAllUsersPhotoVerificationRequests = async (username = null) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any confusion or problem this may cause?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when I read the the function name, what i understand is get all users photo verification requests, is it doing the same?

models/users.js Show resolved Hide resolved
models/users.js Show resolved Hide resolved
test/integration/discordactions.test.js Outdated Show resolved Hide resolved
test/integration/discordactions.test.js Show resolved Hide resolved
models/users.js Outdated
url: profileImageUrl,
publicId: profileImageID,
approved: false,
date: admin.firestore.Timestamp.fromDate(new Date()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not use this formate, lets change it to the standard one which we are following at other place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

models/users.js Outdated
url: profileImageUrl,
publicId: profileImageID,
approved: false,
date: admin.firestore.Timestamp.fromDate(new Date()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is date here?
Did you mean createdAt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, this was already present there, therefore I opted for using the current ones only. But I can make the change to createdAt, as that will make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, I'll rather use updatedAt as the one single picture entry in the photo-verification object can be updated.

Comment on lines +441 to +445
await documentRef.update({ status: photoVerificationRequestStatus.APPROVED });
await updateUserPicture(
{ url: photoVerificationObject.profile.url, publicId: photoVerificationObject.profile.publicId },
userId
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do both the call needs to happen in a series?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, first the photo-verification-object needs to be updated, then the user picture needs to be updated too.

Comment on lines +463 to +468
const verificationImagesSnapshotQuery = photoVerificationModel.where(
"status",
"==",
photoVerificationRequestStatus.PENDING
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: why not declare/initialize it near to the line where its used?

});

const photoVerificationObject = await Promise.all(photoVerificationPromises);
return photoVerificationObject;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are results being paginated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no for now the results are not paginated, but I can add this into in optimization ticket, wdyt?

router.patch(
"/avatar/verify/:id",
authenticate,
authorizeRoles([SUPERUSER]),
checkIsVerifiedDiscord,
updateDiscordImageForVerification
);
// here "id" is the user's discord id
router.patch(
"/avatar/photo-verification-update/:id",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it following route naming conventions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync User Profile Image on Discord and RealDevSquad V1 [RFC]
7 participants