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

Chore: create setAvatarFromService endpoint #26402

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

Conversation

felipe-rod123
Copy link
Contributor

Proposed changes (including videos or screenshots)

Created the 'users.setAvatarFromService' endpoint for the apps/meteor/client/hooks/useUpdateAvatar.ts file, and added Ajv validations.

Issue(s)

Steps to test or reproduce

Further comments

@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 39.06%. Comparing base (3023022) to head (a93420b).
Report is 3262 commits behind head on develop.

❗ Current head a93420b differs from pull request most recent head ce2e59f. Consider uploading reports for the commit ce2e59f to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #26402      +/-   ##
===========================================
- Coverage    40.88%   39.06%   -1.83%     
===========================================
  Files          791      748      -43     
  Lines        17809    18647     +838     
  Branches      1928     1424     -504     
===========================================
+ Hits          7281     7284       +3     
- Misses       10232    11141     +909     
+ Partials       296      222      -74     
Flag Coverage Δ
e2e 39.06% <50.00%> (-1.83%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@felipe-rod123 felipe-rod123 marked this pull request as ready for review August 19, 2022 19:36
@felipe-rod123 felipe-rod123 requested review from a team as code owners August 19, 2022 19:36
ggazzo
ggazzo previously approved these changes Sep 21, 2022
@@ -226,6 +227,43 @@ API.v1.addRoute(
},
);

API.v1.addRoute(
'users.setAvatarFromService',
Copy link
Member

Choose a reason for hiding this comment

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

there is no need to create a new endpoint.. we already have the endpoint users.setAvatar, if it is missing this functionality we should just improve it.

@@ -29,7 +31,8 @@ Meteor.methods({
let user;

if (userId && userId !== Meteor.userId()) {
if (!hasPermission(Meteor.userId(), 'edit-other-user-avatar')) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Copy link
Member

Choose a reason for hiding this comment

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

instead of having to disable this rule, you can make your code compliant. one way to achieve that is assigning Meteor.userId() value to a variable and checking/using that variable, so something like:

const userId = Meteor.userId();
if (!userId) {
  throw new Error('generic error');
}

// now you can use userId here, no need to disable a TS lint rule
if (!hasPermission(userId, 'edit-other-user-avatar')) {
  // throw ...
}

Comment on lines +761 to +765
before((done) => {
updateSetting('Accounts_AllowUserAvatarChange', true).then(() => {
updatePermission('edit-other-user-avatar', ['admin', 'user']).then(done);
});
});
Copy link
Member

Choose a reason for hiding this comment

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

please use async/await (just like the lines above):

Suggested change
before((done) => {
updateSetting('Accounts_AllowUserAvatarChange', true).then(() => {
updatePermission('edit-other-user-avatar', ['admin', 'user']).then(done);
});
});
before(async () => {
await updateSetting('Accounts_AllowUserAvatarChange', true);
await updatePermission('edit-other-user-avatar', ['admin', 'user']);
});

Copy link
Contributor

dionisio-bot bot commented Apr 12, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR has conflicts, please resolve them before merging
  • This PR is missing the 'stat: QA assured' label
  • This PR is not mergeable
  • This PR is missing the required milestone or project
  • This PR has an invalid title

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

1 similar comment
Copy link
Contributor

dionisio-bot bot commented Apr 12, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR has conflicts, please resolve them before merging
  • This PR is missing the 'stat: QA assured' label
  • This PR is not mergeable
  • This PR is missing the required milestone or project
  • This PR has an invalid title

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

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

Successfully merging this pull request may close these issues.

None yet

3 participants